🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

simple-html-tokenizer

Package Overview
Dependencies
Maintainers
6
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-html-tokenizer - npm Package Compare versions

Comparing version

to
0.5.1

.nyc_output/be978d1b387093db581ac3ab12d90d8a.json

19

dist/es6/index.js

@@ -58,2 +58,3 @@ /**

this.index = -1;
this.tagNameBuffer = '';
this.states = {

@@ -68,2 +69,8 @@ beforeData: function () {

else {
if (char === '\n') {
var tag = this.tagNameBuffer.toLowerCase();
if (tag === 'pre' || tag === 'textarea') {
this.consume();
}
}
this.transitionTo("data" /* data */);

@@ -100,4 +107,5 @@ this.delegate.beginData();

this.transitionTo("tagName" /* tagName */);
this.tagNameBuffer = '';
this.delegate.beginStartTag();
this.delegate.appendToTagName(char);
this.appendToTagName(char);
}

@@ -184,3 +192,3 @@ },

else {
this.delegate.appendToTagName(char);
this.appendToTagName(char);
}

@@ -392,4 +400,5 @@ },

this.transitionTo("tagName" /* tagName */);
this.tagNameBuffer = '';
this.delegate.beginEndTag();
this.delegate.appendToTagName(char);
this.appendToTagName(char);
}

@@ -474,2 +483,6 @@ }

};
EventedTokenizer.prototype.appendToTagName = function (char) {
this.tagNameBuffer += char;
this.delegate.appendToTagName(char);
};
return EventedTokenizer;

@@ -476,0 +489,0 @@ }());

@@ -64,2 +64,3 @@ (function (global, factory) {

this.index = -1;
this.tagNameBuffer = '';
this.states = {

@@ -74,2 +75,8 @@ beforeData: function () {

else {
if (char === '\n') {
var tag = this.tagNameBuffer.toLowerCase();
if (tag === 'pre' || tag === 'textarea') {
this.consume();
}
}
this.transitionTo("data" /* data */);

@@ -106,4 +113,5 @@ this.delegate.beginData();

this.transitionTo("tagName" /* tagName */);
this.tagNameBuffer = '';
this.delegate.beginStartTag();
this.delegate.appendToTagName(char);
this.appendToTagName(char);
}

@@ -190,3 +198,3 @@ },

else {
this.delegate.appendToTagName(char);
this.appendToTagName(char);
}

@@ -398,4 +406,5 @@ },

this.transitionTo("tagName" /* tagName */);
this.tagNameBuffer = '';
this.delegate.beginEndTag();
this.delegate.appendToTagName(char);
this.appendToTagName(char);
}

@@ -480,2 +489,6 @@ }

};
EventedTokenizer.prototype.appendToTagName = function (char) {
this.tagNameBuffer += char;
this.delegate.appendToTagName(char);
};
return EventedTokenizer;

@@ -482,0 +495,0 @@ }());

@@ -142,2 +142,17 @@ (function (global, factory) {

});
// https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions
QUnit.test('A newline immediately following a <pre> tag is stripped', function (assert) {
var tokens = simpleHtmlTokenizer.tokenize("<pre>\nhello</pre>");
assert.deepEqual(tokens, [startTag('pre'), chars('hello'), endTag('pre')]);
});
// https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions
QUnit.test('A newline immediately following a <PRE> tag is stripped', function (assert) {
var tokens = simpleHtmlTokenizer.tokenize("<PRE>\nhello</PRE>");
assert.deepEqual(tokens, [startTag('PRE'), chars('hello'), endTag('PRE')]);
});
// https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions
QUnit.test('A newline immediately following a <textarea> tag is stripped', function (assert) {
var tokens = simpleHtmlTokenizer.tokenize("<textarea>\nhello</textarea>");
assert.deepEqual(tokens, [startTag('textarea'), chars('hello'), endTag('textarea')]);
});
QUnit.module('simple-html-tokenizer - preprocessing');

@@ -144,0 +159,0 @@ QUnit.test('Carriage returns are replaced with line feeds', function (assert) {

@@ -10,2 +10,3 @@ import { EntityParser, TokenizerDelegate, TokenizerState } from './types';

private index;
private tagNameBuffer;
constructor(delegate: TokenizerDelegate, entityParser: EntityParser);

@@ -22,2 +23,3 @@ reset(): void;

markTagStart(): void;
private appendToTagName(char);
states: {

@@ -24,0 +26,0 @@ [k in TokenizerState]?: (this: EventedTokenizer) => void;

2

package.json
{
"name": "simple-html-tokenizer",
"version": "0.5.0",
"version": "0.5.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Simple HTML Tokenizer is a lightweight JavaScript library that can be used to tokenize the kind of HTML normally found in templates.",

@@ -13,2 +13,4 @@ import { preprocessInput, isAlpha, isSpace } from './utils';

private tagNameBuffer = '';
constructor(

@@ -110,2 +112,7 @@ private delegate: TokenizerDelegate,

private appendToTagName(char: string) : void {
this.tagNameBuffer += char;
this.delegate.appendToTagName(char);
}
states: { [k in TokenizerState]?: (this: EventedTokenizer) => void } = {

@@ -120,2 +127,8 @@ beforeData() {

} else {
if (char === '\n') {
let tag = this.tagNameBuffer.toLowerCase();
if (tag === 'pre' || tag === 'textarea') {
this.consume();
}
}
this.transitionTo(TokenizerState.data);

@@ -152,4 +165,5 @@ this.delegate.beginData();

this.transitionTo(TokenizerState.tagName);
this.tagNameBuffer = '';
this.delegate.beginStartTag();
this.delegate.appendToTagName(char);
this.appendToTagName(char);
}

@@ -240,3 +254,3 @@ },

} else {
this.delegate.appendToTagName(char);
this.appendToTagName(char);
}

@@ -444,4 +458,5 @@ },

this.transitionTo(TokenizerState.tagName);
this.tagNameBuffer = '';
this.delegate.beginEndTag();
this.delegate.appendToTagName(char);
this.appendToTagName(char);
}

@@ -448,0 +463,0 @@ }

@@ -192,2 +192,20 @@ import {

// https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions
QUnit.test('A newline immediately following a <pre> tag is stripped', function(assert) {
let tokens = tokenize("<pre>\nhello</pre>");
assert.deepEqual(tokens, [startTag('pre'), chars('hello'), endTag('pre')]);
});
// https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions
QUnit.test('A newline immediately following a <PRE> tag is stripped', function(assert) {
let tokens = tokenize("<PRE>\nhello</PRE>");
assert.deepEqual(tokens, [startTag('PRE'), chars('hello'), endTag('PRE')]);
});
// https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions
QUnit.test('A newline immediately following a <textarea> tag is stripped', function(assert) {
let tokens = tokenize("<textarea>\nhello</textarea>");
assert.deepEqual(tokens, [startTag('textarea'), chars('hello'), endTag('textarea')]);
});
QUnit.module('simple-html-tokenizer - preprocessing');

@@ -194,0 +212,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet