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

All documents recognized as HTML in Chrome >= 32 #73

Open
loganfsmyth opened this issue Nov 18, 2013 · 2 comments
Open

All documents recognized as HTML in Chrome >= 32 #73

loganfsmyth opened this issue Nov 18, 2013 · 2 comments

Comments

@loganfsmyth
Copy link

The isHTMLDocument feature detection flag is true for XML documents in Chrome 32, so any attempt to use a function that triggers setDocument on an XML element throws "Uncaught TypeError: Cannot set property 'display' of null".

e.g. http://jsfiddle.net/TcyEW/1

The offending code is https://github.com/mootools/slick/blob/master/Source/Slick.Finder.js#L84

// on non-HTML documents innerHTML and getElementsById doesnt work properly
try {
        testNode.innerHTML = '<a id="'+id+'"></a>';
        features.isHTMLDocument = !!document.getElementById(id);
} catch(e){}

This is caused by:
Move 'innerHTML': https://code.google.com/p/chromium/issues/detail?id=311080
Wrong 'id': https://code.google.com/p/chromium/issues/detail?id=315168

@arian
Copy link
Member

arian commented Nov 19, 2013

Thanks, so because of https://code.google.com/p/chromium/issues/detail?id=311080 innerHTML actually works on all DOM elements...

We could also check if testNode.style or some other property of HTMLElement (http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-58190037)is available. Or use Object.prototype.toString(testNode).slice(1, 5) == 'HTML'.

@loganfsmyth
Copy link
Author

Yep, and innerHTML is actually already works like that on Firefox, but it doesn't fail because on Firefox the getElementById returns null because the id attribute isn't defined as an ID attribute in the DTD of most documents.

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

No branches or pull requests

2 participants