UNPKG

987 BJavaScriptView Raw
1import {
2 o
3} from "./chunk.WWAD5WF4.js";
4
5// src/internal/default-value.ts
6var defaultValue = (propertyName = "value") => (proto, key) => {
7 const ctor = proto.constructor;
8 const attributeChangedCallback = ctor.prototype.attributeChangedCallback;
9 ctor.prototype.attributeChangedCallback = function(name, old, value) {
10 var _a;
11 const options = ctor.getPropertyOptions(propertyName);
12 const attributeName = typeof options.attribute === "string" ? options.attribute : propertyName;
13 if (name === attributeName) {
14 const converter = options.converter || o;
15 const fromAttribute = typeof converter === "function" ? converter : (_a = converter == null ? void 0 : converter.fromAttribute) != null ? _a : o.fromAttribute;
16 const newValue = fromAttribute(value, options.type);
17 if (this[propertyName] !== newValue) {
18 this[key] = newValue;
19 }
20 }
21 attributeChangedCallback.call(this, name, old, value);
22 };
23};
24
25export {
26 defaultValue
27};