jQuery.extend can't merge object and array in some case and the result will be that the second value overwrites the first one. For example: jQuery.extend(true, a, b);
"b" will overwrite "a". To check this out i made an example code here: https://jsfiddle.net/y0ks9arp/3/ Hit the run and look at the console(firebug console for example) The first console.log is mediadatamap-overwritten.png(attached). The second console.log is mediadatamap-not-overwritten.png(attached). If fiddle for some reason is not accessible i attached the full code in a text file(jquery-extend-issue.txt) that can be tested for instance in firebug console.
Reproduce:
- Jquery update with jQuery 1.10
There is a node with a body field and an inline entity reference field. Call the parent node "A" and the referenced node "B". The "A" body field has an image(added with media browser), the "B" has two images(added with media browser) in its body field. You are in "A" node and try to edit the referenced "B" node, you hit the edit button the referenced node is loaded, and now you go back to parent node("A") body field and hit the source button. You will notice that json is disappeared.
I attached a couple of screenshot about this:
- node-a-image.png
- node-a-image-json.png
- node-b-edit.png
- node-a-image-json-disappeared.png
So the problem is that the mediaDataMap settings will be overwritten.
Comment | File | Size | Author |
---|---|---|---|
#2 | media-jquery-merge-problem-2815703-2.patch | 815 bytes | mibfire |
| |||
jquery-extend-issue.txt | 41.67 KB | mibfire | |
mediadatamap-not-overwritten.png | 22.95 KB | mibfire | |
mediadatamap-overwritten.png | 124.09 KB | mibfire | |
node-a-image-json-disappeared.png | 188.96 KB | mibfire |
Comments
Comment #2
mibfire CreditAttribution: mibfire commentedI made a patch to fix this.
Comment #3
gmclelland CreditAttribution: gmclelland commentedPatch attached. Setting to NR
Comment #4
joseph.olstadNote: there's an option in jQuery_update to allow using the default core jQuery for admin interfaces and specific admin themes... Thats probably why others haven't reported this issue because they have jquery_update overrides , so their front-end theme may be using jQuery 1.10.2 but their back end is using the original jQuery that comes with core.
However, if this is a backwards compatible change, as long as it doesn't break default jQuery then yes I think we should make the change. It would be good to have a confirmation on this.
Comment #5
joseph.olstadis this patch still working on 7.x-2.0-beta7?
Comment #6
joseph.olstadmediadatamap-not-overwritten
mediadatamap-overwritten
node-a-image-json-dissappeared
Comment #7
joseph.olstadI'm not sure if this issue still exists, needs testing to see if this patch still works against older jQuery versions
Comment #8
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedThe 2 year old patch in #2 to media_wysiwyg.filter.inc does not apply to the latest media 7.x-2.x-dev and needs a reroll.