vendor/assets/javascripts/webshims/shims/dom-extend.js in webshims-rails-0.4.6 vs vendor/assets/javascripts/webshims/shims/dom-extend.js in webshims-rails-0.4.7
- old
+ new
@@ -14,10 +14,15 @@
var oldVal = $.fn.val;
var singleVal = function(elem, name, val, pass, _argless){
return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
};
+
+ $.fn.onTrigger = function(evt, fn){
+ return this.on(evt, fn).each(fn);
+ };
+
$.fn.val = function(val){
var elem = this[0];
if(arguments.length && val == null){
val = '';
}
@@ -208,18 +213,18 @@
};
});
//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 = (!$.browser.msie || parseInt($.browser.version, 10) > 8);
+ var isExtendNativeSave = Modernizr.ES5;
var extendNativeValue = (function(){
var UNKNOWN = webshims.getPrototypeOf(document.createElement('foobar'));
var has = Object.prototype.hasOwnProperty;
return function(nodeName, prop, desc){
- var elem = document.createElement(nodeName);
- var elemProto = webshims.getPrototypeOf(elem);
- if( isExtendNativeSave && elemProto && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
+ var elem;
+ var elemProto;
+ if( isExtendNativeSave && (elem = document.createElement(nodeName)) && (elemProto = webshims.getPrototypeOf(elem)) && UNKNOWN !== elemProto && ( !elem[prop] || !has.call(elem, prop) ) ){
var sup = elem[prop];
desc._supvalue = function(){
if(sup && sup.apply){
return sup.apply(this, arguments);
}
@@ -415,11 +420,11 @@
docObserve.height = docObserve.getHeight();
docObserve.width = docObserve.getWidth();
}
- $.event.trigger('updateshadowdom');
+ $(document).triggerHandler('updateshadowdom');
}, (e.type == 'resize') ? 50 : 9);
},
_create: function(){
$.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){
var body = document.body;
@@ -459,11 +464,10 @@
}
}
};
- $.event.customEvent.updateshadowdom = true;
webshims.docObserve = function(){
webshims.ready('DOM', function(){
docObserve.start();
});
};
@@ -903,47 +907,47 @@
webshims.isReady('webshimLocalization', true);
});
//html5a11y
(function($, document){
- var browserVersion = $.webshims.browserVersion;
- if($.browser.mozilla && browserVersion > 5){return;}
- if (!$.browser.msie || (browserVersion < 12 && browserVersion > 7)) {
- var elemMappings = {
- article: "article",
- aside: "complementary",
- section: "region",
- nav: "navigation",
- address: "contentinfo"
- };
- var addRole = function(elem, role){
- var hasRole = elem.getAttribute('role');
- if (!hasRole) {
- elem.setAttribute('role', role);
+ //if we support basic styleing or do not support ARIA (assumed) abort
+ if(!Modernizr.localstorage || ('hidden' in document.createElement('a'))){return;}
+
+ var elemMappings = {
+ article: "article",
+ aside: "complementary",
+ section: "region",
+ nav: "navigation",
+ address: "contentinfo"
+ };
+ var addRole = function(elem, role){
+ var hasRole = elem.getAttribute('role');
+ if (!hasRole) {
+ elem.setAttribute('role', role);
+ }
+ };
+
+ $.webshims.addReady(function(context, contextElem){
+ $.each(elemMappings, function(name, role){
+ var elems = $(name, context).add(contextElem.filter(name));
+ for (var i = 0, len = elems.length; i < len; i++) {
+ addRole(elems[i], role);
}
- };
-
- $.webshims.addReady(function(context, contextElem){
- $.each(elemMappings, function(name, role){
- var elems = $(name, context).add(contextElem.filter(name));
- for (var i = 0, len = elems.length; i < len; i++) {
- addRole(elems[i], role);
- }
- });
- if (context === document) {
- var header = document.getElementsByTagName('header')[0];
- var footers = document.getElementsByTagName('footer');
- var footerLen = footers.length;
- if (header && !$(header).closest('section, article')[0]) {
- addRole(header, 'banner');
- }
- if (!footerLen) {
- return;
- }
- var footer = footers[footerLen - 1];
- if (!$(footer).closest('section, article')[0]) {
- addRole(footer, 'contentinfo');
- }
- }
});
- }
+ if (context === document) {
+ var header = document.getElementsByTagName('header')[0];
+ var footers = document.getElementsByTagName('footer');
+ var footerLen = footers.length;
+ if (header && !$(header).closest('section, article')[0]) {
+ addRole(header, 'banner');
+ }
+ if (!footerLen) {
+ return;
+ }
+ var footer = footers[footerLen - 1];
+ if (!$(footer).closest('section, article')[0]) {
+ addRole(footer, 'contentinfo');
+ }
+ }
+ });
+
})(jQuery, document);