Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#1763 closed bug (fixed)

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:
Blocked by: Blocking:


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 (1)

comment:1 Changed 15 years ago by davidserduke

Resolution: fixed
Status: newclosed

Fixed in [4014].

Note: See TracTickets for help on using tickets.