File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -49,17 +49,31 @@ import Stylesheet from "./parser/Stylesheet.js"
4949 return this
5050 }
5151
52+ /**
53+ * get static stylesheet
54+ * @param {string } string css text
55+ * @param {object } callback callback
56+ */
57+ static ( string , callback ) {
58+ let style = new Stylesheet ( string )
59+ return callback ( style )
60+ }
61+
5262 /**
5363 * get local stylesheets
5464 * @param {object } callback callback function
5565 * @param {boolean } all return all stylesheets in callback
5666 */
5767 local ( callback , all = false ) {
5868 let styles = [ ]
59- Object . values ( document . styleSheets ) . forEach ( sheet => {
69+ Object . values ( document . styleSheets ) . forEach ( ( sheet , index ) => {
6070 if ( sheet . ownerNode != null || sheet . ownerNode . childNodes . length > 0 )
6171 if ( sheet . ownerNode . innerText != "" ) {
62- let style = new Stylesheet ( sheet . ownerNode . innerText )
72+ let filename = sheet . ownerNode . dataset . name || null
73+ if ( this . _options . only_files . length == 0 && this . _options . ignore_files . includes ( filename ) ) return
74+ if ( this . _options . only_files . length > 0 && ! this . _options . only_files . includes ( filename ) ) return
75+
76+ let style = new Stylesheet ( sheet . ownerNode . innerText , filename )
6377 all ? styles . push ( style ) : callback ( style )
6478 }
6579 } )
You can’t perform that action at this time.
0 commit comments