Bug Tracker

Opened 11 years ago

Closed 9 years ago

#3337 closed bug (worksforme)

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:

Description

how to repeat:

  1. create a textarea with

<object width="464" height="392"><param name="movie" value="http://embed.break.com/NTY2ODcz"></param><param name="allowScriptAccess" value="always"></param><embed src="http://embed.break.com/NTY2ODcz" type="application/x-shockwave-flash" allowScriptAccess=always width="464" height="392"></embed></object><br /><font size=1><a href="http://break.com/index/big-guy-cries-to-stop-fight.html">Big Guy Cries To Stop Fight</a> - Watch more <a href="http://www.break.com/">free videos</a></font>

as the value

  1. do var my_text=$($('textarea').val()) basically converting the html above to a jquery object
  1. do a my_text.find('*') you will get several elements but you will not get the EMBED
  1. now do my_text.find('embed') you will get the element

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

Attachments (2)

jquery_embed_test.js (1.0 KB) - added by thepug 11 years ago.
test_ie_embed.html (513 bytes) - added by thepug 11 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 11 years ago by wahyudinata

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

comment:2 Changed 11 years ago by flesler

Cc: wahyudinata flesler added
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. Thanks.

comment:3 Changed 11 years ago by thepug

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 11 years ago by thepug

Attachment: jquery_embed_test.js added

Changed 11 years ago by thepug

Attachment: test_ie_embed.html added

comment:4 Changed 11 years ago by thepug

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.

comment:5 Changed 11 years ago by flesler

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.

comment:6 Changed 9 years ago by dmethvin

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.

Note: See TracTickets for help on using tickets.