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

Allow dashes in style names and values #241

Merged
merged 1 commit 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 src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function isEnumeratedAttribute(attrName) {
function validateStyles(expect, str) {
const invalidStyles = str
.split(';')
.filter(part => !/^\s*\w+\s*:\s*\w+\s*$|^$/.test(part));
.filter(part => !/^\s*(\w|-)+\s*:\s*(\w|-)+\s*$|^$/.test(part));

if (invalidStyles.length > 0) {
expect.errorMode = 'nested';
Expand Down
10 changes: 7 additions & 3 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1822,14 +1822,18 @@ describe('unexpected-dom', () => {

it('should succeed when the subject has an extra inline style', () =>
expect(
parseHtml('<div style="color: tan; width: 120px;">hey</div>'),
parseHtml(
'<div style="color: tan; width: 120px; z-index: 700; background-repeat: no-repeat">hey</div>'
),
'to satisfy',
parseHtml('<div style="color: tan;">hey</div>')
parseHtml(
'<div style="color: tan; z-index: 700;background-repeat: no-repeat">hey</div>'
)
));

it('should not fail for invalid style attributes on the LHS', () =>
expect(
parseHtml('<div style="color; width: 120px;">hey</div>'),
parseHtml('<div style="color; width: 120px; z-index: 700">hey</div>'),
'to satisfy',
parseHtml('<div style="width: 120px;">hey</div>')
));
Expand Down