We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
2 parentscf47d52 +60a5e1c commit49458c5Copy full SHA for 49458c5
src/index.js
@@ -11,7 +11,14 @@ export default function register(Component, tagName, propNames) {
11
PreactElement.prototype.connectedCallback=connectedCallback;
12
PreactElement.prototype.attributeChangedCallback=attributeChangedCallback;
13
PreactElement.prototype.detachedCallback=detachedCallback;
14
-PreactElement.observedAttributes=propNames||Component.observedAttributes||Object.keys(Component.propTypes||{});
+propNames=propNames||Component.observedAttributes||Object.keys(Component.propTypes||{});
15
+PreactElement.observedAttributes=propNames;
16
+propNames.forEach(name=>{
17
+Object.defineProperty(PreactElement.prototype,name,{
18
+get(){returnthis._vdom.props[name];},
19
+set(v){this.attributeChangedCallback(name,null,v);}
20
+});
21
+})
22
23
returncustomElements.define(
24
tagName||Component.tagName||Component.displayName||Component.name,