Opened 14 years ago

Closed 11 years ago

#3677 closed bug (wontfix)

Javascripts re-execute on show/hide

Reported by: dmethvin Owned by:
Priority: major Milestone: 1.10.0
Component: ui.effects.core Version: 1.6rc2
Keywords: Cc:
Blocked by: Blocking:

Description

Referred from http://dev.jquery.com/ticket/3707

If the content being hidden has an embedded script tag, the script is executed a second time. Test case attached using slide effect.

Attachments (3)

ui-script-rerun.html (1.0 KB) - added by dmethvin 14 years ago.
Test case main
jquery-ui-1.6rc2.js (30.8 KB) - added by dmethvin 14 years ago.
UI 1.6rc2 with slide effect
alert.js (13 bytes) - added by dmethvin 14 years ago.
Sample script to embed in hidden content

Download all attachments as: .zip

Change History (17)

Changed 14 years ago by dmethvin

Attachment: ui-script-rerun.html added

Test case main

Changed 14 years ago by dmethvin

Attachment: jquery-ui-1.6rc2.js added

UI 1.6rc2 with slide effect

Changed 14 years ago by dmethvin

Attachment: alert.js added

Sample script to embed in hidden content

comment:1 Changed 14 years ago by dmethvin

comment:2 Changed 14 years ago by rdworth

Component: ui.coreeffects.core

comment:3 Changed 14 years ago by rdworth

Milestone: TBD1.6
Priority: minormajor

comment:4 Changed 14 years ago by rdworth

Milestone: 1.71.8

comment:5 Changed 13 years ago by bencoe

I think is caused by domManip() in association with $.wrap in jquery. When a new element is appended to the dom a stack of scripts to execute is created and evaluated. wrap() uses append() which calls domManip() which re-executes script tags. My thought is that createWrapper() in jquery.effects.core could potentially tear out script tags (these are torn out later on anyways). My assumption being that effects should be executed on visible elements, which means their scripts will already have been executed.

Any ways, here is my potential fix:

http://github.com/bcoe/jquery-ui/commit/58895f118754b1aee823dbfdab3c4442b74c24af

comment:6 Changed 13 years ago by bencoe

This actually provides a better fix in my opinion:

http://github.com/bcoe/jquery-ui/commit/780de910b27d778c0c58e9121c494cd313663a71

it checks to make sure the element has document as its parent before trying to remove the script tag. I think a better ultimate fix would be in the jquery core probably.

comment:7 Changed 13 years ago by bencoe

I've also patched this issue in jQuery... Which might be a more logical place to fix the problem. Basically, wrap() currently causes a script to execute a second time ... note that scripts are already stripped from the page after execution, making this fix less insane than it looks ;)

http://github.com/bcoe/jquery/commit/10169a02d6bc045881097d1b025a474cacf94283

comment:8 Changed 13 years ago by Scott González

Thanks for the pataches ben. We're trying to figure out how to properly handle this in core. The problem exists with more than just .wrap(). See http://dev.jquery.com/ticket/3105 for the underlying problem.

comment:9 Changed 12 years ago by Corey Frang

#4839 is a duplicate of this ticket.

comment:10 Changed 12 years ago by Corey Frang

Status: newopen

comment:11 Changed 11 years ago by Scott González

#8278 is a duplicate of this ticket.

comment:12 Changed 11 years ago by Scott González

#8460 is a duplicate of this ticket.

comment:13 Changed 11 years ago by Scott González

Milestone: 1.9.01.10.0

comment:14 Changed 11 years ago by mikesherov

Resolution: wontfix
Status: openclosed

This will be fixed in core in jquery 1.9 here: http://bugs.jquery.com/ticket/9134

Note: See TracTickets for help on using tickets.