Closed nstepien closed 2 years ago
This is likely a bug in JSDOM. We do consider display
for the whitespace. Only block
elements are joined by a space. If I try it in a browser, it returns 'test'
as expected: https://codesandbox.io/s/zen-cartwright-ql4org?file=/src/index.js.
Seems like mark
is considered a block element in JSDOM. There's a default stylesheet in JSDOM. Maybe it's as simple as adding mark { display: inline; }
to that.
@testing-library/dom
version: 8.17.1Relevant code or config:
What you did:
I'm trying to match elements by their role and name. We render a list of options, and depending on the text input the user may have entered, we mark matching text nodes.
What happened:
Reproduction:
See code above, or https://codesandbox.io/s/react-testing-library-demo-forked-mc560z?file=/src/__tests__/hello.js
Problem description:
I'd expect inline elements, such as
<mark>
or<span>
not to introduce spaces around them in accessibility names.Suggested solution:
Maybe inline rendering can be assume for some DOM nodes?