Opened 8 years ago

Closed 4 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.

Change History (14)

comment:1 Changed 8 years ago by dmethvin

comment:2 Changed 8 years ago by rdworth

  • Component changed from ui.core to effects.core

comment:3 Changed 8 years ago by rdworth

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

comment:4 Changed 7 years ago by rdworth

  • Milestone changed from 1.7 to 1.8

comment:5 Changed 6 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 6 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 6 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 6 years ago by scottgonzalez

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

#4839 is a duplicate of this ticket.

comment:10 Changed 5 years ago by gnarf

  • Status changed from new to open

comment:11 Changed 4 years ago by scottgonzalez

#8278 is a duplicate of this ticket.

comment:12 Changed 4 years ago by scottgonzalez

#8460 is a duplicate of this ticket.

comment:13 Changed 4 years ago by scottgonzalez

  • Milestone changed from 1.9.0 to 1.10.0

comment:14 Changed 4 years ago by mikesherov

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

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.