To be clear: jQuery supports the pattern, it just requires the closing /.

$("<td/>") // ok
$("<td>") // ambiguous, malformed, not ok

$("<a href='http://google.com/'/>") // ok
$("<a href='http://google.com/'>") // ambiguous, malformed, not ok

--John



On Tue, Jun 23, 2009 at 10:37 AM, Daniel
Friesen<nadir.seen.f...@gmail.com> wrote:
>
> http://www.google.com/codesearch?hl=en&lr=&q=\%24\([%27%22]%3C[^%3C%3E%25]%2B[^%2F]%3E[%27%22]\)+lang%3Ajs&sbtn=Search
>
> I would have thought there'd be more. Frankly it is a sane way to think,
> jquery is dom manipulation and $('<td>') looks a lot like tag creation
> rather than something than html being mixed into jQuery.
> I for one have been thinking of $('<...>') as tag creation rather than
> raw html, or thinking that jQuery did it's own quick parsing for ages.
> Now I'll have to go back through 6 months of code to track down all the
> code using that pattern.
>
> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
>
> John Resig wrote:
>> I'm hesitant to support that since it tends to promote passing in
>> malformed (X)HTML. At least with <span attr='val'/> it's obvious that
>> it should be a standalone.
>>
>> --John
>>
>>
>>
>> On Tue, Jun 23, 2009 at 12:27 AM, Daniel
>> Friesen<nadir.seen.f...@gmail.com> wrote:
>>
>>> Ok, I agree that $('<div><span></span>') is just plain malformed html
>>> and doesn't need support.
>>> But to be honest $('<span>') looks like we're saying to create a span
>>> node, and likewise $('<span attr=val>') like we're trying to create a
>>> span with a single attr.
>>> Originally when I found out about $('<span>') I wasn't thinking HTML, I
>>> originally thought "Oh yay, jQuery has a shortcut for
>>> document.createElement, and after when I saw that $('<span foo=bar />')
>>> was possible I didn't think HTML, I still thought, createElement + attr
>>> setting.
>>>
>>> Would a patch that just makes $('<span attr=val>') work properly across
>>> browsers be accepted?
>>>
>>> That should be something simple like checking if it starts with < and
>>> ends with >, contains no other <>'s and doesn't have a / before the >
>>> then insert a single / before the last > before continuing.
>>>
>>> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
>>>
>>> John Resig wrote:
>>>
>>>> Unfortunately, there's not really a whole lot that we can do on our
>>>> end to fix a problem like that - short of including a full HTML
>>>> parser/DOM generator.
>>>>
>>>> Now, I've written one:
>>>> http://ejohn.org/blog/pure-javascript-html-parser/
>>>>
>>>> but it's probably just better to make sure that your injected HTML is
>>>> well-formed.
>>>>
>>>> --John
>>>>
>>>>
>>>>
>>>> On Mon, Jun 22, 2009 at 6:45 PM, Daniel
>>>> Friesen<nadir.seen.f...@gmail.com> wrote:
>>>>
>>>>
>>>>> I ran into another IE issue with unclosed tag syntax inside node
>>>>> creation (I personally like to leave the / out unless necessary most of
>>>>> the time, especially since it flows fairly nice with .text(userVar)).
>>>>>
>>>>> http://jsbin.com/ejote
>>>>>
>>>>> <span></span>
>>>>> <span />
>>>>> <span/>
>>>>> <span>
>>>>> <span class=foo />
>>>>>
>>>>> All work in ie7, ie8, opera, firefox, and midori.
>>>>>
>>>>> However:
>>>>> <span class=foo>
>>>>> <span class="foo">
>>>>>
>>>>> Fail in ie7 and ie8 while they work in firefox, midori, and opera.
>>>>>
>>>>> Filed as: http://dev.jquery.com/ticket/4806
>>>>>
>>>>> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
>>>>>
>>>>> John Resig wrote:
>>>>>
>>>>>
>>>>>> This is very helpful analysis. I've added it to my todo list. Could
>>>>>> you file a ticket with your test cases, as well? Thanks!
>>>>>> http://dev.jquery.com/newticket
>>>>>>
>>>>>> --John
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Jun 22, 2009 at 4:33 PM, Daniel
>>>>>> Friesen<nadir.seen.f...@gmail.com> wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Ok, narrowed it down.
>>>>>>> Someone tells me that Konqueror isn't working for that page either so it
>>>>>>> looks like IE8 and Konqueror may share this behavior.
>>>>>>>  From the looks of it $button.append( "[" ); is working.
>>>>>>>
>>>>>>> $('#bodyContent').append( "[" ); // works
>>>>>>> $('#bodyContent').append( "[", "]" ); // "Invalid argument" in IE8 
>>>>>>> console, works in FF Firebug console
>>>>>>> $('#bodyContent').append( "asdf", "asdf" ); // "Invalid argument" in 
>>>>>>> IE8 console, works in FF Firebug console
>>>>>>> $('#bodyContent').append( document.createTextNode("["), "]" ); // works
>>>>>>> $('#bodyContent').append( "<span>foo</span>", "]" ); // in IE8 console 
>>>>>>> only inserts the ']' the foo span is not inserted, works in FF Firebug 
>>>>>>> console
>>>>>>> $('#bodyContent').append( "<span>asdf</span>", "<span>qwerty</span>" ); 
>>>>>>> // in IE8 console only inserts the qwerty span the asdf span is not 
>>>>>>> inserted, works in FF Firebug console
>>>>>>>
>>>>>>> So this looks like an IE8 (maybe Konqueror) issue where when .domManip
>>>>>>> is used (by something like .append) with more than one argument with the
>>>>>>> first being a string a "Invalid argument" error is thrown if the first
>>>>>>> argument is not a valid node string. If the first argument is a valid
>>>>>>> node string, instead the first argument is ignored and the rest are
>>>>>>> inserted.
>>>>>>>
>>>>>>> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
>>>>>>>
>>>>>>> John Resig wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> You say that you still have problems if you split apart the query.
>>>>>>>>
>>>>>>>> So in this case $button.append( "[" ) fails - correct?
>>>>>>>>
>>>>>>>> What happens if you do:
>>>>>>>>
>>>>>>>> $button.append( document.createTextNode("[") )
>>>>>>>>
>>>>>>>> --John
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Jun 22, 2009 at 2:09 PM, Daniel
>>>>>>>> Friesen<nadir.seen.f...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> I've been having trouble with a bit of jQuery that works in FF, Opera,
>>>>>>>>> and Midori, but breaks in IE.
>>>>>>>>>
>>>>>>>>> See http://animanga.wikia.com/wiki/Sandbox?allinone=0
>>>>>>>>> The code: http://dev.wikia.com/wiki/ShowHide/code.js
>>>>>>>>> (it's on a wiki, so you can see the history of editing)
>>>>>>>>>
>>>>>>>>> Using IE8's debugger tools (yay, finally MS rips of Firebug to give 
>>>>>>>>> us a
>>>>>>>>> way to find out why IE is breaking /sarcasm) I've narrowed it down to
>>>>>>>>> $button.append( '[', $buttonLink, ']' ); Where jQuery's .append calls
>>>>>>>>> .clean which near the end calls fragment.appendChild( ret[i] ); 
>>>>>>>>> fragment
>>>>>>>>> is the document, and i is 0, ret is 3 items in length containing the
>>>>>>>>> text node, span, and other text node. jQuery tries to appendChild to 
>>>>>>>>> the
>>>>>>>>> document and IE decides it doesn't like it.
>>>>>>>>>
>>>>>>>>> Does this seem like a jQuery bug?
>>>>>>>>>
>>>>>>>>> Note: ya, I have tried splitting the append call into three separate
>>>>>>>>> ones, still causes the same issue on the first one.
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> ~Daniel Friesen (Dantman, Nadir-Seen-Fire) 
>>>>>>>>> [http://daniel.friesen.name]
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>
>> >
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-dev@googlegroups.com
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to