diff --git a/src/htmlCanvas.js b/src/htmlCanvas.js index fdbfaa9..f142e68 100644 --- a/src/htmlCanvas.js +++ b/src/htmlCanvas.js @@ -268,10 +268,10 @@ Array.prototype.appendToBrush = function (brush) { * @param {string|HTMLElement} child */ TagBrushConstructor.prototype.appendChild = function (child) { - if (this.element.canHaveChildren !== false) { - this.element.appendChild(child); - } else { + if (this.element.canHaveChildren === false) { this.element.text = this.element.text + child.innerHTML; + } else { + this.element.appendChild(child); } }; @@ -343,8 +343,8 @@ TagBrushConstructor.prototype.getElement = function (object) { */ TagBrushConstructor.prototype.render = function () { let args = Array.prototype.slice.call(arguments); - for (let i = 0; i < args.length; i++) { - this.append(args[i]); + for (const arg of args) { + this.append(arg); } return this; }; diff --git a/src/router/hashLocation.js b/src/router/hashLocation.js index e52b2a4..a2ddbe8 100644 --- a/src/router/hashLocation.js +++ b/src/router/hashLocation.js @@ -154,7 +154,7 @@ const hashLocation = object.subclass((that, my) => { function urlFromHash(aHash) { // Remove hash/hash-bang and any leading / - return url({ rawUrl: aHash.replace(/^#!?[/]?/, "") }); + return url({ rawUrl: aHash.replace(/^#!?\/?/, "") }); } function setCurrentHash(newHash) { diff --git a/src/router/routeFactory.js b/src/router/routeFactory.js index 1ad4ea7..4f43b1c 100644 --- a/src/router/routeFactory.js +++ b/src/router/routeFactory.js @@ -52,8 +52,7 @@ function segmentFactory(segmentString, options) { let segments = abstractSegment.allSubclasses(); // Find segment type from string - for (let i = 0; i < segments.length; i++) { - let segment = segments[i]; + for (let segment of segments) { if (segment.match(segmentString)) { return segment({ segmentString, diff --git a/src/router/router.js b/src/router/router.js index 34fc2e4..865864e 100755 --- a/src/router/router.js +++ b/src/router/router.js @@ -443,9 +443,9 @@ const router = object.subclass((that, my) => { } // Merge current parameters with supplied parameters - let currentParameters = !excludeCurrentParameters - ? that.getParameters() - : {}; + let currentParameters = excludeCurrentParameters + ? {} + : that.getParameters(); let allParameters = merge(currentParameters, suppliedParameters); // Fill with defaults if needed diff --git a/src/router/url.js b/src/router/url.js index 34f80f1..128f95c 100644 --- a/src/router/url.js +++ b/src/router/url.js @@ -93,11 +93,7 @@ const url = object.subclass((that, my) => { * @returns {url} */ url.build = function (path, query) { - if ( - typeof path === "undefined" || - path === null || - typeof path !== "string" - ) { + if (path === undefined || path === null || typeof path !== "string") { throw "accepts only string paths"; } diff --git a/src/test/htmlCanvasTest.js b/src/test/htmlCanvasTest.js index 6eb27e2..25f1646 100644 --- a/src/test/htmlCanvasTest.js +++ b/src/test/htmlCanvasTest.js @@ -467,7 +467,7 @@ describe("htmlCanvas", () => { it("can render almost everything", () => { withCanvas((html) => { html.render(0); // toString() - html.render(3.14159265359); // toString() + html.render(3.141_592_653_59); // toString() html.render("
test
"); // => DIV element html.render({}); // as attributes but since it have no keys => nothing html.render([]); // as array but since empty => nothing diff --git a/webpack.aliases.js b/webpack.aliases.js index c91d716..b046ad2 100644 --- a/webpack.aliases.js +++ b/webpack.aliases.js @@ -1,4 +1,4 @@ -const path = require("path"); +const path = require("node:path"); module.exports = { klassified: path.resolve( diff --git a/webpack.base.config.js b/webpack.base.config.js index 96f832a..bc9eb7e 100644 --- a/webpack.base.config.js +++ b/webpack.base.config.js @@ -1,4 +1,4 @@ -const path = require("path"); +const path = require("node:path"); const webpack = require("webpack"); const aliases = require("./webpack.aliases.js");