File tree Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Expand file tree Collapse file tree 1 file changed +2
-3
lines changed Original file line number Diff line number Diff line change 1
1
// 🌘 CSS Scope Inline (https://github.com/gnat/css-scope-inline)
2
2
window . cssScopeCount ??= 1 // Let extra copies share the scope count.
3
- new MutationObserver ( ( mutations , observer ) => {
4
- var cssScopePattern = new RegExp ( '\.(me|this|self)(?![A-Za-z0-9\_\-])' , 'g' ) // Can use: .me .this .self
3
+ new MutationObserver ( mutations => {
5
4
for ( var mutation of mutations ) {
6
5
if ( mutation . type !== "childList" ) continue // Skip if not mutating nodes.
7
6
var nodes = [ ...mutation . addedNodes ] // Get new nodes.
@@ -12,7 +11,7 @@ new MutationObserver((mutations, observer) => {
12
11
if ( node . textContent . includes ( '.self__' ) ) continue // Skip if already processed.
13
12
var scope = 'self__' + ( window . cssScopeCount ++ ) // Ready. Make unique scope, example: .self__1234
14
13
node . parentNode . classList . add ( scope )
15
- node . textContent = node . textContent . replace ( cssScopePattern , '.' + scope )
14
+ node . textContent = node . textContent . replace ( / \. ( m e | t h i s | s e l f ) (? ! [ A - Z a - z 0 - 9 \_ \- ] ) / g , '.' + scope ) // Can use: .me .this .self
16
15
}
17
16
}
18
17
} ) . observe ( document . documentElement , { childList : true , subtree : true } )
You can’t perform that action at this time.
0 commit comments