Opened 14 years ago
Closed 12 years ago
#4684 closed bug (patchwelcome)
Live events don't work in Opera when using XHTML and html()
Reported by: | alex_sh | Owned by: | brandon |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | event | Version: | 1.3.2 |
Keywords: | live event opera xhtml | Cc: | [email protected]… |
Blocked by: | Blocking: |
Description
Live events don't seem to work in Opera (tested with 9.64, Linux) when the new content is loaded via innerHTML (or jquery's html()), AND the document is XHTML (served via application/xml+xhtml, or opened locally with .xhtml extension).
Everything seems to work in Firefox 3.
I'm attaching two test cases (one xhtml, one html). A click event handler is attached via live() on the second button, while the first button replaces the second button with the dynamically created one. The click event is still executed in FF (both html and xhtml) and Opera with html version, but not in Opera with xhtml version.
Attachments (2)
Change History (12)
Changed 14 years ago by
Attachment: | jquery_opera_live_bug.xhtml added |
---|
comment:1 Changed 14 years ago by
This happens because opera (like IE) converts tagnames to uppercase when using innerHTML so the selector '#contents > input' no longer matches. You can test it by simply running $('#contents_div>input').is('#contents_div>input') and $('#contents_div>input').is('#contents_div>INPUT') on the testcase before and after 'loading new contents' with .html().
comment:2 Changed 14 years ago by
oh and btw, it works in the html version because tagnames in html are case-insensitive so the sizzle code converts every tagname to uppercase(only for XML documents). Try with.. $('#contents_div>input').length $('#contents_div>INPUT').length
comment:3 Changed 14 years ago by
Well, it doesn't pose a problem in IE because IE doesn't support XHTML.
Writing $('#contents_div>INPUT') fixes the problem in Opera, but breaks FF (and possibly Webkit).
So, I guess this problem can be dealt with in two ways:
- Make a workaround in jquery so that it produces the expected results in a cross-browser way. I think this is what it was mainly created for...
- Report a bug to Opera software and hope that they fix it.
Should I file a bug report to Opera's bug tracker?
comment:4 Changed 14 years ago by
I don't think this is a bug in opera because opera is just copying IE's behaviour for compatibility with IE-only sites. Perhaps the workaround mentioned on http://dev.fckeditor.net/ticket/1955#comment:2 by hallvord can be used in jQuery..
comment:5 Changed 14 years ago by
Copying IE's behaviour in XHTML mode doesn't make sense since IE doesn't have XHTML mode at all. Opera should import the elements as they are, not changing their case at all.
The workaround you mention applies to reading from innerHTML, not writing to it.
Just to be clear - the problem is apparent when using the following code:
div.innerHTML = '<input type="button" value="New button" />'; alert(div.firstChild.tagName); // shows uppercase in XHTML instead of lowercase as in the original
comment:6 Changed 14 years ago by
Ah yes, you are right. Opera shouldn't copy the behaviour in XHTML mode and this should get filed in Opera's bug tracker.
comment:7 Changed 14 years ago by
I filed a bug report to Opera's bug tracker. A portable solution is still needed until they fix it (if they fix it at all).
comment:9 Changed 12 years ago by
Cc: | [email protected]… added |
---|---|
Milestone: | 1.4 → 1.5 |
Priority: | major → low |
Status: | new → open |
Marking as valid and adding our Opera contact to the cc.
comment:10 Changed 12 years ago by
Resolution: | → patchwelcome |
---|---|
Status: | open → closed |
I will close this patchwelcome but most likely it will need to be fixed by Opera.
XHTML test case