Skip to main content

Bug Tracker

Side navigation

#11135 closed bug (cantfix)

Opened January 06, 2012 04:23PM UTC

Closed January 06, 2012 05:12PM UTC

clean() misbehaves for self-referencing scripts

Reported by: andrew_sayers Owned by:
Priority: low Milestone: None
Component: manipulation Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

Tested in Firefox 9.0.1/Linux

Script tags of the form

<script class="foo">$(".foo")...</script>
are a useful alternative to
when you want to e.g.
a document, but don't work because the
tag is deleted while
looks to execute it.

Steps to replicate:

1. Go to

1. Click "Run"

1. Expected: "Inserted string" appears twice in the resultObserved: "Inserted string" only appears once

This seems to occur because

doesn't include
tags in the DocumentFragment it creates. I understand that
tags need to be run separately from HTML insertion, but variants of
<script class="foo">$(".foo")...</script>
are useful when e.g. a
needs to trigger some Javascript when the URL is inserted.

As well as running scripts explicitly, script tags should be included in the DocumentFragment so the script can refer to the tag it's in.

Attachments (0)
Change History (1)

Changed January 06, 2012 05:12PM UTC by rwaldron comment:1

component: unfiledmanipulation
priority: undecidedlow
resolution: → cantfix
status: newclosed

The reason jQuery removes scripts and executes them manually is because it uses innerHTML whenever possible to inject new HTML. innerHTML disallows script tags: