UNPKG

@sandlada/mdc

Version:

@sandlada/mdc is an open source component library that follows the Material Design 3 design specifications.

8 lines (7 loc) 1.34 kB
import"../../lit-element-Ho-VPzO1.js";import{AriaProperties as t,ariaPropertyToAttribute as e,isARIAAttribute as r}from"./aria.js"; /** * @license * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ const s=Symbol("privateIgnoreAttributeChangesFor");function a(a){var n;class o extends a{constructor(){super(...arguments),this[n]=new Set}static{n=s}attributeChangedCallback(t,e,a){if(!r(t))return void super.attributeChangedCallback(t,e,a);if(this[s].has(t))return;this[s].add(t),this.removeAttribute(t),this[s].delete(t);const i=u(t);null===a?delete this.dataset[i]:this.dataset[i]=a,this.requestUpdate(u(t),e)}getAttribute(t){return r(t)?super.getAttribute(i(t)):super.getAttribute(t)}removeAttribute(t){super.removeAttribute(t),r(t)&&(super.removeAttribute(i(t)),this.requestUpdate())}}return function(r){for(const s of t){const t=e(s),a=i(t),n=u(t);r.createProperty(s,{attribute:t,noAccessor:!0}),r.createProperty(Symbol(a),{attribute:a,noAccessor:!0}),Object.defineProperty(r.prototype,s,{configurable:!0,enumerable:!0,get(){return this.dataset[n]??null},set(t){const e=this.dataset[n]??null;t!==e&&(null===t?delete this.dataset[n]:this.dataset[n]=t,this.requestUpdate(s,e))}})}}(o),o}function i(t){return`data-${t}`}function u(t){return t.replace(/-\w/,t=>t[1].toUpperCase())}export{a as mixinDelegatesAria};