@cocreate/server-side-render 1.14.0 → 1.14.1

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,3 +1,11 @@
1
+ ## [1.14.1](https://github.com/CoCreate-app/CoCreate-server-side-render/compare/v1.14.0...v1.14.1) (2026-07-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump dependencies ([822bbc8](https://github.com/CoCreate-app/CoCreate-server-side-render/commit/822bbc8944b8782a69bff4e10ae0cb3fb2b02245))
7
+ * update dependencies for improved compatibility and performance ([db6db94](https://github.com/CoCreate-app/CoCreate-server-side-render/commit/db6db94096338ab6a4daf58569549cdac4623d38))
8
+
1
9
  # [1.14.0](https://github.com/CoCreate-app/CoCreate-server-side-render/compare/v1.13.0...v1.14.0) (2026-07-17)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/server-side-render",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "description": "A simple server-side-render component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "server-side-render",
@@ -16,9 +16,9 @@
16
16
  "access": "public"
17
17
  },
18
18
  "scripts": {
19
- "start": "npx webpack --config webpack.config.js",
20
- "build": "npx webpack --mode=production --config webpack.config.js",
21
- "dev": "npx webpack --config webpack.config.js --watch"
19
+ "start": "webpack --config webpack.config.js",
20
+ "build": "webpack --mode=production --config webpack.config.js",
21
+ "dev": "webpack --config webpack.config.js --watch"
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",
@@ -37,7 +37,7 @@
37
37
  "type": "module",
38
38
  "main": "./src/index.js",
39
39
  "dependencies": {
40
- "@cocreate/utils": "^1.39.0",
41
- "node-html-parser": "^6.1.12"
40
+ "@cocreate/utils": "^1.44.0",
41
+ "node-html-parser": "^9.0.0"
42
42
  }
43
43
  }
package/src/index.js CHANGED
@@ -17,7 +17,7 @@ const RENDER_SELECTOR = "[array], [src]:not(script, img, iframe, audio, video, s
17
17
  /**
18
18
  * Main functional entry point for Server-Side Rendering.
19
19
  * Completely stateless—all required dependencies are passed directly as arguments.
20
- * * @param {Object} options
20
+ * @param {Object} options
21
21
  * @param {Object} options.file - The template file object containing source markup
22
22
  * @param {Object} options.organization - Organization configuration data
23
23
  * @param {Object} options.urlObject - Request URL parsed object
@@ -54,7 +54,7 @@ export async function HTML({
54
54
  // Core Render Function (placed at the top for prominence)
55
55
  async function render(currentDom, lastKey) {
56
56
  // Find target elements and filter out nested targets to prevent redundant querying
57
- const elements = currentDom.querySelectorAll(RENDER_SELECTOR)
57
+ const elements = currentDom.querySelectorAll(RENDER_SELECTOR);
58
58
 
59
59
  for (let el of elements) {
60
60
  let isData = el.hasAttribute("array");
@@ -65,7 +65,8 @@ export async function HTML({
65
65
  // 1. Process File Source (Takes priority over Data Source)
66
66
  if (isSrc) {
67
67
  let src = el.getAttribute("src");
68
- if (src) {
68
+ // Explicitly check that src is a valid non-empty string (handling null in v9.x)
69
+ if (src && typeof src === "string") {
69
70
  let pathname = filePath;
70
71
  if (!pathname.endsWith("/")) pathname += "/";
71
72
 
@@ -212,23 +213,22 @@ export async function HTML({
212
213
  // Apply DOM mutations only after everything in this sub-tree branch is completely resolved
213
214
  if (chunkDom) {
214
215
  if (el.getAttribute("value-type") === "outerHTML") {
215
- if (chunkDom.childNodes?.length) {
216
- el.replaceWith(...chunkDom.childNodes);
216
+ // Create a static array copy of childNodes to prevent mutation index shifts during replacement
217
+ const childNodes = chunkDom.childNodes ? Array.from(chunkDom.childNodes) : [];
218
+ if (childNodes.length) {
219
+ el.replaceWith(...childNodes);
217
220
  } else {
218
221
  el.remove();
219
222
  }
220
223
  } else {
221
224
  el.setAttribute("rendered", "");
222
- el.innerHTML = "";
223
225
 
224
- // Use node-html-parser compatible appendChild loop
225
- if (chunkDom.childNodes) {
226
- for (const child of [...chunkDom.childNodes]) {
227
- el.appendChild(child);
228
- }
229
- } else {
230
- el.appendChild(chunkDom);
231
- }
226
+ // Use modern set_content native helper for v9.0.0 (safer and cleaner than manually appending nodes)
227
+ const contentToInject = chunkDom.childNodes && chunkDom.childNodes.length > 0
228
+ ? Array.from(chunkDom.childNodes)
229
+ : chunkDom;
230
+
231
+ el.set_content(contentToInject);
232
232
  }
233
233
  }
234
234
  }