Bypassing element restrictions using :is
Version
3.0.11
This is also present in 2.6.12 and 3.1.0-beta.7.
Reproduction link
https://jsfiddle.net/skirtle/bo4zhkrs/
Steps to reproduce
Just run the example.
What is expected?
Vue prevents <script>
and <style>
tags from being used directly in templates because they cause side effects. Using <component :is>
(and presumably render
functions) allows this restriction to be bypassed. I think it would be better to prevent them across the board.
What is actually happening?
The tags are included and their contents cause side effects.
Feel free to reclassify this as an enhancement if you think that's appropriate. My assumption is that it's not intentional as I couldn't find a previous issue (for Vue 2 or 3) that suggested otherwise.
I encountered this when someone mentioned they were using it on Vue Land Discord. I don't know whether this workaround is common but any 'fix' could be considered a breaking change.
I assume this would need a runtime check, so I can understand why it might be seen as more burdensome than the current check in the template compiler.