Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
'use strict';
const util = require('util');
const {DomHandler, Parser, ElementType} = require('htmlparser2');
const DEFAULT_OPTIONS = {
lowerCaseTags: true,
recognizeSelfClosing: true,
lowerCaseAttributeNames: false
};
const rawOnattribend = Parser.prototype.onattribend;
const rawOnattribdata = Parser.prototype.onattribdata;
const rawOnselfclosingtag = Parser.prototype.onselfclosingtag;
const rawOnclosetag = Parser.prototype.onclosetag;
class TemplateParser {
constructor(...args) {
Parser.apply(this, args);
}
onattribdata(...args) {
rawOnattribdata.apply(this, args);
this._hasAttrValue = true;
}
onattribend(...args) {
if (!this._hasAttrValue) {
// reset boolean value
this._attribvalue = true;
beforeEach(() => {
spy = jest.spyOn(Parser.prototype, 'write')
})
afterEach(() => spy.mockRestore())
* @file Template parser
* @author sparklewhy@gmail.com
*/
'use strict';
const util = require('util');
const {DomHandler, Parser, ElementType} = require('htmlparser2');
const DEFAULT_OPTIONS = {
lowerCaseTags: true,
recognizeSelfClosing: true,
lowerCaseAttributeNames: false
};
const rawOnattribend = Parser.prototype.onattribend;
const rawOnattribdata = Parser.prototype.onattribdata;
const rawOnselfclosingtag = Parser.prototype.onselfclosingtag;
const rawOnclosetag = Parser.prototype.onclosetag;
class TemplateParser {
constructor(...args) {
Parser.apply(this, args);
}
onattribdata(...args) {
rawOnattribdata.apply(this, args);
this._hasAttrValue = true;
}
onattribend(...args) {
if (!this._hasAttrValue) {