phpjs
Version:
36 lines (25 loc) • 1.89 kB
HTML
<!-- Generated by Rakefile:build -->
<strong>
<a href="http://brett-zamir.me" rel="nofollow">Brett Zamir</a>
</strong>
on 2010-04-22 19:30:40 <br />
@Yen-Wei Liu: Thank you for the report! I've made some fixes in http://github.com/kvz/phpjs/raw/master/functions/language/require.js (and also a change for include()) which I believe should fix the issue. Our code was insufficient on two counts: the issue you brought up (though in your fix based on our earlier code, the script would I think actually be added above the head rather than inside it) and the fact that we really should be checking whether this is text/html or true XHTML or XML (since even XHTML served as text/html will have the problem you indicated) in order to make the decision, since as you pointed out, FF possessing the method does not mean it is suitable for the document.
<hr />
<strong>
Yen-Wei Liu
</strong>
on 2010-04-22 08:03:58 <br />
on line 27:
d.getElementsByTagNameNS ? d.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'head')[0].appendChild(script_block) : d.getElementsByTagName('head')[0].appendChild(script_block);
This doesn't run on some versions of browsers, such as FF 3.0 and FF 3.5.
These browsers have getElementsByTagNameNS() but only work with XHTML files, so they never get the "head" tag and
'[0]' would trigger an error/exception.
I suggest this should be fixed like that in include() , where I think someone has noticed this problem :
Change it to :
d.getElementsByTagNameNS ?
(d.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'head')[0] ?
d.getElementsByTagNameNS('http://www.w3.org/1999/xhtml', 'head')[0].appendChild(script_block) :
d.documentElement.insertBefore(script_block, d.documentElement.firstChild)
):
d.getElementsByTagName('head')[0].appendChild(script_block);
<hr />