Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion lib/src/matchers/jest_dom/has_description.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class _HasDescription extends CustomMatcher with ElementTextContentMatcherMixin

final elementsWithDescriptions = <Element>[];
_idsOfElementsThatDescribe(item)?.forEach((id) {
final elWithDesc = querySelector('#$id');
final elWithDesc = querySelector('#${Css.escape(id)}');
if (elWithDesc != null) {
elementsWithDescriptions.add(elWithDesc);
}
Expand Down
7 changes: 4 additions & 3 deletions test/unit/dom/matchers/has_description_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ void main() {
{},
react.button({
'aria-label': 'Close',
'aria-describedby': 'description-close',
// Use a special character to verify that it is escaped correctly in hasDescription.
'aria-describedby': 'r:description-close',
}, 'X'),
react.button({
'aria-label': 'Has Multiple Descriptions',
'aria-describedby': 'description-close some-other-description',
'aria-describedby': 'r:description-close some-other-description',
}, 'X'),
react.button({}, 'Delete'),
react.button({'aria-describedby': 'not-found'}, 'Has id not found'),
react.div({'id': 'description-close'}, 'Closing will discard any changes'),
react.div({'id': 'r:description-close'}, 'Closing will discard any changes'),
react.div({'id': 'some-other-description'}, 'Some other description'),
));
});
Expand Down