This repository was archived by the owner on Dec 21, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,9 @@ module.exports = postcss.plugin('postcss-dir-pseudo-class', (opts) => (root) =>
3333 // conditionally prepend a combinator before inserting the [dir] attribute
3434 const first = selector . nodes [ 0 ] ;
3535 const firstIsSpaceCombinator = first && 'combinator' === first . type && ' ' === first . value ;
36+ const firstIsRoot = first && 'pseudo' === first . type && ':root' === first . value ;
3637
37- if ( first && ! firstIsSpaceCombinator ) {
38+ if ( first && ! firstIsRoot && ! firstIsSpaceCombinator ) {
3839 selector . prepend (
3940 selectorParser . combinator ( {
4041 value : ' '
@@ -45,9 +46,16 @@ module.exports = postcss.plugin('postcss-dir-pseudo-class', (opts) => (root) =>
4546 // value of the :dir pseudo-class
4647 const value = node . nodes . toString ( ) ;
4748
48- // prepend the dir attribute
49+ // whether that value matches the presumed direction
50+ const isdir = opts && Object ( opts ) . dir === value ;
51+
4952 selector . prepend (
50- selectorParser . attribute ( {
53+ // prepend :root if the direction is presumed
54+ isdir ? selectorParser . pseudo ( {
55+ value : ':root'
56+ } )
57+ // otherwise, prepend the dir attribute
58+ : selectorParser . attribute ( {
5159 attribute : 'dir' ,
5260 operator : '=' ,
5361 value : `"${ value } "`
You can’t perform that action at this time.
0 commit comments