Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix error when toggling style.display on the target element; ignores …

…the onpropertychange event since size calculation is not accurate during that event and it triggers an onresize event anyway; also work around a weird error thrown when removing the length-calc element from what should be its parent but sometimes isn't.
  • Loading branch information...
commit 8949c0cab3a9c8ba3d2ef7dac1ceafee2765db24 1 parent 8a6f3ac
Jason Johnston authored
Showing with 7 additions and 3 deletions.
  1. +4 −2 sources/Element.js
  2. +3 −1 sources/Length.js
View
6 sources/Element.js
@@ -5,7 +5,7 @@ PIE.Element = (function() {
lazyInitCssProp = PIE.CSS_PREFIX + 'lazy-init',
hoverClass = ' ' + PIE.CLASS_PREFIX + 'hover',
hoverClassRE = new RegExp( '\\b' + PIE.CLASS_PREFIX + 'hover\\b', 'g' ),
- ignorePropertyNames = { 'background':1, 'bgColor':1 };
+ ignorePropertyNames = { 'background':1, 'bgColor':1, 'display': 1 };
function addListener( el, type, handler ) {
@@ -181,7 +181,9 @@ PIE.Element = (function() {
// Some elements like <table> fire onpropertychange events for old-school background properties
// ('background', 'bgColor') when runtimeStyle background properties are changed, which
- // results in an infinite loop; therefore we filter out those property names.
+ // results in an infinite loop; therefore we filter out those property names. Also, 'display'
+ // is ignored because size calculations don't work correctly immediately when its onpropertychange
+ // event fires, and because it will trigger an onresize event anyway.
if( !destroyed && !( e && e.propertyName in ignorePropertyNames ) ) {
if( initialized ) {
lockAll();
View
4 sources/Length.js
@@ -101,7 +101,9 @@ PIE.Length = (function() {
lengthCalcEl.style.width = '1em';
el.appendChild( lengthCalcEl );
px = lengthCalcEl.offsetWidth;
- el.removeChild( lengthCalcEl );
+ if( lengthCalcEl.parentNode !== el ) { //not sure how this happens but it does
+ el.removeChild( lengthCalcEl );
+ }
return px;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.