Skip to main content

Bug Tracker

Side navigation

#13043 closed bug (notabug)

Opened December 12, 2012 09:31PM UTC

Closed December 13, 2012 12:44AM UTC

Last modified December 17, 2012 07:50PM UTC

append fails with HierarchyRequestError when cloned objects are cached and later appended

Reported by: ryanmch@microsoft.com Owned by: ryanmch@microsoft.com
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

Scenario:

Adding rows to a table by cloning the last row, resetting the input values and adding a change handler to each text input

Assumptions:

Given a table defined in the DOM with id="tbl"

The table has a minimum of one row defined with one text input in each of one or more cells

This works:

var tbl = $("#tbl")[0];

$(tbl).append($(tbl.rows[tbl.rows.length-1]).clone().find("input:text").val("").change(tableCellTextChanged).end());

This Fails:

var arr = [];

var tbl = $("#tbl")[0];

arr.push($(tbl.rows[tbl.rows.length-1]).clone().find("input:text").val("").change(tableCellTextChanged).end());

$(tbl).append(arr[0]); // Throws HierarchyRequestError in the Clean function in JQuery

Using native JavaScript works though:

var arr = [];

var tbl = $("#tbl")[0];

arr.push($(tbl.rows[tbl.rows.length-1]).clone().find("input:text").val("").change(tableCellTextChanged).end()[0]);

tbl.appendChild(arr[0]);

Attachments (0)
Change History (5)

Changed December 12, 2012 09:37PM UTC by dmethvin comment:1

owner: → ryanmch@microsoft.com
status: newpending

Please provide a test case in jsFiddle. Also, did you mean to append to the table TBODY? Rows don't under the table element.

Changed December 12, 2012 11:25PM UTC by ryanmch@microsoft.com comment:2

status: pendingnew

Rows do append to the table object. Here is the URL for my jsfiddle test case. http://jsfiddle.net/ryanmch/W34SW/23/

Changed December 13, 2012 12:44AM UTC by dmethvin comment:3

resolution: → notabug
status: newclosed

I reduced your test case. http://jsfiddle.net/dmethvin/W34SW/30/

Try appending either an array of the DOM elements or a jQuery collection containing the DOM elements, but NOT a jQuery collection containing a jQuery collection with the DOM elements. For questions like this in the future, please ask for help on the forum.

Changed December 17, 2012 07:24PM UTC by ryanmch@microsoft.com comment:4

This does not work using JQuery 1.7.2 though. That is the version I specified in the bug. Your fiddle was using the latest JQuery version.

http://jsfiddle.net/ryanmch/W34SW/32/

Replying to [comment:3 dmethvin]:

I reduced your test case. http://jsfiddle.net/dmethvin/W34SW/30/ Try appending either an array of the DOM elements or a jQuery collection containing the DOM elements, but NOT a jQuery collection containing a jQuery collection with the DOM elements. For questions like this in the future, please ask for help on the forum.

Changed December 17, 2012 07:50PM UTC by dmethvin comment:5

I can't tell you what we fixed offhand, but if it works in the current version then that's the one I'd recommend. It does work in 1.8.3. We don't provide patches for old versions.