@imwz/wp-pattern-sentinel 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/validation.js +11 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imwz/wp-pattern-sentinel",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Browser-based WordPress block pattern validator using Playwright",
5
5
  "type": "module",
6
6
  "engines": {
package/src/validation.js CHANGED
@@ -76,9 +76,19 @@ const normalizeBlockAttrJson = str => {
76
76
  });
77
77
  };
78
78
 
79
+ /**
80
+ * Collapse whitespace (including newlines) between adjacent tags/comments to
81
+ * nothing. Custom blocks that render their wrapper markup via JSX (e.g.
82
+ * `<div><div className="inner">...`) serialize with zero whitespace between
83
+ * elements, while hand-authored pattern PHP conventionally puts each nested
84
+ * element on its own line for readability. That's insignificant whitespace —
85
+ * browsers treat it identically — so it must not produce a content_mismatch.
86
+ */
87
+ const collapseInterTagWhitespace = str => str.replace(/>\s+</g, '><');
88
+
79
89
  /** Apply all WordPress serializer normalizations to both sides before diffing. */
80
90
  const normalizeForComparison = str =>
81
- normalizeBlockAttrJson(normalizeCssProps(stripNavRef(str)));
91
+ collapseInterTagWhitespace(normalizeBlockAttrJson(normalizeCssProps(stripNavRef(str))));
82
92
 
83
93
  /**
84
94
  * Compare the editor's serialized output against the original source.