Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for issue 149 #203

Open
wants to merge 1 commit into from

3 participants

gruber76 Jason Johnston Balasubramanian
gruber76

currentStyle is Async in IE, and/or may be null if an element is created using createElement. Either way, PIE needs to make sure currentStyle is present before accessing its methods.

(see http://stackoverflow.com/questions/3722736/weird-ie-behavior-currentstyle-returns-null)

gruber76 gruber76 Fix for issue 149
currentStyle is Async in IE, and/or may be null if an element is created using createElement.  Either way, PIE needs to make sure currentStyle is present before accessing its methods.

(see http://stackoverflow.com/questions/3722736/weird-ie-behavior-currentstyle-returns-null)
91e9117
Jason Johnston
Owner

Thanks for the patch. I'm not sure this would work though -- currentStyle.getAttribute is a function so I'd expect it to throw a "getAttribute is not a function" error if it's set to a plain object.

Do you have a testcase you've been able to test this fix against? That's been the only issue keeping me from fixing this myself, I don't have a way to reproduce the issue so I don't know if a fix works or not.

gruber76

Yeah, that was a hack of a patch, I realized about ten seconds after I hit "request." Sorry. I'll get a test for you tomorrow, as I have it breaking 100% on a pie.js loop.

Jason Johnston
Owner

Awesome, thanks. :)

Since we're discussing it I do have some additional thoughts about this issue...

1) Since PIE really can't do much of anything without currentStyle being present, I'd prefer to short-circuit as soon as possible (and only once), for instance perhaps in Element#update().

2) If we're preventing PIE from completing an update, then we need to make sure that we don't leave it hanging like that and have elements remain unstyled. If the process of IE's async currentStyle initialization doesn't itself trigger PIE to re-update once currentStyle becomes available, then we need to queue something up to try again after a delay.

Jason Johnston
Owner

@gruber76 Any word on that testcase? I'd like to get a proper fix in asap.

Jason Johnston
Owner

FYI here's my potential fix -- https://github.com/lojjic/PIE/tree/currentStyle-check

This checks for the presence of currentStyle at the start of each update, and if it's not present then it exits right away and sets up a timer to attempt the update again after a delay.

This is, of course, untested since I don't yet have a testcase. ;)

gruber76

Ugh, sorry I got this error in an Angular project... it may be that the script is trying to run .attach before the element is actually IN the DOM, but after spending longer trying to pare it down than I really had time for I had to get back to paid work. Here's a snippet that creates the PIE error in IE9:
https://gist.github.com/2202107

Jason Johnston
Owner

See my comment on your gist, there seems to be an error in the gist code and fixing that allows IE9 to render without error.

Unfortunately without a testcase I'll have to close this one as not reproducible. :/

Balasubramanian

You can reproduce this by setting -pie-poll to true for an element and remove the element frmo the DOM tree by calling innerHTML = "" in the parent or.

add another class to the element, using .className += " newClass" and the new class has a different background color

#210

Jason Johnston
Owner

@balu980 I tried to create a testcase that does the steps you described, but was unable to trigger an error.

Are you able to create a testcase, or point me to a URL that triggers it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 19, 2012
  1. gruber76

    Fix for issue 149

    gruber76 authored
    currentStyle is Async in IE, and/or may be null if an element is created using createElement.  Either way, PIE needs to make sure currentStyle is present before accessing its methods.
    
    (see http://stackoverflow.com/questions/3722736/weird-ie-behavior-currentstyle-returns-null)
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  sources/StyleInfoBase.js
2  sources/StyleInfoBase.js
View
@@ -51,7 +51,7 @@ PIE.StyleInfoBase = {
var el = this.targetElement,
ctor = this.constructor,
s = el.style,
- cs = el.currentStyle,
+ cs = el.currentStyle || {getAttribute:{}},
cssProp = this.cssProperty,
styleProp = this.styleProperty,
prefixedCssProp = ctor._prefixedCssProp || ( ctor._prefixedCssProp = PIE.CSS_PREFIX + cssProp ),
Something went wrong with that request. Please try again.