diff --git a/src/index.js b/src/index.js index 547187bf..f4bda178 100644 --- a/src/index.js +++ b/src/index.js @@ -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'; diff --git a/test/index.spec.js b/test/index.spec.js index 5c3772c3..1ab95d7d 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -1820,6 +1820,14 @@ describe('unexpected-dom', () => { parseHtml('
hey
') )); + it('should not fail for a style attribute with hex value on the RHS', () => { + expect( + parseHtml('
hey
'), + 'to satisfy', + parseHtml('
hey
') + ); + }); + it('should fail when the RHS has invalid styles', () => expect( () =>