Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <span>{first} {last}</span>
}

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.
Expand Down
5 changes: 1 addition & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down