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

html-validate

Package Overview
Dependencies
Maintainers
1
Versions
275
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-validate - npm Package Compare versions

Comparing version 0.22.0 to 0.22.1

4

build/config/config.js

@@ -129,4 +129,4 @@ "use strict";

loadPlugins(plugins) {
return plugins.map((name) => {
return require(name);
return plugins.map((module) => {
return require(module.replace("<rootDir>", this.rootDir));
});

@@ -133,0 +133,0 @@ }

@@ -6,8 +6,12 @@ import { Location } from "../context";

}
export declare function reset(): void;
export declare class DOMNode {
readonly location: Location;
readonly nodeName: string;
readonly nodeType: NodeType;
readonly childNodes: DOMNode[];
readonly location: Location;
readonly unique: number;
private disabledRules;
constructor(nodeName: string, location?: Location);
append(node: DOMNode): void;
isRootElement(): boolean;

@@ -14,0 +18,0 @@ disableRule(ruleId: string): void;

@@ -9,2 +9,7 @@ "use strict";

})(NodeType = exports.NodeType || (exports.NodeType = {}));
let counter = 0;
function reset() {
counter = 0;
}
exports.reset = reset;
class DOMNode {

@@ -15,2 +20,4 @@ constructor(nodeName, location) {

this.disabledRules = new Set();
this.childNodes = [];
this.unique = counter++;
this.nodeType = NodeType.ELEMENT_NODE;

@@ -21,2 +28,5 @@ if (!nodeName) {

}
append(node) {
this.childNodes.push(node);
}
isRootElement() {

@@ -23,0 +33,0 @@ return this.nodeType === NodeType.DOCUMENT_NODE;

@@ -15,10 +15,7 @@ import { Location } from "../context";

}
export declare function reset(): void;
export declare class HtmlElement extends DOMNode {
readonly tagName: string;
readonly children: HtmlElement[];
readonly meta: MetaElement;
readonly parent: HtmlElement;
readonly voidElement: boolean;
readonly unique: number;
readonly depth: number;

@@ -32,2 +29,3 @@ closed: NodeClosed;

static fromTokens(startToken: Token, endToken: Token, parent: HtmlElement, metaTable: MetaTable): HtmlElement;
readonly childElements: HtmlElement[];
is(tagName: string): boolean;

@@ -40,3 +38,2 @@ setAttribute(key: string, value: string | DynamicValue, keyLocation: Location, valueLocation: Location, originalAttribute?: string): void;

getAttributeValue(key: string): string;
append(node: HtmlElement): void;
readonly classList: DOMTokenList;

@@ -43,0 +40,0 @@ readonly id: string;

@@ -16,7 +16,2 @@ "use strict";

})(NodeClosed = exports.NodeClosed || (exports.NodeClosed = {}));
let counter = 0;
function reset() {
counter = 0;
}
exports.reset = reset;
class HtmlElement extends domnode_1.DOMNode {

@@ -26,3 +21,2 @@ constructor(tagName, parent, closed = NodeClosed.EndTag, meta, location) {

this.tagName = tagName;
this.children = [];
this.parent = parent;

@@ -33,6 +27,5 @@ this.attr = {};

this.voidElement = this.meta ? this.meta.void : false;
this.unique = counter++;
this.depth = 0;
if (parent) {
parent.children.push(this);
parent.childNodes.push(this);
let cur = parent;

@@ -59,2 +52,5 @@ while (cur.parent) {

}
get childElements() {
return this.childNodes.filter(node => node.nodeType === domnode_1.NodeType.ELEMENT_NODE);
}
is(tagName) {

@@ -98,5 +94,2 @@ return (this.tagName && tagName === "*") || this.tagName === tagName;

}
append(node) {
this.children.push(node);
}
get classList() {

@@ -116,3 +109,3 @@ if (!this.hasAttribute("class")) {

get siblings() {
return this.parent.children;
return this.parent.childElements;
}

@@ -128,3 +121,3 @@ get previousSibling() {

getElementsByTagName(tagName) {
return this.children.reduce((matches, node) => {
return this.childElements.reduce((matches, node) => {
return matches.concat(node.is(tagName) ? [node] : [], node.getElementsByTagName(tagName));

@@ -150,3 +143,3 @@ }, []);

function visit(node) {
node.children.forEach(visit);
node.childElements.forEach(visit);
if (!node.isRootElement()) {

@@ -159,3 +152,3 @@ callback(node);

someChildren(callback) {
return this.children.some(visit);
return this.childElements.some(visit);
function visit(node) {

@@ -166,3 +159,3 @@ if (callback(node)) {

else {
return node.children.some(visit);
return node.childElements.some(visit);
}

@@ -172,3 +165,3 @@ }

everyChildren(callback) {
return this.children.every(visit);
return this.childElements.every(visit);
function visit(node) {

@@ -178,3 +171,3 @@ if (!callback(node)) {

}
return node.children.every(visit);
return node.childElements.every(visit);
}

@@ -187,3 +180,3 @@ }

}
for (const child of node.children) {
for (const child of node.childElements) {
const match = child.find(callback);

@@ -190,0 +183,0 @@ if (match) {

@@ -103,3 +103,3 @@ "use strict";

case combinator_1.Combinator.CHILD:
return root.children.filter(node => node.is(pattern.tagName));
return root.childElements.filter(node => node.is(pattern.tagName));
case combinator_1.Combinator.ADJACENT_SIBLING:

@@ -106,0 +106,0 @@ return Selector.findAdjacentSibling(root);

@@ -85,4 +85,4 @@ "use strict";

const indent = " ".repeat(level - 1);
const l = node.children.length > 0 ? "┬" : "─";
const b = sibling < node.parent.children.length - 1 ? "├" : "└";
const l = node.childElements.length > 0 ? "┬" : "─";
const b = sibling < node.parent.childElements.length - 1 ? "├" : "└";
lines.push(`${indent}${b}─${l} ${node.tagName}${decoration(node)}`);

@@ -93,3 +93,3 @@ }

}
node.children.forEach((child, index) => writeNode(child, level + 1, index));
node.childElements.forEach((child, index) => writeNode(child, level + 1, index));
}

@@ -96,0 +96,0 @@ writeNode(dom.root, 0, 0);

import { Location, Source } from "./context";
import { HtmlElement } from "./dom";
import { Rule } from "./rule";

@@ -31,3 +30,3 @@ export interface Message {

static merge(reports: Report[]): Report;
add(node: HtmlElement, rule: Rule, message: string, severity: number, location: Location, context?: any): void;
add(rule: Rule, message: string, severity: number, location: Location, context?: any): void;
addManual(filename: string, message: Message): void;

@@ -34,0 +33,0 @@ save(sources?: Source[]): Report;

@@ -24,3 +24,3 @@ "use strict";

}
add(node, rule, message, severity, location, context) {
add(rule, message, severity, location, context) {
if (!this.result.hasOwnProperty(location.filename)) {

@@ -27,0 +27,0 @@ this.result[location.filename] = [];

import { Location } from "./context";
import { HtmlElement } from "./dom";
import { DOMNode } from "./dom";
import { AttributeEvent, ConditionalEvent, DoctypeEvent, DOMReadyEvent, Event, TagCloseEvent, TagOpenEvent, WhitespaceEvent } from "./event";

@@ -27,3 +27,3 @@ import { Parser } from "./parser";

isEnabled(): boolean;
report(node: HtmlElement, message: string, location?: Location, context?: T): void;
report(node: DOMNode, message: string, location?: Location, context?: T): void;
private findLocation;

@@ -30,0 +30,0 @@ on(event: "tag:open", callback: (event: TagOpenEvent) => void): void;

@@ -26,3 +26,3 @@ "use strict";

const where = this.findLocation({ node, location, event: this.event });
this.reporter.add(node, this, message, this.severity, where, context);
this.reporter.add(this, message, this.severity, where, context);
}

@@ -29,0 +29,0 @@ }

@@ -35,3 +35,3 @@ "use strict";

if (cur.meta && cur.meta.transparent) {
cur.children.forEach((child) => {
cur.childElements.forEach((child) => {
this.validatePermittedContent(child, parent, rules);

@@ -38,0 +38,0 @@ });

@@ -21,3 +21,3 @@ "use strict";

const rules = parent.meta.permittedContent;
const siblings = parent.children.filter(cur => cur.tagName === node.tagName);
const siblings = parent.childElements.filter(cur => cur.tagName === node.tagName);
const first = node.unique === siblings[0].unique;

@@ -24,0 +24,0 @@ if (first) {

@@ -20,3 +20,3 @@ "use strict";

const rules = node.meta.permittedOrder;
meta_1.Validator.validateOrder(node.children, rules, (child, prev) => {
meta_1.Validator.validateOrder(node.childElements, rules, (child, prev) => {
this.report(child, `Element <${child.tagName}> must be used before <${prev.tagName}> in this context`);

@@ -23,0 +23,0 @@ });

@@ -17,2 +17,3 @@ "use strict";

super(Object.assign({}, defaults, options));
this.name = "WCAG/H37";
if (!Array.isArray(this.options.alias)) {

@@ -19,0 +20,0 @@ this.options.alias = [this.options.alias];

@@ -5,2 +5,17 @@ # html-validate changelog

## 0.22.1 (2019-02-25)
### Breaking change
- `.children` has been split and moved from `HtmlElement` to
`DOMNode`. `.childNodes` replaces the original `.children` but is now typed
`DOMNode[]` (and in a future release may contain other node types). A getter
`.nodeElements` can be used to access only `HtmlElement` from `.childNodes`
and is typed `HtmlElement[]`. If your rules use `.children` the
### Bugfixes
- `<rootDir>` is now respected when configuring plugins.
- fix cosmetic case of `wcag/h37` rule.
## 0.22.0 (2019-02-24)

@@ -7,0 +22,0 @@

{
"name": "html-validate",
"version": "0.22.0",
"version": "0.22.1",
"description": "html linter",

@@ -5,0 +5,0 @@ "keywords": [

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