From 7b9d94b142fb8a5214595fb9ef99a7c00b021676 Mon Sep 17 00:00:00 2001 From: Joe Pea Date: Mon, 6 Nov 2023 20:49:30 -0800 Subject: [PATCH] update lume cli version, update typescript version --- dist/CustomAttributeRegistry.js | 63 +++++++++++++++-------------- dist/CustomAttributeRegistry.js.map | 2 +- package.json | 4 +- tsconfig.json | 4 +- 4 files changed, 36 insertions(+), 37 deletions(-) diff --git a/dist/CustomAttributeRegistry.js b/dist/CustomAttributeRegistry.js index d21b0fb..d5a154d 100644 --- a/dist/CustomAttributeRegistry.js +++ b/dist/CustomAttributeRegistry.js @@ -1,38 +1,23 @@ const forEach = Array.prototype.forEach; export class CustomAttributeRegistry { + ownerDocument; + _attrMap = new Map(); + _elementMap = new WeakMap(); + _observer = new MutationObserver(mutations => { + forEach.call(mutations, (m) => { + if (m.type === 'attributes') { + const attr = this._getConstructor(m.attributeName); + if (attr) + this._handleChange(m.attributeName, m.target, m.oldValue); + } + else { + forEach.call(m.removedNodes, this._elementDisconnected); + forEach.call(m.addedNodes, this._elementConnected); + } + }); + }); constructor(ownerDocument) { this.ownerDocument = ownerDocument; - this._attrMap = new Map(); - this._elementMap = new WeakMap(); - this._observer = new MutationObserver(mutations => { - forEach.call(mutations, (m) => { - if (m.type === 'attributes') { - const attr = this._getConstructor(m.attributeName); - if (attr) - this._handleChange(m.attributeName, m.target, m.oldValue); - } - else { - forEach.call(m.removedNodes, this._elementDisconnected); - forEach.call(m.addedNodes, this._elementConnected); - } - }); - }); - this._elementConnected = (element) => { - if (element.nodeType !== 1) - return; - forEach.call(element.attributes, (attr) => { - if (this._getConstructor(attr.name)) - this._handleChange(attr.name, element, null); - }); - this._attrMap.forEach((_constructor, attr) => this._upgradeAttr(attr, element)); - }; - this._elementDisconnected = (element) => { - const map = this._elementMap.get(element); - if (!map) - return; - map.forEach(inst => inst.disconnectedCallback?.(), this); - this._elementMap.delete(element); - }; if (!ownerDocument) throw new Error('Must be given a document'); } @@ -70,6 +55,22 @@ export class CustomAttributeRegistry { const matches = node.querySelectorAll('[' + attrName + ']'); forEach.call(matches, (element) => this._handleChange(attrName, element, null)); } + _elementConnected = (element) => { + if (element.nodeType !== 1) + return; + forEach.call(element.attributes, (attr) => { + if (this._getConstructor(attr.name)) + this._handleChange(attr.name, element, null); + }); + this._attrMap.forEach((_constructor, attr) => this._upgradeAttr(attr, element)); + }; + _elementDisconnected = (element) => { + const map = this._elementMap.get(element); + if (!map) + return; + map.forEach(inst => inst.disconnectedCallback?.(), this); + this._elementMap.delete(element); + }; _handleChange(attrName, el, oldVal) { let map = this._elementMap.get(el); if (!map) diff --git a/dist/CustomAttributeRegistry.js.map b/dist/CustomAttributeRegistry.js.map index d856f3a..2af642a 100644 --- a/dist/CustomAttributeRegistry.js.map +++ b/dist/CustomAttributeRegistry.js.map @@ -1 +1 @@ -{"version":3,"file":"CustomAttributeRegistry.js","sourceRoot":"","sources":["../src/CustomAttributeRegistry.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,OAAO,CAAA;AAEvC,MAAM,OAAO,uBAAuB;IAmBnC,YAAmB,aAAoC;QAApC,kBAAa,GAAb,aAAa,CAAuB;QAlB/C,aAAQ,GAAG,IAAI,GAAG,EAAuB,CAAA;QACzC,gBAAW,GAAG,IAAI,OAAO,EAAyC,CAAA;QAElE,cAAS,GAAqB,IAAI,gBAAgB,CAAC,SAAS,CAAC,EAAE;YACtE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAiB,EAAE,EAAE;gBAC7C,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,EAAE;oBAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,aAAc,CAAC,CAAA;oBACnD,IAAI,IAAI;wBAAE,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,aAAc,EAAE,CAAC,CAAC,MAAiB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAA;iBAC/E;qBAGI;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AM,CAAC,CAAA;SACtC;IACF,CAAC;CACD;AAaD,IAAI,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE;IAChC,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,YAAY,CAAA;IAEpD,OAAO,CAAC,SAAS,CAAC,YAAY,GAAG,SAAS,YAAY,CAAC,OAAO;QAC7D,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QAE9C,IAAI,CAAC,IAAI,CAAC,gBAAgB;YAAE,IAAI,CAAC,gBAAgB,GAAG,IAAI,uBAAuB,CAAC,IAAI,CAAC,CAAA;QAErF,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;CACD"} \ No newline at end of file diff --git a/package.json b/package.json index 1e67f68..8c3e33c 100644 --- a/package.json +++ b/package.json @@ -37,10 +37,10 @@ }, "homepage": "https://github.com/matthewp/custom-attributes#readme", "devDependencies": { - "@lume/cli": "^0.9.0", + "@lume/cli": "^0.10.0", "prettier": "3.0.3", "rollup": "^0.41.4", - "typescript": "4.4.3" + "typescript": "^5.0.0" }, "dependencies": { "lowclass": "^5.0.0" diff --git a/tsconfig.json b/tsconfig.json index 9838b4b..d7b73b0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,3 @@ { - "extends": "./node_modules/@lume/cli/config/ts.config.json", - "include": ["./src/**/*"], - "exclude": ["./src/globals.d.ts"] + "extends": "./node_modules/@lume/cli/config/ts.config.json" }