always attach fragment to shadow root (fixes #821)

pull/833/head
Rich Harris 8 years ago
parent ef2a2b329a
commit 5f2ea34d84

@ -208,6 +208,12 @@ export default function dom(
this._fragment = @create_main_fragment(this._state, this); this._fragment = @create_main_fragment(this._state, this);
${generator.customElement ? deindent`
this._fragment.create();
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}(this.shadowRoot, null);
if (options.target) this._mount(options.target, options.anchor || null);
` : deindent`
if (options.target) { if (options.target) {
${generator.hydratable ${generator.hydratable
? deindent` ? deindent`
@ -219,9 +225,7 @@ export default function dom(
${options.dev && `if (options.hydrate) throw new Error("options.hydrate only works if the component was compiled with the \`hydratable: true\` option");`} ${options.dev && `if (options.hydrate) throw new Error("options.hydrate only works if the component was compiled with the \`hydratable: true\` option");`}
this._fragment.create(); this._fragment.create();
`} `}
${generator.customElement ? this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}(options.target, options.anchor || null);
`this._mount(options.target, options.anchor || null);` :
`this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}(options.target, options.anchor || null);`}
${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent` ${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent`
${generator.hasComponents && `this._lock = true;`} ${generator.hasComponents && `this._lock = true;`}
@ -231,6 +235,9 @@ export default function dom(
${generator.hasComponents && `this._lock = false;`} ${generator.hasComponents && `this._lock = false;`}
`} `}
} }
`}
`; `;
if (generator.customElement) { if (generator.customElement) {
@ -272,7 +279,6 @@ export default function dom(
customElements.define("${generator.tag}", ${name}); customElements.define("${generator.tag}", ${name});
@assign(${prototypeBase}, ${proto}, { @assign(${prototypeBase}, ${proto}, {
_mount(target, anchor) { _mount(target, anchor) {
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}(this.shadowRoot, null);
target.insertBefore(this, anchor); target.insertBefore(this, anchor);
}, },

Loading…
Cancel
Save