vendor/assets/javascripts/webshims/shims/combos/31.js in webshims-rails-1.11.2 vs vendor/assets/javascripts/webshims/shims/combos/31.js in webshims-rails-1.11.3
- old
+ new
@@ -1,10 +1,11 @@
//DOM-Extension helper
webshims.register('dom-extend', function($, webshims, window, document, undefined){
"use strict";
var supportHrefNormalized = !('hrefNormalized' in $.support) || $.support.hrefNormalized;
var supportGetSetAttribute = !('getSetAttribute' in $.support) || $.support.getSetAttribute;
+ var has = Object.prototype.hasOwnProperty;
webshims.assumeARIA = supportGetSetAttribute || Modernizr.canvas || Modernizr.video || Modernizr.boxsizing;
if($('<input type="email" />').attr('type') == 'text' || $('<form />').attr('novalidate') === "" || ('required' in $('<input />')[0].attributes)){
webshims.error("IE browser modes are busted in IE10+. Please test your HTML/CSS/JS with a real IE version or at least IETester or similiar tools");
}
@@ -73,10 +74,11 @@
var listReg = /\s*,\s*/;
//proxying attribute
var olds = {};
var havePolyfill = {};
+ var hasPolyfillMethod = {};
var extendedProps = {};
var extendQ = {};
var modifyProps = {};
var oldVal = $.fn.val;
@@ -178,10 +180,43 @@
});
return this.pushStack(elems);
};
});
+ //add support for $('video').trigger('play') in case extendNative is set to false
+ if(!webshims.cfg.extendNative && !webshims.cfg.noTriggerOverride){
+ (function(oldTrigger){
+ $.event.trigger = function(event, data, elem, onlyHandlers){
+
+ if(!hasPolyfillMethod[event] || onlyHandlers || !elem || elem.nodeType !== 1){
+ return oldTrigger.apply(this, arguments);
+ }
+ var ret, isOrig, origName;
+ var origFn = elem[event];
+ var polyfilledFn = $.prop(elem, event);
+ var changeFn = polyfilledFn && origFn != polyfilledFn;
+ if(changeFn){
+ origName = '__ws'+event;
+ isOrig = (event in elem) && has.call(elem, event);
+ elem[event] = polyfilledFn;
+ elem[origName] = origFn;
+ }
+
+ ret = oldTrigger.apply(this, arguments);
+ if (changeFn) {
+ if(isOrig){
+ elem[event] = origFn;
+ } else {
+ delete elem[event];
+ }
+ delete elem[origName];
+ }
+
+ return ret;
+ };
+ })($.event.trigger);
+ }
['removeAttr', 'prop', 'attr'].forEach(function(type){
olds[type] = $[type];
$[type] = function(elem, name, value, pass, _argless){
var isVal = (pass == 'val');
@@ -262,10 +297,11 @@
if(!extendedProps[nodeName][prop]){
extendedProps[nodeName][prop] = {};
}
var oldDesc = extendedProps[nodeName][prop][type];
var getSup = function(propType, descriptor, oDesc){
+ var origProp;
if(descriptor && descriptor[propType]){
return descriptor[propType];
}
if(oDesc && oDesc[propType]){
return oDesc[propType];
@@ -278,12 +314,14 @@
olds[type](elem, prop, value)
;
};
}
if(type == 'prop' && propType == 'value' && desc.value.apply){
+ origProp = '__ws'+prop;
+ hasPolyfillMethod[prop] = true;
return function(value){
- var sup = olds[type](this, prop);
+ var sup = this[origProp] || olds[type](this, prop);
if(sup && sup.apply){
sup = sup.apply(this, arguments);
}
return sup;
};
@@ -317,11 +355,11 @@
});
var extendNativeValue = (function(){
var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
- var has = Object.prototype.hasOwnProperty;
+
//see also: https://github.com/lojjic/PIE/issues/40 | https://prototype.lighthouseapp.com/projects/8886/tickets/1107-ie8-fatal-crash-when-prototypejs-is-loaded-with-rounded-cornershtc
var isExtendNativeSave = Modernizr.advancedObjectProperties && Modernizr.objectAccessor;
return function(nodeName, prop, desc){
var elem , elemProto;
if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
@@ -1145,20 +1183,24 @@
$(document).off('.lazyloadvalidation');
};
/*
* Selectors for all browsers
*/
+ var rElementsGroup = /^(?:form|fieldset)$/i;
var hasInvalid = function(elem){
var ret = false;
$(elem).jProp('elements').each(function(){
- ret = $(this).is(':invalid');
- if(ret){
- return false;
+ if(!rElementsGroup.test(elem.nodeName || '')){
+ ret = $(this).is(':invalid');
+ if(ret){
+ return false;
+ }
}
+
});
return ret;
};
- var rElementsGroup = /^(?:form)$/i;///^(?:form|fieldset)$/i
+
$.extend($.expr[":"], {
"valid-element": function(elem){
return rElementsGroup.test(elem.nodeName || '') ? !hasInvalid(elem) :!!($.prop(elem, 'willValidate') && isValid(elem));
},
"invalid-element": function(elem){
\ No newline at end of file