(css, opts = {})
| 35 | } |
| 36 | |
| 37 | constructor(css, opts = {}) { |
| 38 | if ( |
| 39 | css === null || |
| 40 | typeof css === 'undefined' || |
| 41 | (typeof css === 'object' && !css.toString) |
| 42 | ) { |
| 43 | throw new Error(`PostCSS received ${css} instead of CSS string`) |
| 44 | } |
| 45 | |
| 46 | this.css = css.toString() |
| 47 | |
| 48 | if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') { |
| 49 | this.hasBOM = true |
| 50 | this.css = this.css.slice(1) |
| 51 | } else { |
| 52 | this.hasBOM = false |
| 53 | } |
| 54 | |
| 55 | this.document = this.css |
| 56 | if (opts.document) this.document = opts.document.toString() |
| 57 | |
| 58 | if (opts.from) { |
| 59 | if ( |
| 60 | !pathAvailable || |
| 61 | /^\w+:\/\//.test(opts.from) || |
| 62 | isAbsolute(opts.from) |
| 63 | ) { |
| 64 | this.file = opts.from |
| 65 | } else { |
| 66 | this.file = resolve(opts.from) |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | if (pathAvailable && sourceMapAvailable) { |
| 71 | let map = new PreviousMap(this.css, opts) |
| 72 | if (map.text) { |
| 73 | this.map = map |
| 74 | let file = map.consumer().file |
| 75 | if (!this.file && file) this.file = this.mapResolve(file) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | if (!this.file) { |
| 80 | this.id = '<input css ' + nanoid(6) + '>' |
| 81 | } |
| 82 | if (this.map) this.map.file = this.from |
| 83 | } |
| 84 | |
| 85 | error(message, line, column, opts = {}) { |
| 86 | let endColumn, endLine, endOffset, offset, result |
nothing calls this directly
no test coverage detected