File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ wrap(() => {
1414 }
1515
1616 function mod ( plugin ) {
17- return ( ...styles ) => getStyle ( plugin . name ) . add ( ...styles ) ;
17+ return ( ...styles ) => getStyle ( plugin ) . add ( ...styles ) ;
1818 }
1919
2020 registerModule ( name , mod ) ;
Original file line number Diff line number Diff line change 1+ export default function charCount ( string = '' , char = '' ) {
2+ const regex = new RegExp ( char , 'g' ) ;
3+ const matches = string . match ( regex ) ;
4+ return matches ?. length ?? 0 ;
5+ }
Original file line number Diff line number Diff line change 1+ import charCount from './charCount.js' ;
12import eventManager from './eventManager.js' ;
23import last from './last.js' ;
34
@@ -7,7 +8,7 @@ export function newStyle(plugin = false) {
78 const el = document . createElement ( 'style' ) ;
89 function appendStyle ( ) {
910 if ( el . parentElement ) return ;
10- if ( plugin ) el . dataset . underscriptPlugin = plugin ;
11+ if ( plugin ) el . dataset . underscriptPlugin = plugin . name ;
1112 else el . dataset . underscript = '' ;
1213 document . head . append ( el ) ;
1314 }
@@ -26,6 +27,11 @@ export function newStyle(plugin = false) {
2627
2728 function append ( styles = [ ] , nodes = [ ] ) {
2829 styles . flat ( ) . forEach ( ( s ) => {
30+ if ( charCount ( s , '{' ) !== charCount ( s , '}' ) ) {
31+ const logger = plugin ?. logger ?? console ;
32+ logger . error ( 'Malformed CSS (missing { or }):\n' , s ) ;
33+ return ;
34+ }
2935 el . append ( s ) ;
3036 nodes . push ( last ( el . childNodes ) ) ;
3137 } ) ;
You can’t perform that action at this time.
0 commit comments