-
Notifications
You must be signed in to change notification settings - Fork 938
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table elements in ${repeat()} in FireFox #327
Comments
I've looked into this, apparently Firefox only allows table subelements as root element in a template that's being parsed by the browser and not when the content of the template is set using innerHTML: const content = `
<tr>
<td class=\"record\"></td>
<td></td>
</tr>
`;
const tpl = document.createElement('template');
tpl.innerHTML = content;
const container = document.createElement('div');
container.innerHTML = `<template>${content}</template>`;
const tpl2 = container.firstElementChild;
console.log('Created template', tpl, ...tpl.content.childNodes);
console.log('Parsed template', tpl2, ...tpl2.content.childNodes); Output in Firefox: Output in Chrome: |
Interesting. Thanks for investigating @bgotink Looks like we could update the getTemplateElement(): HTMLTemplateElement {
const template = document.createElement('template');
template.innerHTML = `<template>${this.getHTML()}</template>`;
return template.content.firstElementChild.content;
}
} Then we should add a test that fails when Firefox fixes this so we can remove the hack :) |
I did some further investigation, turns out I was testing in firefox on a page where ShadyDOM is active. Without ShadyDOM the output is as expected: Visit https://plnkr.co/edit/xALtastcvBI4VMeKv6cX?p=preview in Firefox and you'll see it's broken. Comment the script tag that loads the webcomponent shims and it'll work. EDIT: @justinfagnani I just noticed you already logged this in the ShadyDOM repo: webcomponents/shadydom#208 |
This issue is now solved when using the latest webcomponents shim! 🎉
|
@bgotink thanks for confirming it's fixed! |
Taking a look at https://glitch.com/edit/#!/forest-editorial?path=index.html:56:22 When you run the preview, in Chrome/Safari the repeats build a table with
<tr/>
and<td/>
elements as expected. However in Firefox, while you get the content printed, the table elements are missing.My demo is built with lit-element, so if you feel for some reason this is actually a lit-element issue, just let me know and I can move this over to that repo. Thanks!
Chrome:
Firefox:
The text was updated successfully, but these errors were encountered: