commit
This commit is contained in:
parent
be4fd23bcf
commit
0bd53741af
728 changed files with 86573 additions and 0 deletions
52
node_modules/parse5/lib/extensions/error-reporting/parser-mixin.js
generated
vendored
Normal file
52
node_modules/parse5/lib/extensions/error-reporting/parser-mixin.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
'use strict';
|
||||
|
||||
const ErrorReportingMixinBase = require('./mixin-base');
|
||||
const ErrorReportingTokenizerMixin = require('./tokenizer-mixin');
|
||||
const LocationInfoTokenizerMixin = require('../location-info/tokenizer-mixin');
|
||||
const Mixin = require('../../utils/mixin');
|
||||
|
||||
class ErrorReportingParserMixin extends ErrorReportingMixinBase {
|
||||
constructor(parser, opts) {
|
||||
super(parser, opts);
|
||||
|
||||
this.opts = opts;
|
||||
this.ctLoc = null;
|
||||
this.locBeforeToken = false;
|
||||
}
|
||||
|
||||
_setErrorLocation(err) {
|
||||
if (this.ctLoc) {
|
||||
err.startLine = this.ctLoc.startLine;
|
||||
err.startCol = this.ctLoc.startCol;
|
||||
err.startOffset = this.ctLoc.startOffset;
|
||||
|
||||
err.endLine = this.locBeforeToken ? this.ctLoc.startLine : this.ctLoc.endLine;
|
||||
err.endCol = this.locBeforeToken ? this.ctLoc.startCol : this.ctLoc.endCol;
|
||||
err.endOffset = this.locBeforeToken ? this.ctLoc.startOffset : this.ctLoc.endOffset;
|
||||
}
|
||||
}
|
||||
|
||||
_getOverriddenMethods(mxn, orig) {
|
||||
return {
|
||||
_bootstrap(document, fragmentContext) {
|
||||
orig._bootstrap.call(this, document, fragmentContext);
|
||||
|
||||
Mixin.install(this.tokenizer, ErrorReportingTokenizerMixin, mxn.opts);
|
||||
Mixin.install(this.tokenizer, LocationInfoTokenizerMixin);
|
||||
},
|
||||
|
||||
_processInputToken(token) {
|
||||
mxn.ctLoc = token.location;
|
||||
|
||||
orig._processInputToken.call(this, token);
|
||||
},
|
||||
|
||||
_err(code, options) {
|
||||
mxn.locBeforeToken = options && options.beforeToken;
|
||||
mxn._reportError(code);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ErrorReportingParserMixin;
|
Loading…
Add table
Add a link
Reference in a new issue