This repository was archived by the owner on Mar 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,10 @@ import Settings from './models/Settings';
88import Style from './util/Style' ;
99import SettingsView from './views/users/settings/DefaultSettingsView' ;
1010
11+ function isWebpackStyle ( v ) {
12+ return Array . isArray ( v ) && typeof v . i === 'function' ;
13+ }
14+
1115const stubHook = ( ) => { } ;
1216const hooks = [ 'enable' , 'disable' ] ;
1317
@@ -99,7 +103,14 @@ const Plugin = Class.extend({
99103
100104 // Styles API
101105 createStyle ( defaults = { } ) {
102- const style = new Style ( defaults ) ;
106+ const style = new Style ( ) ;
107+ if ( typeof defaults === 'string' ) {
108+ style . raw ( defaults ) ;
109+ } else if ( isWebpackStyle ( defaults ) ) {
110+ style . raw ( defaults . toString ( ) ) ;
111+ } else {
112+ style . set ( defaults ) ;
113+ }
103114 this [ stylesSymbol ] . push ( style ) ;
104115 return style ;
105116 } ,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const Style = Class.extend({
99 init ( defaults ) {
1010 this . sistyl = new Sistyl ( defaults ) ;
1111 this . timeout = null ;
12+ this . rawStyles = [ ] ;
1213
1314 this . refresh = this . refresh . bind ( this ) ;
1415 this . id = _ . uniqueId ( 'eps-' ) ;
@@ -23,6 +24,15 @@ const Style = Class.extend({
2324 this . refresh ( ) ;
2425 } ,
2526
27+ raw ( text ) {
28+ this . rawStyles . push ( text ) ;
29+
30+ // throttle updates
31+ clearTimeout ( this . timeout ) ;
32+ this . timeout = setTimeout ( this . refresh , 1 ) ;
33+ return this ;
34+ } ,
35+
2636 $ ( ) {
2737 let el = this . el ;
2838 if ( popoutView . _window ) { // eslint-disable-line no-underscore-dangle
@@ -58,9 +68,8 @@ const Style = Class.extend({
5868 } ,
5969
6070 toString ( ) {
61- return this . sistyl . toString ( ) ;
71+ return ` ${ this . sistyl } \n ${ this . rawStyles . join ( '\n\n' ) } ` ;
6272 } ,
63-
6473} ) ;
6574
6675export default Style ;
You can’t perform that action at this time.
0 commit comments