From 74e33cf22258d1869fb03329de29aecee1d581fb Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 26 Nov 2025 00:25:24 -0600 Subject: [PATCH] refactor: Drop support for using propTypes to define observedAttrs --- README.md | 16 ---------------- src/index.js | 5 +---- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/README.md b/README.md index 496c70d..63af4ec 100644 --- a/README.md +++ b/README.md @@ -63,22 +63,6 @@ class Greeting extends Component { register(Greeting); ``` -If no `observedAttributes` are specified, they will be inferred from the keys of `propTypes` if present on the Component: - -```js -// Other option: use PropTypes: -function FullName({ first, last }) { - return {first} {last} -} - -FullName.propTypes = { - first: Object, // you can use PropTypes, or this - last: Object // trick to define untyped props. -}; - -register(FullName, 'full-name'); -``` - ### Passing slots as props 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. diff --git a/src/index.js b/src/index.js index 26424c7..34c8a7b 100644 --- a/src/index.js +++ b/src/index.js @@ -40,10 +40,7 @@ export default function register(Component, tagName, propNames, options) { /** * @type {string[]} */ - propNames = - propNames || - Component.observedAttributes || - Object.keys(Component.propTypes || {}); + propNames = propNames || Component.observedAttributes || []; PreactElement.observedAttributes = propNames; if (Component.formAssociated) {