dom-elements
Version:
Polyfill for Elements class and query/queryAll additions to the DOM standard.
1 lines • 3.7 kB
JavaScript
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.domElements=e()}}(function(){return function e(t,r,n){function o(i,l){if(!r[i]){if(!t[i]){var s="function"==typeof require&&require;if(!l&&s)return s(i,!0);if(u)return u(i,!0);throw new Error("Cannot find module '"+i+"'")}var p=r[i]={exports:{}};t[i][0].call(p.exports,function(e){var r=t[i][1][e];return o(r?r:e)},p,p.exports,e,t,r,n)}return r[i].exports}for(var u="function"==typeof require&&require,i=0;i<n.length;i++)o(n[i]);return o}({1:[function(e,t){function r(){}t.exports=r;var n=e("../utils/pushuniq"),o=r.prototype=[],u=e("../methods");o.queryAll=function(e){var t=n();return this.reduce(function(r,n){return t(u.queryAll.call(n,e))},null)},o.query=function(e){return o.queryAll.call(this,e)[0]||null}},{"../methods":5,"../utils/pushuniq":11}],2:[function(e){var t=e("./methods"),r=e("./utils/is-native"),n=[];if(!("undefined"!=typeof Document&&"map"in n&&"reduce"in n&&"querySelectorAll"in document))throw new TypeError("Missing browser features to initiantiate dom-elements");"Element"in window&&(r(Element.prototype,"query")||(Element.prototype.query=t.query),r(Element.prototype,"queryAll")||(Element.prototype.queryAll=t.queryAll)),["Document","DocumentFragment"].forEach(function(e){var n;e in window&&(n=window[e].prototype,r(n,"query")||(n.query=t.queryWrapper),r(n,"queryAll")||(n.queryAll=t.queryAllWrapper))})},{"./methods":5,"./utils/is-native":10}],3:[function(e,t){var r=e("./attribute-name");t.exports=function(e){return function(t){return"["+r+'="'+e+'"] '+t}}},{"./attribute-name":4}],4:[function(e,t){t.exports="data-dom-elements-id-"+e("../utils/expando")},{"../utils/expando":9}],5:[function(e,t){var r=e("../scope"),n=e("../scope/support"),o=t.exports={},u=e("../elements"),i=e("../utils/to-array"),l=e("./attribute-name"),s=e("./scope-selector"),p=e("./absolutize-selector"),c=-1;o.query=function(e){return o.queryAll.call(this,e)[0]||null},o.queryAll=function(e){var t,o,a,f=this;return n||f.setAttribute(l,++c),o=n?r(e,s):r(e,p(c)),t=f.querySelectorAll(o),n||f.removeAttribute(l),a=new u,a.push.apply(a,i(t)),a},o.queryAllWrapper=function(e){var t=this.querySelectorAll(e),r=new u;return r.push.apply(r,i(t)),r},o.queryWrapper=function(e){return this.querySelector(e)}},{"../elements":1,"../scope":7,"../scope/support":8,"../utils/to-array":13,"./absolutize-selector":3,"./attribute-name":4,"./scope-selector":6}],6:[function(e,t){t.exports=function(e){return":scoped "+e}},{}],7:[function(e,t){var r=e("../utils/separate-selector");t.exports=function(e,t){var n=r(e),o=n.map(t);return o.join()}},{"../utils/separate-selector":12}],8:[function(e,t){try{document.createElement("i").querySelector(":scoped *"),t.exports=!0}catch(r){t.exports=!1}},{}],9:[function(e,t){t.exports=String(Math.random()).replace(/\D/g,"")},{}],10:[function(e,t){var r=Function.prototype.toString,n=r.call(document.querySelector),o=/\bquerySelector\b/g;t.exports=function(e,t){return e[t]?r.call(e[t])===n.replace(o,t):!1}},{}],11:[function(e,t){var r=e("../elements"),n=e("./expando"),o="domElementsId"+n,u=-1;t.exports=function(e){function t(e){for(var t,r=-1,l=e.length;++r<l;)t=e[r],t&&1===t.nodeType&&(o in t&&i.hasOwnProperty(t[o])||(t[o]=++u,i[u]=1,n.push(t)));return n}var n=new r,i={};return arguments.length&&t(e),t}},{"../elements":1,"./expando":9}],12:[function(e,t){t.exports=function(e){return e.split(/\s*,\s*/)}},{}],13:[function(e,t){t.exports=function(e){for(var t=-1,r=e.length,n=Array(r);++t<r;)n[t]=e[t];return n}},{}]},{},[2])(2)});