Bug Tracker

Modify

Ticket #3337 (closed bug: worksforme)

Opened 5 years ago

Last modified 3 years ago

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

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

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

Change History

comment:1 Changed 5 years ago by wahyudinata

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

comment:2 Changed 5 years ago by flesler

  • Cc wahyudinata, flesler added
  • need changed from Review to Test 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 5 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 5 years ago by thepug

Changed 5 years ago by thepug

comment:4 Changed 5 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 5 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 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to worksforme

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.