Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/api/attributes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ describe('$(...)', () => {
expect(attr).toBe('autofocus');
});

it('(valid key) : should preserve non-boolean hidden attribute values', () => {
const attr = $('<div hidden="until-found">').attr('hidden');
expect(attr).toBe('until-found');
});

it('(key, value) : should set one attr', () => {
const $pear = $('.pear').attr('id', 'pear');
expect($('#pear')).toHaveLength(1);
Expand Down
2 changes: 1 addition & 1 deletion src/api/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const dataAttrPrefix = 'data-';

// Attributes that are booleans
const rboolean =
/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i;
/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|loop|multiple|open|readonly|required|scoped|selected)$/i;
// Matches strings that look like JSON objects or arrays
const rbrace = /^{[^]*}$|^\[[^]*]$/;

Expand Down