A Node was inserted somewhere it doesn't belong.
feeela opened this issue · 1 comments
feeela commented
There is a bug in dom.importstyles.js @line four:
https://github.com/chemerisuk/better-dom/blob/master/src/dom.importstyles.js#L4
If you have some HTML comment between the HTML and HEAD tags, _.docEl.firstChild
refers to such a comment and thus _.docEl.firstChild.appendChild()
throws the error mentioned in the headline. Instead of firstChild
you should use something like _.docEl.querySelector( 'head' )
to properly retrieve the HEAD element.
The markup to reproduce that error: (firstChild
refers to <!--<![endif]-->
)
<!DOCTYPE html>
<!--[if lte IE 8]><html class="no-js lt-ie9"><![endif]-->
<!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]-->
<head>
</head>
<body>
</body>
</html>
chemerisuk commented
You are correct, fixed in 781f504. BTW I've used a safer technique: http://www.paulirish.com/2011/surefire-dom-element-insertion/