Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#9647 closed bug (duplicate)

.append() fails when jQuery object in array

Reported by: jquery@… Owned by:
Priority: low Milestone: 1.next
Component: manipulation Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:

Description

1. The version(s) of jQuery affected

tested: 1.0, 1.3, 1.6.1 (all minified, 1.0 packed)

2. The browser (or browsers) that you are able to reproduce the bug in, including version numbers

Firefox 4.0.1 Chrome 12.0

3. The operating system (or operating systems) you experienced the bug on.

Windows 7

4. Step-by-step instructions on how to reproduce the issue, including any required system configuration changes

Following script.

jQuery(function(){
	var $ = jQuery;	// for jQuery 1.0
	// OK:
	$('body').append($('<p>'),$('<p>'));
	// OK:
	$('body').append([document.createElement('p'),document.createElement('p')]);
	// ERROR:
	$('body').append([$('<p>'),$('<p>')]);
});

5. A description of what you expect to happen, and what actually happens

For visualisation I added a border to paragraph tags in the CSS. Because they are empty tags this renders as a line (when successful). I would expect 6 such lines; each statement renders two.

I get four lines, so the last statement fails. Firefox (Firebug) says: NS_ERROR_XPC_BAD_CONVERT_JS. Chrome says: NOT_FOUND_ERR DOM Exception 8.

6. A link to a reduced, working demo/test case that will never move (jsFiddle is good for this)

http://jsfiddle.net/RfMaW/

7. Information on other jQuery versions tested, including whether or not the issue is reproducible there

Reproducible on all versions tested: 1.0, 1.3, 1.6 (jsFiddle), 1.6.1 Versions (except jsFiddle) were minified/packed versions.

8. Information on other browsers where the issue does not occur

Only tested Firefox and Chrome. Suspect IE and Opera will not make a difference.

9. References to the URL of a web server mentioned in your ticket (if any) in the case of a bug involving Ajax or server-side requests which are needed to fully evaluate the issue experienced.

not present

10. A patch (preferably as a link to a GitHub commit or pull request)

sorry, not my expertise

11. A link to any relevant discussions, such as forum posts.

not available

Change History (4)

comment:1 Changed 8 years ago by timmywil

Component: unfiledmanipulation
Priority: undecidedlow

I don't think that signature is supported. If in an array, they should be nodes.

Internally, this is because the clean function loops through the object and instead of having to loop through each individual jQuery object (e.g. [ $(node, node), $(node, anotherNode) ]), it will assume each spot in the array is a node. This means you can you use just a jquery object (e.g. $(node, node) ) or a simple array of nodes (e.g. [ node, node ]). Supporting arrays of jQuery objects is more complex and I think more than is needed.

comment:2 Changed 8 years ago by timmywil

Resolution: duplicate
Status: newclosed

comment:3 Changed 8 years ago by timmywil

Duplicate of #9011.

comment:4 Changed 8 years ago by jquery@…

That is responsive.

I searched for this "bug" but could not easily find a duplicate. As in the original case, I too bumped into this by using $.map(). The discussion in the original ticket is adequate and very helpful. Thanks.

Note: See TracTickets for help on using tickets.