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

Slick throws when feature testing XHTML document #74

Open
nwellnhof opened this issue Mar 3, 2014 · 0 comments
Open

Slick throws when feature testing XHTML document #74

nwellnhof opened this issue Mar 3, 2014 · 0 comments

Comments

@nwellnhof
Copy link

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.

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

1 participant