When running Drupal.extend twice and supplying an object with string properties that already exists in the page scope (for instance, when ajax-loading a page including a call to drupal_add_js($script, 'setting'), the function attempts to recurse over string properties, thinking they are arrays or objects. This is caused by the following piece of code:
for (var i in obj) {
if (this[i]) {
...
}
}
I've attached a patch which seems to solve this issue without raising any side effect.
| Comment | File | Size | Author |
|---|---|---|---|
| drupal.js_.patch | 476 bytes | electricmonk |
Comments
Comment #1
electricmonk commentedComment #2
marcus_clements commentedI encountered this problem trying to use lightbox2 to display node edit forms.
The error has disappeared in Firefox and I haven't spotted any side effects.
Thanks for the patch.
Sadly doesn't seem to have solved the problems I'm having with IE7 and node/edit forms in lightbox, which I'd hoped it would...
cheers
Marcus
Comment #3
marcus_clements commentedIn case this helps someone...
This is a symptom which for me was part of a much larger problem which is making js and css available to modal lightbox forms. I'm using a tpl file to control what gets loaded into the lightbox, but because it is a node/add form, other modules need to add css and js for various functions (taxonomy ajax) etc. Because some of the css and js already exists in the main page "below" I have to be careful only to load those scripts necessary for the node/edit form which *dont* already exist.
With a create content link in a block that can be called from any page - this may be a pit of vipers...
Comment #4
electricmonk commentedThis may help - I created this function in order to do just that, only load the additional scripts loaded by an AJAX load operation. It's basically a copy of jQuery's $.load() function which, before applying the new scripts to the page, removes all existing ones from the loaded page.
Comment #5
electricmonk commentedI would like to apply this patch against the 5.x core. Anyone objects?
Comment #6
drummCommitted to 5.x.