-
Notifications
You must be signed in to change notification settings - Fork 2
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
Ie fixes #3
Conversation
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.
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. |
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. |
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).