-
Notifications
You must be signed in to change notification settings - Fork 20
Description
The feature detection code in Slick.Finder throws an exception with XHTML documents in Firefox and Chrome. I think this used to work with earlier versions of these browsers, but I'm not sure. Example:
var parser = new DOMParser();
var xml = parser.parseFromString('<html xmlns="http://www.w3.org/1999/xhtml"><body></body></html>', 'text/xml');
xml.documentElement.getElement('body');
Results in TypeError: testNode.style is undefined in Firefox, Uncaught TypeError: Cannot set property 'display' of null in Chrome.
JSFiddle: http://jsfiddle.net/4UFHV/
The exception is thrown at line 89 in Slick.Finder.js.
Reason: The test node is created with an empty namespace. Subsequently, the innerHTML and getElementsById tests succeed, the document is detected as HTML, but setting a style on the newly created element fails.
Possible solution: Create the test node using createElementNS:
var testNode = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
This works for XHTML documents but it might break other HTML documents.