()
| 400 | } |
| 401 | |
| 402 | sync() { |
| 403 | if (this.error) throw this.error |
| 404 | if (this.processed) return this.result |
| 405 | this.processed = true |
| 406 | |
| 407 | if (this.processing) { |
| 408 | throw this.getAsyncError() |
| 409 | } |
| 410 | |
| 411 | for (let plugin of this.plugins) { |
| 412 | let promise = this.runOnRoot(plugin) |
| 413 | if (isPromise(promise)) { |
| 414 | throw this.getAsyncError() |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | this.prepareVisitors() |
| 419 | if (this.hasListener) { |
| 420 | let root = this.result.root |
| 421 | while (!root[isClean]) { |
| 422 | root[isClean] = true |
| 423 | this.walkSync(root) |
| 424 | } |
| 425 | if (this.listeners.OnceExit) { |
| 426 | if (root.type === 'document') { |
| 427 | for (let subRoot of root.nodes) { |
| 428 | this.visitSync(this.listeners.OnceExit, subRoot) |
| 429 | } |
| 430 | } else { |
| 431 | this.visitSync(this.listeners.OnceExit, root) |
| 432 | } |
| 433 | } |
| 434 | } |
| 435 | |
| 436 | return this.result |
| 437 | } |
| 438 | |
| 439 | then(onFulfilled, onRejected) { |
| 440 | if (process.env.NODE_ENV !== 'production') { |
no test coverage detected