Bug Tracker

Ticket #12863 (closed bug: fixed)

Opened 2 years ago

Last modified 23 months ago

behavior:url(#default#savehistory) causes event error on oldIE

Reported by: dwilks Owned by: dmethvin
Priority: high Milestone: 1.9
Component: manipulation Version: 1.8.2
Keywords: Cc:
Blocking: Blocked by:

Description

In IE8

Result: Object doesn't support this property or method.

The key conditions:

  • body must have a change event
  • the dynamically appended element must have an associated style with a behavior:url(#default#savehistory)

Full description at  http://pdfcast.org/pdf/jquery-calendar-problem

(This is a re-post of the incorrectly closed #12178)

Change History

comment:1 Changed 2 years ago by dmethvin

  • Priority changed from undecided to high
  • Status changed from new to open
  • Component changed from unfiled to manipulation
  • Milestone changed from None to 1.9

Still in -git:

 https://github.com/jquery/jquery/blob/0ee94159023bebe1992c5281d0f4778b4f75ff0d/src/manipulation.js#L843

Seems that when a behavior is attached to an element, typeof elem.removeAttribute === "unknown" and the mere act of asking if the property exists causes it to call the method (incorrectly), similar to the problems that Sizzle works around here:

 https://github.com/jquery/sizzle/blob/5e6ae330a9ccb33fd343a0bdc73ed2b821767f9c/sizzle.js#L599

We'll need a trickier test like !/undefined|unknown/.test( typeof elem.removeAttribute ) perhaps.

comment:2 Changed 2 years ago by timmywil

@dmethvin: I don't think the Sizzle code is related. ;P

comment:3 Changed 2 years ago by dmethvin

@timmywil, I think it's the same basic problem, a simple falsy-check for elem.getAttribute was calling it and here it seems to be elem.removeAttribute instead.

comment:4 Changed 2 years ago by timmywil

@dmethvin: The falsey check is on the return value of getAttribute("class") rather than on the getAttribute method itself. Wouldn't the code just fail if it tried to call a function that IE reports to be type "unknown"? I imagine that Sizzle still doesn't handle that issue.

I think you're thinking of the falsey check we used to use: if ( elem.getAttribute ) { ... } Unfortunately, IE calls the method in XML (and some other edge cases) even without parens. There wasn't a performance loss in using typeof, which never accidentally calls the method, so we switched to that. Your solution of a regex on typeof would work, but I'm not sure we want to add something like that.

I'm inclined to say this is not high priority. The behavior property is proprietary IE and can most likely cause more problems than this.

comment:5 Changed 2 years ago by gibson042

For the curious, it's on the order of +15 bytes gzipped.

comment:6 Changed 2 years ago by dmethvin

  • Owner set to dmethvin
  • Status changed from open to assigned

comment:7 Changed 23 months ago by dmethvin

  • Summary changed from IE8 - Object doesn't support this property or method to behavior:url(#default#savehistory) causes event error on oldIE

comment:8 Changed 23 months ago by dmethvin

This did seem to be the same problem where .removeAttribute() is being called, I changed to use a typeof and the test case no longer fails. Unfortunately the setup is really complicated and involves the flakey focus events which are async in IE so I am having trouble creating a reliable unit test.

comment:9 Changed 23 months ago by Dave Methvin

  • Status changed from assigned to closed
  • Resolution set to fixed

Fix #12863. Prevent oldIE from calling .removeAttribute

Changeset: 4e0bc169df0f6dee45fe7c19925216453b431ebb

Note: See TracTickets for help on using tickets.