Skip to content
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

Ie fixes #3

Merged
merged 6 commits into from
May 11, 2016
Merged

Ie fixes #3

merged 6 commits into from
May 11, 2016

Conversation

ScottFreeCode
Copy link
Contributor

Tried this out on IE 11 and it was basically non-functional. Besides having to add an XPath library (see #2), there were a few little broken things. I tracked them down, fixed them, organized the fix as nicely as I could... Let me know what you think; I'm hoping it doesn't break anything for other browsers or older versions of IE (well, anything that was working before anyway).

This was referenced Feb 21, 2016
In IE11, using DOMParser to generate a DOM from a string doesn't include
innerHTML and outerHTML everywhere we need it; it's either that it
doesn't put it on non-HTML tags, or that it doesn't do it for mime type
text/xml, or else a combination of the two. Possible fixes include using
text/html if that would even work with non-HTML tags like <template> and
then stripping the automatically added <html> and <body> tags, falling
back on something other than DOMParser to generate the DOM, and (the
method chosen for this fix) generating innerHTML and outerHTML by
cloning the DOM nodes into a known good dummy HTML node and using that
dummy node's innerHTML (equivalent to the child's outerHTML, simply
strip the outermost tag for its innerHTML).
I'm figuring this was some kind of debug thing, perhaps related to the
innerHTML issue on IE or getting the DOMParser right? If not, it can
always be uncommented.
Wasn't working in IE11, so if children is missing use childNodes and
filter out non-Element nodes. Also, test that the filter worked by doing
an nth-child test that has to ignore comments and text.
Instead of modifying the properties of the faulty node, simply access
innerHTML and outerHTML through a function that generates current data
if the properties are missing.
Convert this shim to a function also, in preparation to move the shim
functions out more modularly.
Move these into their own little space instead of embedding them next to
the places where they're used.
@ScottFreeCode
Copy link
Contributor Author

This should be mergeable (merge-able?) again now. I've rebased it onto master... Along the way, I dropped the XPath changes because they've been superseded by a fix to make the xpath library I've been using install itself on Document.prototype instead of window.document, and I also improved the consistency of the coding style used in the added parts.

@ScottFreeCode
Copy link
Contributor Author

I can also add that I've found that with these fixes Tranjsform works back to Internet Explorer 9. (8 I'd have to find out if there's a polyfill for DOMParser.)

Oh yeah, and I ended up deciding that unless they're used in multiple files adding a separate file for the shims complicated things too much usage-wise for little to no actual benefit. They're still moved out into their own section, but it's in the main tranjsform.js file.

@TRPB TRPB merged commit df4c1fe into Level-2:master May 11, 2016
@ScottFreeCode ScottFreeCode deleted the ie-fixes branch May 11, 2016 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants