@litejs/dom 23.11.0 → 23.12.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/README.md +1 -4
- package/index.js +10 -11
- package/net.js +15 -1
- package/package.json +2 -5
- package/selector.js +1 -2
package/README.md
CHANGED
|
@@ -67,13 +67,10 @@ and run tests.
|
|
|
67
67
|
`npm install; npm test`
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
Copyright (c) 2014-2023 Lauri Rooden <lauri@rooden.ee>
|
|
70
|
+
> Copyright (c) 2014-2023 Lauri Rooden <lauri@rooden.ee>
|
|
73
71
|
[MIT License](https://litejs.com/MIT-LICENSE.txt) |
|
|
74
72
|
[GitHub repo](https://github.com/litejs/dom) |
|
|
75
73
|
[npm package](https://npmjs.org/package/@litejs/dom) |
|
|
76
|
-
[coverage][2] |
|
|
77
74
|
[Buy Me A Tea][6]
|
|
78
75
|
|
|
79
76
|
|
package/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
3
2
|
/*! litejs.com/MIT-LICENSE.txt */
|
|
4
3
|
|
|
5
|
-
|
|
6
4
|
var boolAttrs = {
|
|
7
5
|
async:1, autoplay:1, loop:1, checked:1, defer:1, disabled:1, muted:1, multiple:1, nomodule:1, playsinline:1, readonly:1, required:1, selected:1
|
|
8
6
|
}
|
|
@@ -227,8 +225,8 @@ var boolAttrs = {
|
|
|
227
225
|
}
|
|
228
226
|
, quotedAttrRe = /[\s"'`=<>]/
|
|
229
227
|
, escRe = /<|&(?=[a-z#])/gi
|
|
230
|
-
, unescRe =
|
|
231
|
-
,
|
|
228
|
+
, unescRe = /&[a-z]{1,31};?|&#(x|)([\da-f]+);/ig
|
|
229
|
+
, entities = {
|
|
232
230
|
"&": "&", "'": "'", "¢": "¢", "©": "©", "¤": "¤",
|
|
233
231
|
"°": "°", "€": "€", ">": ">", "<": "<", " ": " ",
|
|
234
232
|
"±": "±", "£": "£", """: "\"", "®": "®",
|
|
@@ -260,7 +258,7 @@ function escFn(chr) {
|
|
|
260
258
|
}
|
|
261
259
|
|
|
262
260
|
function unescFn(ent, hex, num) {
|
|
263
|
-
return num ? String.fromCharCode(parseInt(num, hex === "" ? 10 : 16)) :
|
|
261
|
+
return num ? String.fromCharCode(parseInt(num, hex === "" ? 10 : 16)) : entities[ent] || ent
|
|
264
262
|
}
|
|
265
263
|
|
|
266
264
|
;["hasAttribute", "getAttribute", "setAttribute", "removeAttribute"].forEach(function(name) {
|
|
@@ -493,7 +491,7 @@ function getElement(childs, index, step, type) {
|
|
|
493
491
|
function getSibling(node, step, type) {
|
|
494
492
|
var silbings = node.parentNode && node.parentNode.childNodes
|
|
495
493
|
, index = silbings ? silbings.indexOf(node) : -1
|
|
496
|
-
return type > 0 ? getElement(silbings, index + step, step, type) : silbings[index + step] || null
|
|
494
|
+
return type > 0 ? getElement(silbings, index + step, step, type) : silbings && silbings[index + step] || null
|
|
497
495
|
}
|
|
498
496
|
|
|
499
497
|
function camelCase(str) {
|
|
@@ -505,11 +503,12 @@ function hyphenCase(str) {
|
|
|
505
503
|
}
|
|
506
504
|
|
|
507
505
|
exports.document = new Document()
|
|
508
|
-
exports.
|
|
509
|
-
exports.XMLSerializer = XMLSerializer
|
|
506
|
+
exports.entities = entities
|
|
510
507
|
exports.CSSStyleDeclaration = CSSStyleDeclaration
|
|
511
|
-
exports.
|
|
512
|
-
exports.HTMLElement = HTMLElement
|
|
513
|
-
exports.DocumentFragment = DocumentFragment
|
|
508
|
+
exports.DOMParser = DOMParser
|
|
514
509
|
exports.Document = Document
|
|
510
|
+
exports.DocumentFragment = DocumentFragment
|
|
511
|
+
exports.HTMLElement = HTMLElement
|
|
512
|
+
exports.Node = Node
|
|
513
|
+
exports.XMLSerializer = XMLSerializer
|
|
515
514
|
|
package/net.js
CHANGED
|
@@ -8,7 +8,13 @@ var DOM = require(".")
|
|
|
8
8
|
, parser = new DOM.DOMParser()
|
|
9
9
|
, dataUrlRe = /^([^;,]*?)(;[^,]+?|),(.*)$/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
XMLHttpRequest.defaultHeaders = {
|
|
12
|
+
accept: ["Accept", "*/*"]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function XMLHttpRequest() {
|
|
16
|
+
this._reqHeaders = Object.assign({}, XMLHttpRequest.defaultHeaders)
|
|
17
|
+
}
|
|
12
18
|
|
|
13
19
|
function setState(xhr, state) {
|
|
14
20
|
if (xhr.readyState !== state) {
|
|
@@ -51,6 +57,9 @@ XMLHttpRequest.prototype = {
|
|
|
51
57
|
var xhr = this
|
|
52
58
|
return xhr.readyState >= xhr.HEADERS_RECEIVED && xhr._headers[name.toLowerCase()] || null
|
|
53
59
|
},
|
|
60
|
+
setRequestHeader: function(name, value) {
|
|
61
|
+
this._reqHeaders[name.toLowerCase()] = [name, value]
|
|
62
|
+
},
|
|
54
63
|
abort: function() {
|
|
55
64
|
throw Error("XMLHttpRequest abort/reuse not implemented")
|
|
56
65
|
},
|
|
@@ -72,6 +81,11 @@ XMLHttpRequest.prototype = {
|
|
|
72
81
|
|
|
73
82
|
if (url.protocol === "http:" || url.protocol === "https:") {
|
|
74
83
|
url.method = xhr.method
|
|
84
|
+
url.headers = Object.keys(xhr._reqHeaders).reduce(function(result, key) {
|
|
85
|
+
var entrie = xhr._reqHeaders[key]
|
|
86
|
+
result[entrie[0]] = entrie[1]
|
|
87
|
+
return result
|
|
88
|
+
}, {})
|
|
75
89
|
require(url.protocol.slice(0, -1)).request(url, function(res) {
|
|
76
90
|
head(res.statusCode, res.statusMessage, res.headers)
|
|
77
91
|
res.on("data", fillBody)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litejs/dom",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.12.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>",
|
|
@@ -21,10 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"repository": "github:litejs/dom",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@litejs/cli": "23.
|
|
24
|
+
"@litejs/cli": "23.11.1",
|
|
25
25
|
"jshint": "2.13.6"
|
|
26
|
-
},
|
|
27
|
-
"litejs": {
|
|
28
|
-
"build": false
|
|
29
26
|
}
|
|
30
27
|
}
|
package/selector.js
CHANGED
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
return ""
|
|
70
70
|
})
|
|
71
71
|
|
|
72
|
-
if (tag && tag != "*") rules[0] += "&&_.tagName=='" + tag.toUpperCase() + "'"
|
|
72
|
+
if (tag && tag != "*") rules[0] += "&&_.tagName==(_.namespaceURI?'" + tag.toUpperCase() + "':'" + tag + "')"
|
|
73
73
|
if (parentSel) rules.push("(v='" + parentSel + "')", selectorMap[relation + relation])
|
|
74
74
|
return rules.join("&&")
|
|
75
75
|
}).join("||") + "}"
|
|
@@ -106,7 +106,6 @@
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
exports.find = find
|
|
109
|
-
exports.fn = selectorFn
|
|
110
109
|
exports.matches = matches
|
|
111
110
|
exports.next = next
|
|
112
111
|
exports.prev = prev
|