Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vscode-html-languageservice

Package Overview
Dependencies
Maintainers
6
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vscode-html-languageservice - npm Package Compare versions

Comparing version 3.1.0-next.0 to 3.1.0-next.1

20

lib/esm/parser/htmlParser.js

@@ -66,3 +66,3 @@ /*---------------------------------------------------------------------------------------------

export function parse(text) {
var scanner = createScanner(text);
var scanner = createScanner(text, undefined, undefined, true);
var htmlDocument = new Node(0, text.length, [], void 0);

@@ -85,7 +85,15 @@ var curr = htmlDocument;

case TokenType.StartTagClose:
curr.end = scanner.getTokenEnd(); // might be later set to end tag position
curr.startTagEnd = scanner.getTokenEnd();
if (curr.tag && isVoidElement(curr.tag) && curr.parent) {
curr.closed = true;
curr = curr.parent;
if (curr.parent) {
curr.end = scanner.getTokenEnd(); // might be later set to end tag position
if (scanner.getTokenLength()) {
curr.startTagEnd = scanner.getTokenEnd();
if (curr.tag && isVoidElement(curr.tag)) {
curr.closed = true;
curr = curr.parent;
}
}
else {
// pseudo close token from an incomplete start tag
curr = curr.parent;
}
}

@@ -92,0 +100,0 @@ break;

import { ScannerState, Scanner } from '../htmlLanguageTypes';
export declare function createScanner(input: string, initialOffset?: number, initialState?: ScannerState): Scanner;
export declare function createScanner(input: string, initialOffset?: number, initialState?: ScannerState, emitPseudoCloseTags?: boolean): Scanner;

@@ -136,5 +136,6 @@ /*---------------------------------------------------------------------------------------------

};
export function createScanner(input, initialOffset, initialState) {
export function createScanner(input, initialOffset, initialState, emitPseudoCloseTags) {
if (initialOffset === void 0) { initialOffset = 0; }
if (initialState === void 0) { initialState = ScannerState.WithinContent; }
if (emitPseudoCloseTags === void 0) { emitPseudoCloseTags = false; }
var stream = new MultiLineStream(input, initialOffset);

@@ -165,3 +166,3 @@ var state = initialState;

var token = internalScan();
if (token !== TokenType.EOS && offset === stream.pos()) {
if (token !== TokenType.EOS && offset === stream.pos() && !(emitPseudoCloseTags && (token === TokenType.StartTagClose || token === TokenType.EndTagClose))) {
console.log('Scanner.scan has not advanced at offset ' + offset + ', state before: ' + oldState + ' after: ' + state);

@@ -238,3 +239,7 @@ stream.advance(1);

}
errorMessage = localize('error.tagNameExpected', 'Closing bracket expected.');
if (emitPseudoCloseTags && stream.peekChar() === _LAN) { // <
state = ScannerState.WithinContent;
return finishToken(offset, TokenType.EndTagClose, localize('error.closingBracketMissing', 'Closing bracket missing.'));
}
errorMessage = localize('error.closingBracketExpected', 'Closing bracket expected.');
break;

@@ -294,2 +299,6 @@ case ScannerState.AfterOpeningStartTag:

}
if (emitPseudoCloseTags && stream.peekChar() === _LAN) { // <
state = ScannerState.WithinContent;
return finishToken(offset, TokenType.StartTagClose, localize('error.closingBracketMissing', 'Closing bracket missing.'));
}
stream.advance(1);

@@ -296,0 +305,0 @@ return finishToken(offset, TokenType.Unknown, localize('error.unexpectedCharacterInTag', 'Unexpected character in tag.'));

@@ -77,3 +77,3 @@ /*---------------------------------------------------------------------------------------------

function parse(text) {
var scanner = htmlScanner_1.createScanner(text);
var scanner = htmlScanner_1.createScanner(text, undefined, undefined, true);
var htmlDocument = new Node(0, text.length, [], void 0);

@@ -96,7 +96,15 @@ var curr = htmlDocument;

case htmlLanguageTypes_1.TokenType.StartTagClose:
curr.end = scanner.getTokenEnd(); // might be later set to end tag position
curr.startTagEnd = scanner.getTokenEnd();
if (curr.tag && fact_1.isVoidElement(curr.tag) && curr.parent) {
curr.closed = true;
curr = curr.parent;
if (curr.parent) {
curr.end = scanner.getTokenEnd(); // might be later set to end tag position
if (scanner.getTokenLength()) {
curr.startTagEnd = scanner.getTokenEnd();
if (curr.tag && fact_1.isVoidElement(curr.tag)) {
curr.closed = true;
curr = curr.parent;
}
}
else {
// pseudo close token from an incomplete start tag
curr = curr.parent;
}
}

@@ -103,0 +111,0 @@ break;

import { ScannerState, Scanner } from '../htmlLanguageTypes';
export declare function createScanner(input: string, initialOffset?: number, initialState?: ScannerState): Scanner;
export declare function createScanner(input: string, initialOffset?: number, initialState?: ScannerState, emitPseudoCloseTags?: boolean): Scanner;

@@ -147,5 +147,6 @@ /*---------------------------------------------------------------------------------------------

};
function createScanner(input, initialOffset, initialState) {
function createScanner(input, initialOffset, initialState, emitPseudoCloseTags) {
if (initialOffset === void 0) { initialOffset = 0; }
if (initialState === void 0) { initialState = htmlLanguageTypes_1.ScannerState.WithinContent; }
if (emitPseudoCloseTags === void 0) { emitPseudoCloseTags = false; }
var stream = new MultiLineStream(input, initialOffset);

@@ -176,3 +177,3 @@ var state = initialState;

var token = internalScan();
if (token !== htmlLanguageTypes_1.TokenType.EOS && offset === stream.pos()) {
if (token !== htmlLanguageTypes_1.TokenType.EOS && offset === stream.pos() && !(emitPseudoCloseTags && (token === htmlLanguageTypes_1.TokenType.StartTagClose || token === htmlLanguageTypes_1.TokenType.EndTagClose))) {
console.log('Scanner.scan has not advanced at offset ' + offset + ', state before: ' + oldState + ' after: ' + state);

@@ -249,3 +250,7 @@ stream.advance(1);

}
errorMessage = localize('error.tagNameExpected', 'Closing bracket expected.');
if (emitPseudoCloseTags && stream.peekChar() === _LAN) { // <
state = htmlLanguageTypes_1.ScannerState.WithinContent;
return finishToken(offset, htmlLanguageTypes_1.TokenType.EndTagClose, localize('error.closingBracketMissing', 'Closing bracket missing.'));
}
errorMessage = localize('error.closingBracketExpected', 'Closing bracket expected.');
break;

@@ -305,2 +310,6 @@ case htmlLanguageTypes_1.ScannerState.AfterOpeningStartTag:

}
if (emitPseudoCloseTags && stream.peekChar() === _LAN) { // <
state = htmlLanguageTypes_1.ScannerState.WithinContent;
return finishToken(offset, htmlLanguageTypes_1.TokenType.StartTagClose, localize('error.closingBracketMissing', 'Closing bracket missing.'));
}
stream.advance(1);

@@ -307,0 +316,0 @@ return finishToken(offset, htmlLanguageTypes_1.TokenType.Unknown, localize('error.unexpectedCharacterInTag', 'Unexpected character in tag.'));

{
"name": "vscode-html-languageservice",
"version": "3.1.0-next.0",
"version": "3.1.0-next.1",
"description": "Language service for HTML",

@@ -5,0 +5,0 @@ "main": "./lib/umd/htmlLanguageService.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc