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

Should not magically convert kebab-cased values to camelCased values #13

Merged
merged 7 commits into from
Nov 7, 2018
Merged
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 normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
module.exports = normalize

function normalize(value) {
return value.toLowerCase().replace(/\b[:-]\b/g, '')
return value.toLowerCase()
}
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ Yields:

Get the cleaned case-insensitive form of an attribute or a property.

This removed all non-alphanumerical characters from `name`, and lowercases
the result.
This lowercases the `name` and return the result.

#### Parameters

Expand All @@ -150,6 +149,7 @@ the result.
info.html.normal[info.normalize('for')] // => 'htmlFor'
info.svg.normal[info.normalize('VIEWBOX')] // => 'viewBox'
info.html.normal[info.normalize('unknown')] // => undefined
info.html.normal[info.normalize('accept-charset')] // => 'acceptCharset'
```

### `propertyInformation.html`
Expand Down
12 changes: 12 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ test('normalize', function(t) {
'attribute delimiters should remain if not preceding a word boundary (GH-7)'
)

t.equal(
normalize('class-name'),
'class-name',
'attribute delimiters should remain otherwise it will be handled as a different known property called className (GH-12)'
)

t.equal(
normalize('[cl]a[ss]'),
'[cl]a[ss]',
Expand Down Expand Up @@ -310,6 +316,12 @@ test('find', function(t) {
'should find aria properties'
)

t.deepEqual(
find(information.html, 'class-name'),
{attribute: 'class-name', property: 'class-name'},
'should not handle class-name as class property (GH-12)'
)

t.test('data', function(st) {
var mapping = {
'data-alpha': 'dataAlpha',
Expand Down