Skip to content

Commit 72d3107

Browse files
committed
refactor: Drop support for using propTypes to define observedAttrs (#125)
1 parent 0e31535 commit 72d3107

File tree

2 files changed

+1
-24
lines changed

2 files changed

+1
-24
lines changed

README.md

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,6 @@ class Greeting extends Component {
6161
register(Greeting);
6262
```
6363

64-
If no `observedAttributes` are specified, they will be inferred from the keys of `propTypes` if present on the Component:
65-
66-
```js
67-
// Other option: use PropTypes:
68-
function FullName({ first, last }) {
69-
return (
70-
<span>
71-
{first} {last}
72-
</span>
73-
);
74-
}
75-
76-
FullName.propTypes = {
77-
first: Object, // you can use PropTypes, or this
78-
last: Object, // trick to define untyped props.
79-
};
80-
81-
register(FullName, 'full-name');
82-
```
83-
8464
### Passing slots as props
8565

8666
The `register()` function also accepts an optional fourth parameter, an options bag. At present, it allows you to opt-in to using shadow DOM for your custom element by setting the `shadow` property to `true`, and if so, you can also specify the encapsulation mode with `mode`, which can be either `'open'` or `'closed'`. Additionally, you may mark the shadow root as being serializable with the boolean `serializable` property.

src/index.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ export default function register(Component, tagName, propNames, options) {
4040
/**
4141
* @type {string[]}
4242
*/
43-
propNames =
44-
propNames ||
45-
Component.observedAttributes ||
46-
Object.keys(Component.propTypes || {});
43+
propNames = propNames || Component.observedAttributes || [];
4744
PreactElement.observedAttributes = propNames;
4845

4946
if (Component.formAssociated) {

0 commit comments

Comments
 (0)