Permalink
Browse files

Merge branch 'vml-detect'

Conflicts:
	sources/PIE_API.js
	sources/PIE_open.js
  • Loading branch information...
2 parents da3012b + 7f3900a commit d81c6f737b4c2e320389311c58e7243d30ee253e Jason Johnston committed Apr 10, 2011
Showing with 34 additions and 19 deletions.
  1. +12 −1 sources/PIE_API.js
  2. +22 −18 sources/PIE_open.js
View
@@ -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.ieDocMode < 9) {
+ if (PIE.ieDocMode < 9 && PIE.supportsVML) {
PIE.Element.getInstance( el ).init();
}
};
View
@@ -16,28 +16,32 @@ 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( /^-/, '' );
- }
+ PIE.ieDocMode = doc.documentMode || PIE.ieVersion;
- // Detect IE8
- PIE.ieDocMode = doc.documentMode || PIE.ieVersion;
+ // 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");
+ }());

0 comments on commit d81c6f7

Please sign in to comment.