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 2.0.13 to 2.0.14

2

lib/parser/htmlParser.js

@@ -27,3 +27,3 @@ (function (factory) {

Object.defineProperty(Node.prototype, "attributeNames", {
get: function () { return Object.keys(this.attributes); },
get: function () { return this.attributes ? Object.keys(this.attributes) : []; },
enumerable: true,

@@ -30,0 +30,0 @@ configurable: true

@@ -155,4 +155,11 @@ (function (factory) {

var codeSnippet = attribute;
var command;
if (type !== 'v' && value.length) {
codeSnippet = codeSnippet + value;
if (type) {
command = {
title: 'Suggest',
command: 'editor.action.triggerSuggest'
};
}
}

@@ -163,8 +170,37 @@ result.items.push({

textEdit: vscode_languageserver_types_1.TextEdit.replace(range, codeSnippet),
insertTextFormat: vscode_languageserver_types_1.InsertTextFormat.Snippet
insertTextFormat: vscode_languageserver_types_1.InsertTextFormat.Snippet,
command: command
});
});
});
collectDataAttributesSuggestions(range);
return result;
}
function collectDataAttributesSuggestions(range) {
var dataAttr = 'data-';
var dataAttributes = {};
function addNodeDataAttributes(node) {
node.attributeNames.forEach(function (attr) {
if (strings_1.startsWith(attr, dataAttr) && !dataAttributes[attr]) {
dataAttributes[attr] = true;
}
});
node.children.forEach(function (child) { return addNodeDataAttributes(child); });
}
result.items.push({
label: dataAttr,
kind: vscode_languageserver_types_1.CompletionItemKind.Value,
textEdit: vscode_languageserver_types_1.TextEdit.replace(range, dataAttr),
insertTextFormat: vscode_languageserver_types_1.InsertTextFormat.Snippet
});
if (htmlDocument) {
htmlDocument.roots.forEach(function (root) { return addNodeDataAttributes(root); });
Object.keys(dataAttributes).forEach(function (attr) { return result.items.push({
label: attr,
kind: vscode_languageserver_types_1.CompletionItemKind.Value,
textEdit: vscode_languageserver_types_1.TextEdit.replace(range, attr + '=""'),
insertTextFormat: vscode_languageserver_types_1.InsertTextFormat.Snippet
}); });
}
}
function collectAttributeValueSuggestions(valueStart, valueEnd) {

@@ -171,0 +207,0 @@ if (valueEnd === void 0) { valueEnd = offset; }

@@ -7,3 +7,3 @@ (function (factory) {

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "../parser/htmlScanner", "vscode-languageserver-types", "vscode-uri"], factory);
define(["require", "exports", "../parser/htmlScanner", "vscode-languageserver-types", "../utils/strings", "vscode-uri"], factory);
}

@@ -19,2 +19,3 @@ })(function (require, exports) {

var vscode_languageserver_types_1 = require("vscode-languageserver-types");
var strings = require("../utils/strings");
var vscode_uri_1 = require("vscode-uri");

@@ -49,3 +50,3 @@ function normalizeRef(url, languageId) {

}
function getWorkspaceUrl(modelAbsoluteUri, tokenContent, documentContext, base) {
function getWorkspaceUrl(documentUri, tokenContent, documentContext, base) {
if (/^\s*javascript\:/i.test(tokenContent) || /^\s*\#/i.test(tokenContent) || /[\n\r]/.test(tokenContent)) {

@@ -61,10 +62,7 @@ return null;

// Absolute link (that does not name the protocol)
var pickedScheme = 'http';
if (modelAbsoluteUri.scheme === 'https') {
pickedScheme = 'https';
}
var pickedScheme = strings.startsWith(documentUri, 'https://') ? 'https' : 'http';
return pickedScheme + ':' + tokenContent.replace(/^\s*/g, '');
}
if (documentContext) {
return documentContext.resolveReference(tokenContent, base);
return documentContext.resolveReference(tokenContent, base || documentUri);
}

@@ -74,3 +72,2 @@ return tokenContent;

function createLink(document, documentContext, attributeValue, startOffset, endOffset, base) {
var documentUri = vscode_uri_1.default.parse(document.uri);
var tokenContent = normalizeRef(attributeValue, document.languageId);

@@ -84,3 +81,3 @@ if (!validateRef(tokenContent, document.languageId)) {

}
var workspaceUrl = getWorkspaceUrl(documentUri, tokenContent, documentContext, base);
var workspaceUrl = getWorkspaceUrl(document.uri, tokenContent, documentContext, base);
if (!workspaceUrl || !isValidURI(workspaceUrl)) {

@@ -87,0 +84,0 @@ return null;

{
"name": "vscode-html-languageservice",
"version": "2.0.13",
"version": "2.0.14",
"description": "Language service for HTML",

@@ -5,0 +5,0 @@ "main": "./lib/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