Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add better support for aria-* attributes #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function context () {
e.setAttribute(v, l[k][v])
}
}
else if (k.substr(0, 5) === "data-") {
else if (/^(data|aria)-/.test(k)) {
e.setAttribute(k, l[k])
} else {
e[k] = l[k]
Expand Down
6 changes: 6 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ test('sets data attributes', function(t){
t.end()
})

test('sets aria attributes', function(t){
var div = h('div', {'aria-label': 'Close'})
t.equal(div.getAttribute('aria-label'), 'Close')
t.end()
})

test('boolean, number, date, regex get to-string\'ed', function(t){
var e = h('p', true, false, 4, new Date('Mon Jan 15 2001'), /hello/)
t.assert(e.outerHTML.match(/<p>truefalse4Mon Jan 15.+2001.*\/hello\/<\/p>/))
Expand Down