Skip to content

Commit

Permalink
fix(pretty-format): only call hasAttribute if function (#11000)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhaenisch committed Jan 6, 2021
1 parent 7430a78 commit 931d466
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Expand Up @@ -49,9 +49,10 @@
- `[jest-transform]` Show enhanced `SyntaxError` message for all `SyntaxError`s ([#10749](https://github.com/facebook/jest/pull/10749))
- `[jest-transform]` [**BREAKING**] Refactor API to pass an options bag around rather than multiple boolean options ([#10753](https://github.com/facebook/jest/pull/10753))
- `[jest-transform]` [**BREAKING**] Refactor API of transformers to pass an options bag rather than separate `config` and other options ([#10834](https://github.com/facebook/jest/pull/10834))
- `[jest-worker]` [**BREAKING**] Use named exports ([#10623] (https://github.com/facebook/jest/pull/10623))
- `[jest-worker]` Do not swallow errors during serialization ([#10984] (https://github.com/facebook/jest/pull/10984))
- `[jest-worker]` [**BREAKING**] Use named exports ([#10623](https://github.com/facebook/jest/pull/10623))
- `[jest-worker]` Do not swallow errors during serialization ([#10984](https://github.com/facebook/jest/pull/10984))
- `[pretty-format]` [**BREAKING**] Convert to ES Modules ([#10515](https://github.com/facebook/jest/pull/10515))
- `[pretty-format]` Only call `hasAttribute` if it's a function ([#11000](https://github.com/facebook/jest/pull/11000))

### Chore & Maintenance

Expand Down
2 changes: 1 addition & 1 deletion packages/pretty-format/src/plugins/DOMElement.ts
Expand Up @@ -27,7 +27,7 @@ const testNode = (val: any) => {
const {nodeType, tagName} = val;
const isCustomElement =
(typeof tagName === 'string' && tagName.includes('-')) ||
val.hasAttribute?.('is');
(typeof val.hasAttribute === 'function' && val.hasAttribute('is'));

return (
(nodeType === ELEMENT_NODE &&
Expand Down

0 comments on commit 931d466

Please sign in to comment.