Bug Tracker

Modify

Ticket #1763 (closed bug: fixed)

Opened 6 years ago

Last modified 5 years ago

In jQuery clean function, "doc" is sometimes not the proper scope

Reported by: nettles Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: doc, createElement Cc:
Blocking: Blocked by:

Description

When an object that is not the document is passed into the clean function as the second argument, line 783 fails because createElement is not a valid method on that object.

For me, this occurred while using the jqGrid plugin, which has the call stack listed at the bottom of this post. The line in question looks like:

var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement, tb = [];

Changing it to the following works:

var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement ? doc.createElement("div") : document.createElement("div"), tb = [];

Below is the stack trace of the entire issue:

doc.createElement is not a function
(no name)(0, "<tr id="1"><td>Row 1 - Value 1</td>")jquery-1.2.1.js (line 783)
each(["<tr id="1"><td>Row 1 - Value 1</td>"], function(), undefined)jquery-1.2.1.js (line 585)
clean(["<tr id="1"><td>Row 1 - Value 1</td>"], div)jquery-1.2.1.js (line 769)
init("<tr id="1"><td>Row 1 - Value 1</td>", div)jquery-1.2.1.js (line 44)
jQuery("<tr id="1"><td>Row 1 - Value 1</td>", div)jquery-1.2.1.js (line 20)
jQuery("<tr id="1"><td>Row 1 - Value 1</td>", div)jquery-1.2.1.js (line 21)
addJSONData(Object total=6 page=1 records=10 rows=[10], div)jquery.jqGrid.js (line 192)
(no name)(Object total=6 page=1 records=10 rows=[10])jquery.jqGrid.js (line 216)
success()jquery-1.2.1.js (line 2402)
onreadystatechange(39)jquery-1.2.1.js (line 2354)
[Break on this error] var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb =...

Change History

comment:1 Changed 5 years ago by davidserduke

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

Fixed in [4014].

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.