Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add detection for functioning VML support -- some small number of IE …

…installs don't have a working VML engine, so for those cases we short-circuit initialization so the users see the CSS3-less fallbacks instead of having styling removed and JS errors.
  • Loading branch information...
commit 7f3900a61593123eaa6bcc2aeac67e236a848a58 1 parent 5564212
Jason Johnston authored
Showing with 35 additions and 19 deletions.
  1. +12 −1 sources/PIE_API.js
  2. +23 −18 sources/PIE_open.js
View
13 sources/PIE_API.js
@@ -4,11 +4,22 @@
/**
+ * @property supportsVML
+ * True if the current IE browser environment has a functioning VML engine. Should be true
+ * in most IEs, but in rare cases may be false. If false, PIE will exit immediately when
+ * attached to an element; this property may be used for debugging or by external scripts
+ * to perform some special action when VML support is absent.
+ * @type {boolean}
+ */
+PIE[ 'supportsVML' ] = PIE.supportsVML;
+
+
+/**
* Programatically attach PIE to a single element.
* @param {Element} el
*/
PIE[ 'attach' ] = function( el ) {
- if (PIE.ieVersion < 9) {
+ if (PIE.ieVersion < 9 && PIE.supportsVML) {
PIE.Element.getInstance( el ).init();
}
};
View
41 sources/PIE_open.js
@@ -16,28 +16,33 @@ if( !PIE ) {
doc.execCommand( 'BackgroundImageCache', false, true );
} catch(e) {}
- /*
- * IE version detection approach by James Padolsey, with modifications -- from
- * http://james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/
- */
- PIE.ieVersion = function(){
- var v = 4,
+ (function() {
+ /*
+ * IE version detection approach by James Padolsey, with modifications -- from
+ * http://james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/
+ */
+ var ieVersion = 4,
div = doc.createElement('div'),
- all = div.getElementsByTagName('i');
-
+ all = div.getElementsByTagName('i'),
+ shape;
while (
- div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
+ div.innerHTML = '<!--[if gt IE ' + (++ieVersion) + ']><i></i><![endif]-->',
all[0]
) {}
+ PIE.ieVersion = ieVersion;
- return v;
- }();
+ // Detect IE6
+ if( ieVersion === 6 ) {
+ // IE6 can't access properties with leading dash, but can without it.
+ PIE.CSS_PREFIX = PIE.CSS_PREFIX.replace( /^-/, '' );
+ }
- // Detect IE6
- if( PIE.ieVersion === 6 ) {
- // IE6 can't access properties with leading dash, but can without it.
- PIE.CSS_PREFIX = PIE.CSS_PREFIX.replace( /^-/, '' );
- }
+ // Detect IE8
+ PIE.ie8DocMode = ieVersion === 8 && doc.documentMode;
- // Detect IE8
- PIE.ie8DocMode = PIE.ieVersion === 8 && doc.documentMode;
+ // Detect VML support (a small number of IE installs don't have a working VML engine)
+ div.innerHTML = '<v:shape adj="1"/>';
+ shape = div.firstChild;
+ shape.style['behavior'] = 'url(#default#VML)';
+ PIE.supportsVML = (typeof shape['adj'] === "object");
+ }());
Please sign in to comment.
Something went wrong with that request. Please try again.