Permalink
Browse files

Re-enable the pie_hover mouseover class in all IE versions for better…

… consistency, and let the setting of the className trigger a propertychange update rather than manually calling it a second time.
  • Loading branch information...
Jason Johnston
Jason Johnston committed Nov 8, 2010
1 parent 77fef47 commit 8dd6656d0fd3f9a13be7c6ec6ef0f4643cdcc32a
Showing with 14 additions and 13 deletions.
  1. +14 −10 sources/Element.js
  2. +0 −3 sources/PIE_open.js
View
@@ -3,6 +3,8 @@ PIE.Element = (function() {
var wrappers = {},
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 };
function Element( el ) {
@@ -190,27 +192,29 @@ PIE.Element = (function() {
}
+ function addHoverClass() {
+ el.className += hoverClass;
+ }
+
+ function removeHoverClass() {
+ el.className = el.className.replace( hoverClassRE, '' );
+ }
+
/**
* Handle mouseenter events. Adds a custom class to the element to allow IE6 to add
- * hover styles to non-link elements.
+ * hover styles to non-link elements, and to trigger a propertychange update.
*/
function mouseEntered() {
- if( PIE.ieVersion === 6 && el.tagName !== 'A' ) {
- el.className += ' ' + PIE.CLASS_PREFIX + 'hover';
- }
- //must delay this because the mouseleave event fires before the :hover styles are added.
- setTimeout( propChanged, 0 );
+ //must delay this because the mouseenter event fires before the :hover styles are added.
+ setTimeout( addHoverClass, 0 );
}
/**
* Handle mouseleave events
*/
function mouseLeft() {
- if( PIE.ieVersion === 6 && el.tagName !== 'A' ) {
- el.className = el.className.replace( PIE.hoverClassRE, '' );
- }
//must delay this because the mouseleave event fires before the :hover styles are removed.
- setTimeout( propChanged, 0 );
+ setTimeout( removeHoverClass, 0 );
}
View
@@ -35,9 +35,6 @@ if( !PIE ) {
if( PIE.ieVersion === 6 ) {
// IE6 can't access properties with leading dash, but can without it.
PIE.CSS_PREFIX = PIE.CSS_PREFIX.replace( /^-/, '' );
-
- // Regex object for removing pie_hover className
- PIE.hoverClassRE = new RegExp( '\\b' + PIE.CLASS_PREFIX + 'hover\\b', 'g' );
}
// Detect IE8

0 comments on commit 8dd6656

Please sign in to comment.