Skip to content
This repository has been archived by the owner on Jun 6, 2019. It is now read-only.

Fix table element parsing in ie11 #39

Merged
merged 5 commits into from
May 22, 2018
Merged

Conversation

TimvdLippe
Copy link
Contributor

Using the fix from jQuery when setting the innerHTML text. See the links in the source code for the original implementation. This solution was previously submitted in a different form in #16 and #19 by @kapouer, but these were never merged for other unrelated reasons.

Fixes #3

Copy link
Contributor

@sorvell sorvell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add tests for all the special table nodes (col and thead look missing). Otherwise looks ok. Thanks!

@TimvdLippe
Copy link
Contributor Author

@sorvell Done!

@jay8t6
Copy link

jay8t6 commented Apr 16, 2018

@TimvdLippe This is awesome! Thanks!

@web-padawan
Copy link

I'm wondering if the similar fix can be applied to the select element as well?
See Polymer/polymer#1735

@TimvdLippe
Copy link
Contributor Author

@web-padawan Hm yes that should be possible. Let me update the PR tomorrow

template.js Outdated
['tr']: ['tbody', 'table'],
['th']: ['tr', 'tbody', 'table'],
['td']: ['tr', 'tbody', 'table']
'option': ['select'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW maybe also optgroup tag?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is working correctly in IE11, is it not?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, I was just guessing. Here is the glitch to check: https://morning-fuel.glitch.me

@smalluban
Copy link

@sorvell Is there anything more, that stops this PR from merging?

@dfreedm dfreedm merged commit f784f19 into master May 22, 2018
@dfreedm dfreedm deleted the fix-table-element-innerhtml-ie-11 branch May 22, 2018 17:50
@TechQuery
Copy link

But it will be failed in this case:

<table>
    <tbody><template>
        <tr><td>Something...</td></tr>
    </template></tbody>
</table>

HTML parser of IE will drop <template /> directly, you won't find anything of your template...

@TimvdLippe
Copy link
Contributor Author

@TechQuery Yes and there is nothing we can do about it 😢 The template is already gone before we even have a chance to search for it. For more info see: Polymer/polymer#1567 (comment)

@TechQuery
Copy link

@TimvdLippe So I can only allow users to replace <template /> with <!-- -->...

@TimvdLippe
Copy link
Contributor Author

Unfortunately that is the result of parsing of IE11. Don't think you have any other option. I would like it to be different, but haven't found a workable solution 😢

@tekreme73
Copy link

tekreme73 commented Jan 4, 2019

I got a workable solution for you if you have to use a table layout.

I created a custom element for each layers of my table: x-table, x-header, x-row and x-cell. For each layers, I defined the :host CSS display property to match the table layout behavior like:

  • x-table => display: table
  • x-header => display: table-header-group
  • x-row => display: table-row
  • x-cell => display: table-cell

With this solution, I'm able to do dom-repeat for the rows, even with IE11.
It will need some CSS tricks to have the same behavior as a native table tag but it does the stuff.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<template> polyfill not working when template root element is <tr>
8 participants