Skip to content

Commit

Permalink
Allow style attributes with hex values.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjeffburke committed Jan 8, 2019
1 parent 2ad0a31 commit 7e6aa57
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.js
Expand Up @@ -85,7 +85,12 @@ 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*(#(?:[0-9a-fA-F]{3}){1,2}|(\w|-)+)\s*$|^$/.test(
part
)
);

if (invalidStyles.length > 0) {
expect.errorMode = 'nested';
Expand Down
8 changes: 8 additions & 0 deletions test/index.spec.js
Expand Up @@ -1820,6 +1820,14 @@ describe('unexpected-dom', () => {
parseHtml('<div style="">hey</div>')
));

it('should not fail for a style attribute with hex value on the RHS', () => {
expect(
parseHtml('<div style="border-left-color: #1BcD3F">hey</div>'),
'to satisfy',
parseHtml('<div style="border-left-color: #1BcD3F;">hey</div>')
);
});

it('should fail when the RHS has invalid styles', () =>
expect(
() =>
Expand Down

0 comments on commit 7e6aa57

Please sign in to comment.