Side navigation
#10470 closed bug (fixed)
Opened October 11, 2011 09:18AM UTC
Closed November 19, 2012 02:54PM UTC
wrap() evaluates scripts
Reported by: | nick@nickhowes.co.uk | Owned by: | gibson042 |
---|---|---|---|
Priority: | low | Milestone: | 1.9 |
Component: | manipulation | Version: | 1.6.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Calling .wrap() will evaluate any scripts inside the element. This can cause problems when the browser has already run the scripts once. If this isn't considered a bug, it ought to be be mentioned in the documentation for wrap().
Workaround: manually do .remove('script') prior to using .wrap().
Demo:
Attachments (0)
Change History (12)
Changed October 12, 2011 02:06PM UTC by comment:1
status: | new → open |
---|
Changed October 12, 2011 02:09PM UTC by comment:2
Regarding the workaround, .remove('script') doesn't seem to work although .find('script').remove() does.
Changed November 01, 2011 10:39PM UTC by comment:3
The only way I can think of to fix this is to add an optional argument to domManip
(the function that wrap
ultimately relies upon) and then do something like:
if ( !ignoreScripts && scripts.length ) { jQuery.each( scripts, evalScript ); }
Does this seem reasonable? If so, I'm happy to write a patch.
Changed December 20, 2011 11:38AM UTC by comment:4
Actually, it looks like wrap first reloads the script tags and only then removes them.
If you wrap an element containing a script element once, it is executed. You can now inspect the DOM and will find out the script element is missing. Thus, if you try to wrap the same element once more, the script is not executed.
Is there any reason to execute the scripts when the first wrap() is called, if it is always removed from the DOM by the same call?
Check:
Tested in FF 8, Chrome 15, jQuery 1.7.1 and jQuery 1.4.1
Changed July 12, 2012 12:59AM UTC by comment:5
component: | unfiled → manipulation |
---|
Changed September 11, 2012 02:17AM UTC by comment:6
milestone: | None → 1.8.2 |
---|---|
owner: | → mikesherov |
priority: | undecided → low |
status: | open → assigned |
Changed September 17, 2012 04:13PM UTC by comment:7
milestone: | 1.8.2 → 1.9 |
---|
Changed October 16, 2012 05:08AM UTC by comment:8
blockedby: | → 11795 |
---|
Changed October 16, 2012 05:09AM UTC by comment:9
owner: | mikesherov → gibson042 |
---|
Changed October 31, 2012 01:08AM UTC by comment:10
#9134 is a duplicate of this ticket.