Skip to content

Commit 3f2b738

Browse files
authored
refactor: Drop support for using propTypes to define observedAttrs (#125)
1 parent 7da9deb commit 3f2b738

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed

README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,6 @@ class Greeting extends Component {
6363
register(Greeting);
6464
```
6565

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

8468
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)