fix empty script tags
Reported by Brian Moschel | March 18th, 2010 @ 05:09 AM
Loading a page with an empty script tag causes errors:
<script type='text/javascript'></script>
ERROR: [Thu Mar 18 2010 10:07:05 GMT-0500 (CDT)] {ENVJS} Error
loading script. Line: null
ERROR: [Thu Mar 18 2010 10:07:05 GMT-0500 (CDT)] {ENVJS} TypeError:
Cannot read property "length" from null
Comments and changes to this ticket
-
nickg March 18th, 2010 @ 05:36 AM
- Tag set to script
I will look into this too. I believe my yet-to-accepted patch fixes this.
-
Thatcher March 18th, 2010 @ 07:03 AM
Ah good catch, definitely shouldn't barf. empty script tags still do some
crazy stuff in browsers (empty tags with src attributes wont load for
example) -
nickg March 18th, 2010 @ 06:49 PM
My commit which rejiggered how [before|after]ScriptLoad is invoked does not have this problem.
http://github.com/client9/env-js/commit/9d5bdb6accb90a9668ec639fe5b...
or cutnpaste the file from
http://github.com/client9/env-js/blob/9d5bdb6accb90a9668ec639fe5b4a...
I understand this might not be the end-all be all of the API, but it's better and solves Brians problem.
-
nickg March 21st, 2010 @ 07:35 PM
- State changed from new to resolved
- Assigned user changed from Thatcher to nickg
Thanks for filling this since it uncovered some juicy bugs!
The problem is actually with HTMLScriptElement in that ascript.text can return NULL when it should return ''. Also it could return a partial script fragment instead of the whole script (unlikely but possible with very large scripts).
setting script.text was also incorrect.
Corrected, with lots of notes from spec, and a few unit tests. See commit http://github.com/thatcher/env-js/commit/d07dbde5c11bb4c80e9147bcc8... for more info (not happy with how git does diffs, but oh well).
Let me know if this doesn't fix the issues.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
a javascript browser environment