Bug Tracker

Ticket #6180 (closed bug: fixed)

Opened 5 years ago

Last modified 3 years ago

jQuery.clean should not touch script tags that are not of type text/javascript

Reported by: rio Owned by: rjgotten
Priority: high Milestone: 1.6
Component: manipulation Version: 1.5
Keywords: Cc:
Blocking: Blocked by:

Description

At the very end of the clean function script tag nodes embedded in the nodes stored in the ret array are spliced into the ret array itself.

The clean function should not touch those scripts with a type different from "text/javascript" (e.g. custom types used for script island metadata). This check is partially in place, but still missing from:

ret.splice.apply(ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );

The direct use of getElementsByTagName() causes all non-"text/javascript" script tags to be moved to direct children of fragment. If this is combined with temporary container nodes (e.g. the Blind effect in jQuery UI) this causes those script tags to be 'eaten'.

A simple fix is $.grep()-ing the result from getElementsByTagName and only retaining those script elements with the "text/javascript" type.

Change History

comment:1 Changed 4 years ago by rjgotten

Created a jsFiddle which demonstrates the problem present in jQuery 1.4.3:  http://jsfiddle.net/3S8Kx/

And created a patch to manipulation.js:  http://github.com/rjgotten/jquery/commit/df7dfc2404807dce2f97c21782eb3a14ced86d6b

comment:2 Changed 4 years ago by snover

  • Priority set to high
  • Status changed from new to open
  • Version changed from 1.4.1 to 1.4.3
  • Milestone changed from 1.4.2 to 1.5

comment:3 Changed 4 years ago by snover

3rd party  pull request

comment:4 Changed 4 years ago by jitter

#7586 is a duplicate of this ticket.

comment:5 Changed 4 years ago by jitter

#6941 is a duplicate of this ticket.

comment:6 Changed 4 years ago by jitter

#6765 is a duplicate of this ticket.

comment:7 Changed 4 years ago by jitter

  • Owner set to rjgotten
  • Status changed from open to assigned
  • Version changed from 1.4.3 to 1.5
  • Milestone set to 1.next

This comment on #6765 might deserve some attention when considering to fix this bug.

comment:8 Changed 4 years ago by rwaldron

#8483 is a duplicate of this ticket.

comment:9 Changed 3 years ago by rwaldron

#8749 is a duplicate of this ticket.

comment:10 Changed 3 years ago by John Resig

  • Status changed from assigned to closed
  • Resolution set to fixed

Merge branch 'master' of  https://github.com/rjgotten/jquery into rjgotten-master. Also added in unit tests covering the case. Fixes #6180.

Conflicts:

src/manipulation.js

Changeset: 3418f323876043db63a2da9f653e51d5458647fa

comment:11 Changed 3 years ago by john

  • Milestone changed from 1.next to 1.6
Note: See TracTickets for help on using tickets.