Skip to content

Commit 39ffb8f

Browse files
committed
don't suggest on nested ignore tags
1 parent 001179b commit 39ffb8f

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

src/__tests__/suggestions.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ afterAll(() => {
1010
configure({throwSuggestions: false})
1111
})
1212

13+
test('does not suggest for nested inline style', () => {
14+
renderIntoDocument(
15+
`<div data-testid="style"><style>.hsuHs{margin:auto}.wFncld{margin-top:3px;color:#9AA0A6;height:20px;width:20px}</style></div>`,
16+
)
17+
18+
// screen.debug(screen.getByText(/hsus/))
19+
20+
expect(() => screen.getByTestId('style')).not.toThrow()
21+
})
22+
1323
test('does not suggest for inline script, style', () => {
1424
renderIntoDocument(
1525
`<script data-testid="script">alert('hello')</script><style data-testid="style">.hsuHs{margin:auto}.wFncld{margin-top:3px;color:#9AA0A6;height:20px;width:20px}</style>`,

src/queries/text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import {wrapAllByQueryWithSuggestion} from '../query-helpers'
12
import {
23
fuzzyMatches,
34
matches,
45
makeNormalizer,
56
getNodeText,
67
buildQueries,
78
} from './all-utils'
8-
import {wrapAllByQueryWithSuggestion} from '../query-helpers'
99

1010
function queryAllByText(
1111
container,

src/suggestions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {computeAccessibleName} from 'dom-accessibility-api'
22
import {getRoles} from './role-helpers'
33
import {getDefaultNormalizer} from './matches'
4+
import {getNodeText} from './get-node-text'
45

56
const normalize = getDefaultNormalizer()
67

@@ -57,7 +58,7 @@ export function getSuggestedQuery(element, variant) {
5758
return makeSuggestion('PlaceholderText', placeholderText, {variant})
5859
}
5960

60-
const textContent = normalize(element.textContent)
61+
const textContent = normalize(getNodeText(element))
6162
if (textContent && !element.matches('script, style')) {
6263
return makeSuggestion('Text', textContent, {variant})
6364
}

0 commit comments

Comments
 (0)