Bug Tracker

Modify

Ticket #4684 (closed bug: patchwelcome)

Opened 4 years ago

Last modified 2 years ago

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

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

jquery_opera_live_bug.xhtml Download (1.5 KB) - added by alex_sh 4 years ago.
XHTML test case
jquery_opera_live_bug.html Download (1.4 KB) - added by alex_sh 4 years ago.
HTML test case

Change History

Changed 4 years ago by alex_sh

XHTML test case

Changed 4 years ago by alex_sh

HTML test case

comment:1 Changed 4 years ago by temp01

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 4 years ago by temp01

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 4 years ago by alex_sh

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:

  1. 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...
  2. 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 4 years ago by temp01

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 4 years ago by alex_sh

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 4 years ago by temp01

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 4 years ago by alex_sh

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:8 Changed 3 years ago by dmethvin

Bug is still present in Opera 10.60 AFAICT by the test case.

comment:9 Changed 3 years ago by SlexAxton

  • Cc miketaylr@… added
  • Priority changed from major to low
  • Status changed from new to open
  • Milestone changed from 1.4 to 1.5

Marking as valid and adding our Opera contact to the cc.

comment:10 Changed 2 years ago by dmethvin

  • Status changed from open to closed
  • Resolution set to patchwelcome

I will close this patchwelcome but most likely it will need to be fixed by Opera.

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.