@siteimprove/alfa-dom 0.93.1 → 0.93.6

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,5 +1,21 @@
1
1
  # @siteimprove/alfa-dom
2
2
 
3
+ ## 0.93.6
4
+
5
+ ## 0.93.5
6
+
7
+ ## 0.93.4
8
+
9
+ ## 0.93.3
10
+
11
+ ### Patch Changes
12
+
13
+ - **Changed:** `Node.from` and `Page.from` are now cached. ([#1703](https://github.com/Siteimprove/alfa/pull/1703))
14
+
15
+ This makes multiple de-serialisation inexpensive as long as the JSON object is not discarded, thus simplifying logic for callers.
16
+
17
+ ## 0.93.2
18
+
3
19
  ## 0.93.1
4
20
 
5
21
  ## 0.93.0
package/dist/node.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { Cache } from "@siteimprove/alfa-cache";
1
2
  import { Comparable, Comparison, } from "@siteimprove/alfa-comparable";
2
3
  import { Flags } from "@siteimprove/alfa-flags";
3
4
  import { Lazy } from "@siteimprove/alfa-lazy";
@@ -265,8 +266,14 @@ export class Node extends tree.Node {
265
266
  * nested browsing context container, a common use case.
266
267
  */
267
268
  Node.composedNested = Traversal.of(Traversal.composed, Traversal.nested);
269
+ const cacheWithDevice = Cache.empty();
270
+ const cacheWithoutDevice = Cache.empty();
268
271
  function from(json, device) {
269
- return fromNode(json, device).run();
272
+ return device === undefined
273
+ ? cacheWithoutDevice.get(json, () => fromNode(json, device).run())
274
+ : cacheWithDevice
275
+ .get(json, Cache.empty)
276
+ .get(device, () => fromNode(json, device).run());
270
277
  }
271
278
  Node.from = from;
272
279
  /**
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "http://json.schemastore.org/package",
3
3
  "name": "@siteimprove/alfa-dom",
4
4
  "homepage": "https://alfa.siteimprove.com",
5
- "version": "0.93.1",
5
+ "version": "0.93.6",
6
6
  "license": "MIT",
7
7
  "description": "Implementations of the core DOM and CSSOM node types",
8
8
  "repository": {
@@ -33,32 +33,32 @@
33
33
  "dist/**/*.d.ts"
34
34
  ],
35
35
  "dependencies": {
36
- "@siteimprove/alfa-array": "^0.93.1",
37
- "@siteimprove/alfa-cache": "^0.93.1",
38
- "@siteimprove/alfa-comparable": "^0.93.1",
39
- "@siteimprove/alfa-css": "^0.93.1",
40
- "@siteimprove/alfa-css-feature": "^0.93.1",
41
- "@siteimprove/alfa-device": "^0.93.1",
42
- "@siteimprove/alfa-earl": "^0.93.1",
43
- "@siteimprove/alfa-equatable": "^0.93.1",
44
- "@siteimprove/alfa-flags": "^0.93.1",
45
- "@siteimprove/alfa-iterable": "^0.93.1",
46
- "@siteimprove/alfa-json": "^0.93.1",
47
- "@siteimprove/alfa-lazy": "^0.93.1",
48
- "@siteimprove/alfa-map": "^0.93.1",
49
- "@siteimprove/alfa-option": "^0.93.1",
50
- "@siteimprove/alfa-predicate": "^0.93.1",
51
- "@siteimprove/alfa-rectangle": "^0.93.1",
52
- "@siteimprove/alfa-refinement": "^0.93.1",
53
- "@siteimprove/alfa-sarif": "^0.93.1",
54
- "@siteimprove/alfa-selective": "^0.93.1",
55
- "@siteimprove/alfa-sequence": "^0.93.1",
56
- "@siteimprove/alfa-string": "^0.93.1",
57
- "@siteimprove/alfa-trampoline": "^0.93.1",
58
- "@siteimprove/alfa-tree": "^0.93.1"
36
+ "@siteimprove/alfa-array": "^0.93.6",
37
+ "@siteimprove/alfa-cache": "^0.93.6",
38
+ "@siteimprove/alfa-comparable": "^0.93.6",
39
+ "@siteimprove/alfa-css": "^0.93.6",
40
+ "@siteimprove/alfa-css-feature": "^0.93.6",
41
+ "@siteimprove/alfa-device": "^0.93.6",
42
+ "@siteimprove/alfa-earl": "^0.93.6",
43
+ "@siteimprove/alfa-equatable": "^0.93.6",
44
+ "@siteimprove/alfa-flags": "^0.93.6",
45
+ "@siteimprove/alfa-iterable": "^0.93.6",
46
+ "@siteimprove/alfa-json": "^0.93.6",
47
+ "@siteimprove/alfa-lazy": "^0.93.6",
48
+ "@siteimprove/alfa-map": "^0.93.6",
49
+ "@siteimprove/alfa-option": "^0.93.6",
50
+ "@siteimprove/alfa-predicate": "^0.93.6",
51
+ "@siteimprove/alfa-rectangle": "^0.93.6",
52
+ "@siteimprove/alfa-refinement": "^0.93.6",
53
+ "@siteimprove/alfa-sarif": "^0.93.6",
54
+ "@siteimprove/alfa-selective": "^0.93.6",
55
+ "@siteimprove/alfa-sequence": "^0.93.6",
56
+ "@siteimprove/alfa-string": "^0.93.6",
57
+ "@siteimprove/alfa-trampoline": "^0.93.6",
58
+ "@siteimprove/alfa-tree": "^0.93.6"
59
59
  },
60
60
  "devDependencies": {
61
- "@siteimprove/alfa-test": "^0.93.1",
61
+ "@siteimprove/alfa-test": "^0.93.6",
62
62
  "@types/jsdom": "^21.1.6",
63
63
  "jsdom": "^25.0.0"
64
64
  },