| 148 | } |
| 149 | |
| 150 | export class CSSParser { |
| 151 | static { |
| 152 | this.prototype.mainState = MainState.None; |
| 153 | this.prototype.stringState = StringState.None; |
| 154 | this.prototype.atState = AtState.None; |
| 155 | this.prototype.escaping = false; |
| 156 | |
| 157 | this.prototype.currentSelector = ''; |
| 158 | |
| 159 | this.prototype.currentRule = null; |
| 160 | this.prototype.parentRule = null; |
| 161 | |
| 162 | this.prototype.currentProp = ''; |
| 163 | this.prototype.currentValue = ''; |
| 164 | |
| 165 | this.prototype.currentAtName = ''; |
| 166 | this.prototype.currentAtCond = ''; |
| 167 | } |
| 168 | |
| 169 | rules = []; |
| 170 | |
| 171 | constructor(bailing = true) { |
| 172 | if (bailing) { |
| 173 | const _parse = this.parse.bind(this); |
| 174 | this.parse = (...args) => { |
| 175 | try { |
| 176 | return _parse(...args); |
| 177 | } catch (e) { |
| 178 | console.warn('CSSParser bailed', e); |
| 179 | return []; |
| 180 | } |
| 181 | }; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | parse(input) { |
| 186 | const checkToken = (a, b) => !this.escaping && this.stringState === StringState.None && a === b; |
| 187 | |
| 188 | const checkSES = c => { |
| 189 | if (this.escaping) { |
| 190 | return false; |
| 191 | } |
| 192 | |
| 193 | if (c != '"' && c != '\'') { |
| 194 | return false; |
| 195 | } |
| 196 | |
| 197 | const state = c == '"' ? StringState.Double : StringState.Single; |
| 198 | |
| 199 | // start |
| 200 | if (this.stringState == StringState.None) { |
| 201 | this.stringState = state; |
| 202 | return true; |
| 203 | } |
| 204 | |
| 205 | // end |
| 206 | if (this.stringState == state) { |
| 207 | this.stringState = StringState.None; |
nothing calls this directly
no outgoing calls
no test coverage detected