Ticket #3677 (closed bug: wontfix)

Opened 6 years ago

Last modified 23 months ago

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:
Blocking: Blocked by:

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

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

Change History

Changed 6 years ago by dmethvin

Test case main

Changed 6 years ago by dmethvin

UI 1.6rc2 with slide effect

Changed 6 years ago by dmethvin

Sample script to embed in hidden content

comment:1 Changed 6 years ago by dmethvin

comment:2 Changed 6 years ago by rdworth

  • Component changed from ui.core to effects.core

comment:3 Changed 6 years ago by rdworth

  • Priority changed from minor to major
  • Milestone changed from TBD to 1.6

comment:4 Changed 5 years ago by rdworth

  • Milestone changed from 1.7 to 1.8

comment:5 Changed 4 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 4 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 4 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 4 years ago by scott.gonzalez

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 3 years ago by gnarf

#4839 is a duplicate of this ticket.

comment:10 Changed 3 years ago by gnarf

  • Status changed from new to open

comment:11 Changed 2 years ago by scott.gonzalez

#8278 is a duplicate of this ticket.

comment:12 Changed 2 years ago by scott.gonzalez

#8460 is a duplicate of this ticket.

comment:13 Changed 23 months ago by scott.gonzalez

  • Milestone changed from 1.9.0 to 1.10.0

comment:14 Changed 23 months ago by mikesherov

  • Status changed from open to closed
  • Resolution set to wontfix

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.