Skip to content

Commit

Permalink
added: patch to match complex pseudoselectors riot/riot#2967
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaGuarini committed Nov 1, 2022
1 parent 5e6f53c commit da9c4f9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/generators/css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const CSS_SELECTOR = RegExp(`([{}]|^)[; ]*((?:[^@ ;{}][^{}]*)?[^@ ;{}:] ?)(?={)|
* @const {RegExp}
*/

const CSS_SELECTOR_LIST = /([^,]+):\w+(?:[\s|\S]*?\))?|([^,]+)/g
const CSS_SELECTOR_LIST = /([^,]+)(?::\w+(?:[\s|\S]*?\))?\s?)+|([^,]+)/g

/**
* Scope the css selectors prefixing them with the tag name
Expand Down
9 changes: 6 additions & 3 deletions test/generators/css.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('Generators - CSS', () => {
expect(output.default.template).to.be.not.ok
})

it('scoped css are properly generated', () => {
it('simple scoped css are properly generated', () => {
expect(addScopeToSelectorList('my-tag', '')).to.be.equal('')
expect(addScopeToSelectorList('my-tag', 'from')).to.be.equal('from')
expect(addScopeToSelectorList('my-tag', 'to')).to.be.equal('to')
Expand All @@ -148,13 +148,16 @@ describe('Generators - CSS', () => {
expect(addScopeToSelectorList('my-tag', ':host')).to.be.equal('my-tag,[is="my-tag"]')
expect(addScopeToSelectorList('my-tag', ':host:hover')).to.be.equal('my-tag:hover,[is="my-tag"]:hover')
expect(addScopeToSelectorList('my-tag', 'input')).to.be.equal('my-tag input,[is="my-tag"] input')
expect(addScopeToSelectorList('my-tag', '.foo, .bar')).to.be.equal('my-tag .foo,[is="my-tag"] .foo,my-tag .bar,[is="my-tag"] .bar')
expect(addScopeToSelectorList('my-tag', '.foo:hover, .foo:focus')).to.be.equal('my-tag .foo:hover,[is="my-tag"] .foo:hover,my-tag .foo:focus,[is="my-tag"] .foo:focus')
})

it('complex scoped css are properly generated', () => {
expect(addScopeToSelectorList('my-tag', '.foo:has(.bar,.baz)')).to.be.equal('my-tag .foo:has(.bar,.baz),[is="my-tag"] .foo:has(.bar,.baz)')
expect(addScopeToSelectorList('my-tag', '.foo:not(.bar,.baz)')).to.be.equal('my-tag .foo:not(.bar,.baz),[is="my-tag"] .foo:not(.bar,.baz)')
expect(addScopeToSelectorList('my-tag', '.foo:where(.bar,.baz)')).to.be.equal('my-tag .foo:where(.bar,.baz),[is="my-tag"] .foo:where(.bar,.baz)')
expect(addScopeToSelectorList('my-tag', '.foo:is(.bar,.baz)')).to.be.equal('my-tag .foo:is(.bar,.baz),[is="my-tag"] .foo:is(.bar,.baz)')
expect(addScopeToSelectorList('my-tag', '.foo :is(.bar,.baz) :is(.d, .e)')).to.be.equal('my-tag .foo :is(.bar,.baz),[is="my-tag"] .foo :is(.bar,.baz) :is(.d, .e)')
expect(addScopeToSelectorList('my-tag', '.foo :is(.bar,.baz) :is(.d, .e)')).to.be.equal('my-tag .foo :is(.bar,.baz) :is(.d, .e),[is="my-tag"] .foo :is(.bar,.baz) :is(.d, .e)')
expect(addScopeToSelectorList('my-tag', '.foo:is(.bar,.baz), .bar')).to.be.equal('my-tag .foo:is(.bar,.baz),[is="my-tag"] .foo:is(.bar,.baz),my-tag .bar,[is="my-tag"] .bar')
expect(addScopeToSelectorList('my-tag', '.foo, .bar')).to.be.equal('my-tag .foo,[is="my-tag"] .foo,my-tag .bar,[is="my-tag"] .bar')
})
})

0 comments on commit da9c4f9

Please sign in to comment.