Bug Tracker

Modify

Ticket #3592 (closed bug: fixed)

Opened 5 years ago

Last modified 3 years ago

append() evaluates script tags with non-script types

Reported by: zach Owned by: flesler
Priority: minor Milestone: 1.3
Component: manipulation Version: 1.2.6
Keywords: Cc:
Blocking: Blocked by:

Description

Using $(document).append(content) will strip out all script tags from content and attempt to evaluate them. This throws errors when the script tag contains content other than JavaScript, even when the type attribute of the script tag is set appropriately. Normal browser behavior is to ignore such content and not try to evaluate it, but append() is inconsistent with this.

I added an exception for my specific case (text/html content for use with John's micro-templating[1]) so the script tag would not be stripped and I found no issues when appending (IE6/7/8b2 on IETester, Chrome, FF3/2 linux, Opera 9.51 linux.)

It would be useful for append() to follow the behavior of browsers regarding script tags and only attempt to evaluate scripts when the type is missing or is a recognized script mime type (text/javascript or application/javascript.)

[1]:  http://ejohn.org/blog/javascript-micro-templating/

Attachments

jquery-patch.diff Download (515 bytes) - added by zach 5 years ago.
the patch I'm using

Change History

Changed 5 years ago by zach

the patch I'm using

comment:1 Changed 4 years ago by dmethvin

  • Component changed from unfilled to core

comment:2 Changed 3 years ago by rwaldron

  • Status changed from new to closed
  • Resolution set to fixed
  • Component changed from core to manipulation

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.