sudovanilla-website/public/@shoelace-style/shoelace/cdn/chunks/chunk.RQ7JZ4R7.js
2024-05-13 23:34:06 -04:00

27 lines
987 B
JavaScript

import {
u
} from "./chunk.CXZZ2LVK.js";
// src/internal/default-value.ts
var defaultValue = (propertyName = "value") => (proto, key) => {
const ctor = proto.constructor;
const attributeChangedCallback = ctor.prototype.attributeChangedCallback;
ctor.prototype.attributeChangedCallback = function(name, old, value) {
var _a;
const options = ctor.getPropertyOptions(propertyName);
const attributeName = typeof options.attribute === "string" ? options.attribute : propertyName;
if (name === attributeName) {
const converter = options.converter || u;
const fromAttribute = typeof converter === "function" ? converter : (_a = converter == null ? void 0 : converter.fromAttribute) != null ? _a : u.fromAttribute;
const newValue = fromAttribute(value, options.type);
if (this[propertyName] !== newValue) {
this[key] = newValue;
}
}
attributeChangedCallback.call(this, name, old, value);
};
};
export {
defaultValue
};