You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> _**\* Note:** as per the [Custom Elements specification](http://w3c.github.io/webcomponents/spec/custom/#prod-potentialcustomelementname), the tag name must contain a hyphen._
@@ -31,19 +31,45 @@ Output:
31
31
<p>Hello, Billy Jo!</p>
32
32
```
33
33
34
-
### Why the prop names parameter?
34
+
### Prop Names and Automatic Prop Names
35
35
36
-
The Custom Elements V1 spec requires you to explictly state the attribute names you want to observe. From your Preact component perspective, `props` could be an object with any keys at runtime. This unfortunate combination of factors leaves us needing to explicitly state them.
36
+
The Custom Elements V1 specification requires explictly stating the names of any attributes you want to observe. From your Preact component perspective, `props` could be an object with any keys at runtime, so it's not always clear which props should be accepted as attributes.
37
37
38
-
It's possible that a compile step could introspect your usages of props and generate the glue code here. Please send me a link if you do this!
38
+
If you omit the third parameter to `register()`, the list of attributes to observe can be specified using a static `observedAttributes` property on your Component. This also works for the Custom Element's name, which can be specified using a `tagName` static property:
Big thanks to BrowserStack for providing service for CI on this project! BrowserStack allows us to test this project on all real browsers that support Custom Elements, including mobile browsers.
51
+
render({ name }) {
52
+
return<p>Hello, {name}!</p>;
53
+
}
54
+
}
55
+
register(Greeting);
56
+
```
57
+
58
+
If no `observedAttributes` are specified, they will be inferred from the keys of `propTypes` if present on the Component:
0 commit comments