Skip to main content

Bug Tracker

Side navigation

#3337 closed bug (worksforme)

Opened September 08, 2008 06:39AM UTC

Closed June 20, 2010 07:21PM UTC

find('*') is borked in a certain case.

Reported by: wahyudinata Owned by:
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: Cc: wahyudinata, flesler
Blocked by: Blocking:

how to repeat:

1. create a textarea with

<object width="464" height="392"><param name="movie" value=""></param><param name="allowScriptAccess" value="always"></param><embed src="" type="application/x-shockwave-flash" allowScriptAccess=always width="464" height="392"></embed></object><br /><font size=1><a href="">Big Guy Cries To Stop Fight</a> - Watch more <a href="">free videos</a></font>

as the value

2. do var my_text=$($('textarea').val()) //basically converting the html above to a jquery object

3. do a my_text.find('*') you will get several elements but you will not get the EMBED

4. now do my_text.find('embed') you will get the element

the find('*') should get you everything shouldn't it?

Attachments (2)
Change History (6)

Changed September 08, 2008 07:29AM UTC by wahyudinata comment:1

extra info: according to Malen, jquery cannot find the <font> tag, more tests needed

Changed September 08, 2008 10:00PM UTC by flesler comment:2

cc: → wahyudinata, flesler
need: ReviewTest Case

Can you turn this loose data into a formal test case ?

a minimalistic html file with the requires html and js to reproduce the problem.


Changed October 16, 2008 04:20PM UTC by thepug comment:3

I have a test case for this, but also I think IE is broken when finding 'embed' tags. Please let me know if I should open a ticket for that. The test case displays the error described above and if you run it in IE , it shows the error when searching for the embed tag.

attaching files

Changed October 16, 2008 07:32PM UTC by thepug comment:4

The problem seems to be in the 'clean' function. The clean function creates a 'div' , sets the innerHtml to the html string, and returns the div's child nodes. The resulting child node in my test case is the 'object' element. However when iterating through the 'object' childNodes , in IE the 'embed' node is just missing. In firefox, the 'embed' node is there, but its not the same type as the 'param' child nodes.

Changed October 16, 2008 08:55PM UTC by flesler comment:5

I think this is the expected behavior. IE ignores embeds, FF ignores objects.

You simply need to "find" them both and append (or whatever you're doing) both. The one accepted will be found by jQuery.

Changed June 20, 2010 07:21PM UTC by dmethvin comment:6

resolution: → worksforme
status: newclosed

I agree with flesler, the browser will sometimes discard nodes for these cases. It's not feasible for jQuery to manually parse the HTML in order to create a workaround, so the best thing to do is work with the resulting DOM that is created by the browser.