html-validate 10.16.0 → 10.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/core.js CHANGED
@@ -8981,6 +8981,55 @@ class NoTrailingWhitespace extends Rule {
8981
8981
  }
8982
8982
  }
8983
8983
 
8984
+ const skipPatterns = [
8985
+ /^data-/i,
8986
+ /^aria-/i,
8987
+ /^on[a-z]/i,
8988
+ /^xml(ns)?:/i,
8989
+ /^:/,
8990
+ /^@/,
8991
+ /^ng-/i,
8992
+ /^v-/i,
8993
+ /^x-/i,
8994
+ /^\[/
8995
+ ];
8996
+ function isKnownDynamicAttr(attr) {
8997
+ return skipPatterns.some((pattern) => pattern.test(attr));
8998
+ }
8999
+ class NoUnknownAttributes extends Rule {
9000
+ documentation(context) {
9001
+ return {
9002
+ description: `The \`${context.attr}\` attribute is not a known attribute on \`<${context.tagName}>\`.`,
9003
+ url: "https://html-validate.org/rules/no-unknown-attributes.html"
9004
+ };
9005
+ }
9006
+ setup() {
9007
+ this.on("attr", (event) => {
9008
+ const node = event.target;
9009
+ const meta = node.meta;
9010
+ const attr = event.key.toLowerCase();
9011
+ if (meta === null) {
9012
+ return;
9013
+ }
9014
+ if (attr in meta.attributes) {
9015
+ return;
9016
+ }
9017
+ if (isKnownDynamicAttr(attr)) {
9018
+ return;
9019
+ }
9020
+ this.report({
9021
+ node,
9022
+ message: `Attribute "${event.key}" is not allowed on <${node.tagName}> element`,
9023
+ location: event.keyLocation,
9024
+ context: {
9025
+ tagName: node.tagName,
9026
+ attr: event.key
9027
+ }
9028
+ });
9029
+ });
9030
+ }
9031
+ }
9032
+
8984
9033
  const defaults$b = {
8985
9034
  include: null,
8986
9035
  exclude: null
@@ -11288,6 +11337,7 @@ const bundledRules = {
11288
11337
  "no-self-closing": NoSelfClosing,
11289
11338
  "no-style-tag": NoStyleTag,
11290
11339
  "no-trailing-whitespace": NoTrailingWhitespace,
11340
+ "no-unknown-attributes": NoUnknownAttributes,
11291
11341
  "no-unknown-elements": NoUnknownElements,
11292
11342
  "no-unused-disable": NoUnusedDisable,
11293
11343
  "no-utf8-bom": NoUtf8Bom,
@@ -12602,7 +12652,7 @@ class EventHandler {
12602
12652
  }
12603
12653
 
12604
12654
  const name = "html-validate";
12605
- const version = "10.16.0";
12655
+ const version = "10.17.0";
12606
12656
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
12607
12657
 
12608
12658
  function freeze(src) {