@material/auto-init
Advanced tools
Comparing version 0.1.4 to 0.2.0
@@ -117,2 +117,19 @@ /*! | ||
function _emit(evtType, evtData) { | ||
var shouldBubble = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
var evt = void 0; | ||
if (typeof CustomEvent === 'function') { | ||
evt = new CustomEvent(evtType, { | ||
detail: evtData, | ||
bubbles: shouldBubble | ||
}); | ||
} else { | ||
evt = document.createEvent('CustomEvent'); | ||
evt.initCustomEvent(evtType, shouldBubble, false, evtData); | ||
} | ||
document.dispatchEvent(evt); | ||
} | ||
/** | ||
@@ -151,2 +168,4 @@ * Auto-initializes all mdc components on a page. | ||
} | ||
_emit('MDCAutoInit:End', {}); | ||
} | ||
@@ -153,0 +172,0 @@ |
@@ -6,2 +6,2 @@ /*! | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.autoInit=e():(t.mdc=t.mdc||{},t.mdc.autoInit=e())}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/assets/",e(e.s=24)}({24:function(t,e,n){t.exports=n(25)},25:function(t,e,n){"use strict";function o(){for(var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i,o=e.querySelectorAll("[data-mdc-auto-init]"),u=0;t=o[u];u++){var c=t.dataset.mdcAutoInit;if(!c)throw new Error("(mdc-auto-init) Constructor name must be given.");var a=r[c];if("function"!=typeof a)throw new Error("(mdc-auto-init) Could not find constructor in registry for "+c);if(t[c])n("(mdc-auto-init) Component already initialized for "+t+". Skipping...");else{var f=a.attachTo(t);Object.defineProperty(t,c,{value:f,writable:!1,enumerable:!1,configurable:!0})}}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var r=Object.create(null),i=console.warn.bind(console);o.register=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i;if("function"!=typeof e)throw new Error("(mdc-auto-init) Invalid Ctor value "+e+". Expected function");r[t]&&n("(mdc-auto-init) Overriding registration for "+t+" with "+e+". Was: "+r[t]),r[t]=e},o.deregister=function(t){delete r[t]},o.deregisterAll=function(){Object.keys(r).forEach(this.deregister,this)}}})}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.autoInit=e():(t.mdc=t.mdc||{},t.mdc.autoInit=e())}(this,function(){return function(t){function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/assets/",e(e.s=24)}({24:function(t,e,n){t.exports=n(25)},25:function(t,e,n){"use strict";function o(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=void 0;"function"==typeof CustomEvent?o=new CustomEvent(t,{detail:e,bubbles:n}):(o=document.createEvent("CustomEvent"),o.initCustomEvent(t,n,!1,e)),document.dispatchEvent(o)}function r(){for(var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u,r=e.querySelectorAll("[data-mdc-auto-init]"),c=0;t=r[c];c++){var a=t.dataset.mdcAutoInit;if(!a)throw new Error("(mdc-auto-init) Constructor name must be given.");var d=i[a];if("function"!=typeof d)throw new Error("(mdc-auto-init) Could not find constructor in registry for "+a);if(t[a])n("(mdc-auto-init) Component already initialized for "+t+". Skipping...");else{var f=d.attachTo(t);Object.defineProperty(t,a,{value:f,writable:!1,enumerable:!1,configurable:!0})}}o("MDCAutoInit:End",{})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var i=Object.create(null),u=console.warn.bind(console);r.register=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:u;if("function"!=typeof e)throw new Error("(mdc-auto-init) Invalid Ctor value "+e+". Expected function");i[t]&&n("(mdc-auto-init) Overriding registration for "+t+" with "+e+". Was: "+i[t]),i[t]=e},r.deregister=function(t){delete i[t]},r.deregisterAll=function(){Object.keys(i).forEach(this.deregister,this)}}})}); |
17
index.js
@@ -21,2 +21,17 @@ /** | ||
function _emit(evtType, evtData, shouldBubble = false) { | ||
let evt; | ||
if (typeof CustomEvent === 'function') { | ||
evt = new CustomEvent(evtType, { | ||
detail: evtData, | ||
bubbles: shouldBubble, | ||
}); | ||
} else { | ||
evt = document.createEvent('CustomEvent'); | ||
evt.initCustomEvent(evtType, shouldBubble, false, evtData); | ||
} | ||
document.dispatchEvent(evt); | ||
} | ||
/** | ||
@@ -53,2 +68,4 @@ * Auto-initializes all mdc components on a page. | ||
} | ||
_emit('MDCAutoInit:End', {}); | ||
} | ||
@@ -55,0 +72,0 @@ |
{ | ||
"name": "@material/auto-init", | ||
"description": "Declarative, easy-to-use auto-initialization for Material Components for the web", | ||
"version": "0.1.4", | ||
"version": "0.2.0", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "license": "Apache-2.0", |
@@ -163,1 +163,8 @@ <!--docs: | ||
This will suppress any warnings about already initialized elements. | ||
### Events | ||
#### MDCAutoInit:End | ||
Triggered when initialization of all components is complete. | ||
`document.addEventListener("MDCAutoInit:End", () => {...});` |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
18132
252
170