html-validate 6.1.6 → 6.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # html-validate changelog
2
2
 
3
+ ## [6.2.0](https://gitlab.com/html-validate/html-validate/compare/v6.1.6...v6.2.0) (2022-01-17)
4
+
5
+ ### Features
6
+
7
+ - expose `isTextNode()` ([502ef09](https://gitlab.com/html-validate/html-validate/commit/502ef09a820550ef66d12c2a3ccb1044ccc6c0b9))
8
+
9
+ ### Bug Fixes
10
+
11
+ - **rules:** improve error message for `attribute-allowed-values` ([b3d4d11](https://gitlab.com/html-validate/html-validate/commit/b3d4d119614c6804a782242fd6dd5717306cd0a3))
12
+
3
13
  ### [6.1.6](https://gitlab.com/html-validate/html-validate/compare/v6.1.5...v6.1.6) (2022-01-07)
4
14
 
5
15
  ### Bug Fixes
package/dist/cjs/core.js CHANGED
@@ -1783,6 +1783,14 @@ class Selector {
1783
1783
  }
1784
1784
 
1785
1785
  const TEXT_NODE_NAME = "#text";
1786
+ /**
1787
+ * Returns true if the node is a text node.
1788
+ *
1789
+ * @public
1790
+ */
1791
+ function isTextNode(node) {
1792
+ return Boolean(node && node.nodeType === NodeType.TEXT_NODE);
1793
+ }
1786
1794
  /**
1787
1795
  * Represents a text in the HTML document.
1788
1796
  *
@@ -2939,7 +2947,7 @@ var TRANSFORMER_API;
2939
2947
  /** @public */
2940
2948
  const name = "html-validate";
2941
2949
  /** @public */
2942
- const version = "6.1.6";
2950
+ const version = "6.2.0";
2943
2951
  /** @public */
2944
2952
  const homepage = "https://html-validate.org";
2945
2953
  /** @public */
@@ -4085,12 +4093,26 @@ class AttributeAllowedValues extends Rule {
4085
4093
  if (!context) {
4086
4094
  return docs;
4087
4095
  }
4088
- if (context.allowed.enum) {
4089
- const allowed = context.allowed.enum.map((val) => `- \`${val}\``);
4090
- docs.description = `Element <${context.element}> does not allow attribute \`${context.attribute}\` to have the value \`"${context.value}"\`, it must match one of the following:\n\n${allowed.join("\n")}`;
4096
+ const { allowed, attribute, element, value } = context;
4097
+ if (allowed.enum) {
4098
+ const allowedList = allowed.enum.map((value) => {
4099
+ if (typeof value === "string") {
4100
+ return `- \`"${value}"\``;
4101
+ }
4102
+ else {
4103
+ return `- \`${value.toString()}\``;
4104
+ }
4105
+ });
4106
+ docs.description = [
4107
+ `The \`<${element}>\` element does not allow the attribute \`${attribute}\` to have the value \`"${value}"\`.`,
4108
+ "",
4109
+ "It must match one of the following:",
4110
+ "",
4111
+ ...allowedList,
4112
+ ].join("\n");
4091
4113
  }
4092
- else if (context.allowed.boolean) {
4093
- docs.description = `Element <${context.element}> attribute \`${context.attribute}\` must be a boolean attribute, e.g. \`<${context.element} ${context.attribute}>\``;
4114
+ else if (allowed.boolean) {
4115
+ docs.description = `The \`<${context.element}>\` attribute \`${context.attribute}\` must be a boolean attribute, e.g. \`<${context.element} ${context.attribute}>\``;
4094
4116
  }
4095
4117
  return docs;
4096
4118
  }
@@ -7067,9 +7089,6 @@ function hasDefaultText(node) {
7067
7089
  const type = node.getAttribute("type");
7068
7090
  return Boolean(type && type.valueMatches(/submit|reset/, false));
7069
7091
  }
7070
- function isTextNode(node) {
7071
- return node.nodeType === NodeType.TEXT_NODE;
7072
- }
7073
7092
  function isNonEmptyText(node) {
7074
7093
  if (isTextNode(node)) {
7075
7094
  return node.isDynamic || node.textContent.trim() !== "";