Featured post
javascript - Prototype and jQuery concatenation failure -
edit: i've taken jquery , prototype libs out of equation, problem still remains.
simplified test case 1 - without concatenation
$ function decalared using window.$ in a.js, , declared in function notation in b.js. b.js loaded second, , overwrites a.js $ function
simplified test case 2 - with concatenation
combined a.js , b.js, first, , b second. function declaration
i found strange when trying concatenate prototype , jquery. seems though when concatenated, $ jquery reference doesn't overwritten prototype. i've built 2 test cases single out, , it's failing in chrome8 , ff 3.6.
test case 1 - without concatenation
jquery , prototype loaded separately different script tags. jquery loaded first, prototype second.
test case 2 - with concatenation
jquery , prototype concatenated single file, , loaded single script tag. jquery first in script, , prototype added second.
these should act identically, second test throwing errors because $ function in prototype doesn't overwrite $ jquery reference.
did set these wrong, or browsers rendering javascript differently when it's in same file?
the $ function in prototype instantiated function declaration:
function $(element) {
since prototype library not in closure, assumed scope window. variable , function declarations hoisted top of scope, "function $" declared, , $ variable overwritten jquery.
here's fiddle: http://jsfiddle.net/psc7s/
- Get link
- X
- Other Apps
Comments
Post a Comment