I have a shadow dom which contains the root element and a vue component.
<template>
<div class="container">
<div id="app"></div>
</div>
<script src="http://my-site.com/app/js/vue-component.js"></script>
</template>
<div id="hostElement"></div>
<script>
// create shadow DOM on the <p> element above
const shadow = document.querySelector('#hostElement').attachShadow({mode: 'open'});
const template = document.querySelector('template');
shadow.appendChild(document.importNode(template.content, true));
</script>
Inside the vue-component.js
looks something like this:
import Vue from 'vue';
const shadow = document.querySelector('#hostElement').shadowRoot;
new Vue({
el: shadow.querySelector('#app'),
// ...
})
// this doesn't work because I think Vue is using document.querySelector('#app')
// instead of the required document.querySelector('#hostElement').shadowRoot.querySelector('#app')
// new Vue ({
// el: '#app'
// })
Everything works fine if I use this stuff outside the shadow dom (like regular people do). However, it seems like Vue isn't able to handle shadow dom stuff. I believe it shouldn't be calling document.querySelector
if it's inside the shadow dom. Instead, it should be running shadowRoot.querySelector
.
Please let me know if this is confusing at all, I'm in a uncommon use case scenario so it is a little hard to explain.