Skip to content

Commit d0b169a

Browse files
committed
fix: don't suggest for script,style tags
1 parent 95bb7f2 commit d0b169a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/__tests__/suggestions.js

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

13+
test('dost not suggest for inline script, style', () => {
14+
renderIntoDocument(
15+
`<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>`,
16+
)
17+
18+
expect(() => screen.getByTestId('script')).not.toThrow()
19+
expect(() => screen.getByTestId('style')).not.toThrow()
20+
})
21+
1322
test('does not suggest when using getByRole', () => {
1423
renderIntoDocument(`<button data-testid="foo">submit</button>`)
1524

src/suggestions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function getSuggestedQuery(element, variant) {
5858
}
5959

6060
const textContent = normalize(element.textContent)
61-
if (textContent) {
61+
if (textContent && !element.matches('script, style')) {
6262
return makeSuggestion('Text', textContent, {variant})
6363
}
6464

0 commit comments

Comments
 (0)