@litejs/dom 23.12.1 → 24.6.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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dom.js +12 -2
  3. package/package.json +4 -3
package/README.md CHANGED
@@ -63,7 +63,7 @@ Follow [Coding Style Guide](https://github.com/litejs/litejs/wiki/Style-Guide),
63
63
  run tests `npm install; npm test`.
64
64
 
65
65
 
66
- > Copyright (c) 2014-2023 Lauri Rooden <lauri@rooden.ee>
66
+ > Copyright (c) 2014-2024 Lauri Rooden <lauri@rooden.ee>
67
67
  [MIT License](https://litejs.com/MIT-LICENSE.txt) |
68
68
  [GitHub repo](https://github.com/litejs/dom) |
69
69
  [npm package](https://npmjs.org/package/@litejs/dom) |
package/dom.js CHANGED
@@ -83,6 +83,7 @@ var boolAttrs = {
83
83
  if ((re = rawTextElements[child.tagName])) {
84
84
  for (text = ""; (m = tagRe.exec(html)) && !re.test(m[0]); text += m[3] || m[0]);
85
85
  child.textContent = text.replace(unescRe, unescFn)
86
+ if (!m) break
86
87
  } else if (!voidElements[child.tagName] && !m[8]) tree = child
87
88
  } else {
88
89
  tree.appendChild(
@@ -182,9 +183,9 @@ var boolAttrs = {
182
183
  return selector.find(this, sel)
183
184
  },
184
185
  toString: function(minify) {
185
- return rawTextElements[this.tagName] ? this.textContent : this.hasChildNodes() ? this.childNodes.reduce(function(memo, node) {
186
+ return rawTextElements[this.tagName] ? this.textContent : this.childNodes.reduce(function(memo, node) {
186
187
  return memo + node.toString(minify)
187
- }, "") : ""
188
+ }, "")
188
189
  }
189
190
  }
190
191
  , Element = {
@@ -315,6 +316,7 @@ NamedNodeMap.prototype = {
315
316
  if (!isXml) {
316
317
  if (hasOwn.call(boolAttrs, loName)) return name
317
318
  if (minify) {
319
+ value = loName.slice(0, 2) === "on" ? value.replace(/^[\s\uFEFF\xA0;]+|[\s\uFEFF\xA0;]+$/g, "") : value.replace(/\s+/g, " ").trim()
318
320
  if (hasOwn.call(defaultAttrs, (tagName + " " + name + " " + value).toLowerCase())) return
319
321
  if (!quotedAttrRe.test(value)) return name + "=" + value
320
322
  if (value.split("\"").length > value.split("'").length) return name + "='" + value.replace(/'/g, "'") + "'"
@@ -430,6 +432,14 @@ function Document() {
430
432
  }
431
433
 
432
434
  extendNode(Document, Element, {
435
+ get title() {
436
+ var el = selector.find(this, "title", 1)
437
+ return el && el.textContent || ""
438
+ },
439
+ set title(text) {
440
+ var el = selector.find(this, "title", 1) || this.appendChild(this.createElement("title"))
441
+ el.textContent = text
442
+ },
433
443
  nodeType: 9,
434
444
  nodeName: "#document",
435
445
  contentType: "text/html",
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@litejs/dom",
3
- "version": "23.12.1",
3
+ "version": "24.6.0",
4
4
  "description": "A small DOM library for server-side testing, rendering, and handling of HTML files",
5
5
  "license": "MIT",
6
6
  "author": "Lauri Rooden <lauri@rooden.ee>",
7
7
  "keywords": [
8
8
  "document",
9
9
  "dom",
10
+ "html",
10
11
  "DOMParser",
11
12
  "XMLHttpRequest",
12
13
  "XMLSerializer",
@@ -17,8 +18,8 @@
17
18
  "*.js"
18
19
  ],
19
20
  "scripts": {
20
- "test": "lj test --coverage --brief test/index.js && node --import=@litejs/cli/test.js test/run.mjs && jshint --config .github/jshint.json *.js",
21
- "test-fast": "lj test --brief test/index.js"
21
+ "lint": "jshint --config .github/jshint.json *.js",
22
+ "test": "lj t test/index.js"
22
23
  },
23
24
  "repository": "github:litejs/dom",
24
25
  "devDependencies": {