@compas-oscd/open-scd 0.34.16 → 0.34.18
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/dist/WizardDivider.d.ts +8 -8
- package/dist/WizardDivider.js +26 -26
- package/dist/Wizarding.js +36 -36
- package/dist/Wizarding.js.map +1 -1
- package/dist/action-icon.d.ts +25 -25
- package/dist/action-icon.js +51 -51
- package/dist/action-pane.d.ts +25 -25
- package/dist/action-pane.js +86 -86
- package/dist/addons/Editor.d.ts +25 -25
- package/dist/addons/Editor.js +105 -105
- package/dist/addons/Editor.js.map +1 -1
- package/dist/addons/History.d.ts +86 -93
- package/dist/addons/History.js +301 -302
- package/dist/addons/History.js.map +1 -1
- package/dist/addons/Layout.d.ts +96 -96
- package/dist/addons/Layout.js +448 -448
- package/dist/addons/Layout.js.map +1 -1
- package/dist/addons/Settings.d.ts +68 -68
- package/dist/addons/Settings.js +272 -272
- package/dist/addons/Settings.js.map +1 -1
- package/dist/addons/Waiter.d.ts +14 -14
- package/dist/addons/Waiter.js +40 -40
- package/dist/addons/Waiter.js.map +1 -1
- package/dist/addons/Wizards.d.ts +15 -15
- package/dist/addons/Wizards.js +46 -46
- package/dist/addons/editor/edit-action-to-v1-converter.d.ts +3 -3
- package/dist/addons/editor/edit-action-to-v1-converter.js +95 -95
- package/dist/addons/editor/edit-action-to-v1-converter.js.map +1 -1
- package/dist/addons/editor/edit-v1-to-v2-converter.d.ts +2 -2
- package/dist/addons/editor/edit-v1-to-v2-converter.js +36 -36
- package/dist/addons/editor/edit-v1-to-v2-converter.js.map +1 -1
- package/dist/addons/history/get-log-text.d.ts +5 -5
- package/dist/addons/history/get-log-text.js +25 -25
- package/dist/addons/history/get-log-text.js.map +1 -1
- package/dist/addons/menu-tabs/menu-tabs.d.ts +22 -22
- package/dist/addons/menu-tabs/menu-tabs.js +59 -59
- package/dist/addons/plugin-manager/custom-plugin-dialog.d.ts +28 -28
- package/dist/addons/plugin-manager/custom-plugin-dialog.js +71 -71
- package/dist/addons/plugin-manager/plugin-manager.d.ts +20 -20
- package/dist/addons/plugin-manager/plugin-manager.js +77 -77
- package/dist/core/api/api.js +7 -0
- package/dist/core/api/api.js.map +1 -0
- package/dist/core/api/editor/subject.js +22 -0
- package/dist/core/api/editor/subject.js.map +1 -0
- package/dist/core/api/editor/xml-editor.js +82 -0
- package/dist/core/api/editor/xml-editor.js.map +1 -0
- package/dist/core/api/plugin-state-api.js +27 -0
- package/dist/core/api/plugin-state-api.js.map +1 -0
- package/dist/core/foundation/cyrb64.js +26 -0
- package/dist/core/foundation/cyrb64.js.map +1 -0
- package/dist/core/foundation/deprecated/edit-event.js +44 -0
- package/dist/core/foundation/deprecated/edit-event.js.map +1 -0
- package/dist/core/foundation/deprecated/editor.js +94 -0
- package/dist/core/foundation/deprecated/editor.js.map +1 -0
- package/dist/core/foundation/deprecated/history.js +17 -0
- package/dist/core/foundation/deprecated/history.js.map +1 -0
- package/dist/core/foundation/deprecated/open-event.js +9 -0
- package/dist/core/foundation/deprecated/open-event.js.map +1 -0
- package/dist/core/foundation/deprecated/settings.js +19 -0
- package/dist/core/foundation/deprecated/settings.js.map +1 -0
- package/dist/core/foundation/deprecated/validation.js +8 -0
- package/dist/core/foundation/deprecated/validation.js.map +1 -0
- package/dist/core/foundation/deprecated/waiter.js +12 -0
- package/dist/core/foundation/deprecated/waiter.js.map +1 -0
- package/dist/core/foundation/edit-completed-event.js +11 -0
- package/dist/core/foundation/edit-completed-event.js.map +1 -0
- package/dist/core/foundation/edit-event.js +8 -0
- package/dist/core/foundation/edit-event.js.map +1 -0
- package/dist/core/foundation/edit.js +31 -0
- package/dist/core/foundation/edit.js.map +1 -0
- package/dist/core/foundation/handle-edit.js +151 -0
- package/dist/core/foundation/handle-edit.js.map +1 -0
- package/dist/core/foundation/open-event.js +8 -0
- package/dist/core/foundation/open-event.js.map +1 -0
- package/dist/core/foundation/plugin.js +2 -0
- package/dist/core/foundation/plugin.js.map +1 -0
- package/dist/core/foundation.js +14 -0
- package/dist/core/foundation.js.map +1 -0
- package/dist/core/locales.js +21 -0
- package/dist/core/locales.js.map +1 -0
- package/dist/filtered-list.d.ts +27 -27
- package/dist/filtered-list.js +118 -118
- package/dist/finder-list.d.ts +37 -37
- package/dist/finder-list.js +153 -153
- package/dist/foundation/compare.d.ts +79 -79
- package/dist/foundation/compare.js +216 -216
- package/dist/foundation/dai.d.ts +30 -30
- package/dist/foundation/dai.js +126 -126
- package/dist/foundation/generators.d.ts +13 -13
- package/dist/foundation/generators.js +66 -66
- package/dist/foundation/ied.d.ts +22 -22
- package/dist/foundation/ied.js +83 -83
- package/dist/foundation/ied.js.map +1 -1
- package/dist/foundation/nsd.d.ts +4 -4
- package/dist/foundation/nsd.js +12 -12
- package/dist/foundation/nsdoc.d.ts +14 -14
- package/dist/foundation/nsdoc.js +178 -178
- package/dist/foundation/scl.d.ts +1 -1
- package/dist/foundation/scl.js +63 -63
- package/dist/foundation.d.ts +230 -230
- package/dist/foundation.js +1921 -1921
- package/dist/foundation.js.map +1 -1
- package/dist/icons/compare.d.ts +3 -3
- package/dist/icons/compare.js +4 -4
- package/dist/icons/icons.d.ts +41 -41
- package/dist/icons/icons.js +92 -92
- package/dist/icons/ied-icons.d.ts +3 -3
- package/dist/icons/ied-icons.js +4 -4
- package/dist/icons/lnode.d.ts +16 -16
- package/dist/icons/lnode.js +17 -17
- package/dist/open-scd.d.ts +131 -131
- package/dist/open-scd.js +438 -438
- package/dist/open-scd.js.map +1 -1
- package/dist/openscd/src/WizardDivider.js +37 -0
- package/dist/openscd/src/WizardDivider.js.map +1 -0
- package/dist/openscd/src/Wizarding.js +38 -0
- package/dist/openscd/src/Wizarding.js.map +1 -0
- package/dist/openscd/src/action-icon.js +220 -0
- package/dist/openscd/src/action-icon.js.map +1 -0
- package/dist/openscd/src/action-pane.js +176 -0
- package/dist/openscd/src/action-pane.js.map +1 -0
- package/dist/openscd/src/addons/Editor.js +106 -0
- package/dist/openscd/src/addons/Editor.js.map +1 -0
- package/dist/openscd/src/addons/History.js +490 -0
- package/dist/openscd/src/addons/History.js.map +1 -0
- package/dist/openscd/src/addons/Layout.js +619 -0
- package/dist/openscd/src/addons/Layout.js.map +1 -0
- package/dist/openscd/src/addons/Settings.js +465 -0
- package/dist/openscd/src/addons/Settings.js.map +1 -0
- package/dist/openscd/src/addons/Waiter.js +45 -0
- package/dist/openscd/src/addons/Waiter.js.map +1 -0
- package/dist/openscd/src/addons/Wizards.js +48 -0
- package/dist/openscd/src/addons/Wizards.js.map +1 -0
- package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js +96 -0
- package/dist/openscd/src/addons/editor/edit-action-to-v1-converter.js.map +1 -0
- package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js +37 -0
- package/dist/openscd/src/addons/editor/edit-v1-to-v2-converter.js.map +1 -0
- package/dist/openscd/src/addons/history/get-log-text.js +26 -0
- package/dist/openscd/src/addons/history/get-log-text.js.map +1 -0
- package/dist/openscd/src/addons/menu-tabs/menu-tabs.js +74 -0
- package/dist/openscd/src/addons/menu-tabs/menu-tabs.js.map +1 -0
- package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js +177 -0
- package/dist/openscd/src/addons/plugin-manager/custom-plugin-dialog.js.map +1 -0
- package/dist/openscd/src/addons/plugin-manager/plugin-manager.js +165 -0
- package/dist/openscd/src/addons/plugin-manager/plugin-manager.js.map +1 -0
- package/dist/openscd/src/filtered-list.js +168 -0
- package/dist/openscd/src/filtered-list.js.map +1 -0
- package/dist/openscd/src/finder-list.js +207 -0
- package/dist/openscd/src/finder-list.js.map +1 -0
- package/dist/openscd/src/foundation/compare.js +273 -0
- package/dist/openscd/src/foundation/compare.js.map +1 -0
- package/dist/openscd/src/foundation/dai.js +127 -0
- package/dist/openscd/src/foundation/dai.js.map +1 -0
- package/dist/openscd/src/foundation/generators.js +67 -0
- package/dist/openscd/src/foundation/generators.js.map +1 -0
- package/dist/openscd/src/foundation/ied.js +84 -0
- package/dist/openscd/src/foundation/ied.js.map +1 -0
- package/dist/openscd/src/foundation/nsd.js +13 -0
- package/dist/openscd/src/foundation/nsd.js.map +1 -0
- package/dist/openscd/src/foundation/nsdoc.js +180 -0
- package/dist/openscd/src/foundation/nsdoc.js.map +1 -0
- package/dist/openscd/src/foundation/scl.js +64 -0
- package/dist/openscd/src/foundation/scl.js.map +1 -0
- package/dist/openscd/src/foundation.js +1922 -0
- package/dist/openscd/src/foundation.js.map +1 -0
- package/dist/openscd/src/icons/compare.js +11 -0
- package/dist/openscd/src/icons/compare.js.map +1 -0
- package/dist/openscd/src/icons/icons.js +611 -0
- package/dist/openscd/src/icons/icons.js.map +1 -0
- package/dist/openscd/src/icons/ied-icons.js +11 -0
- package/dist/openscd/src/icons/ied-icons.js.map +1 -0
- package/dist/openscd/src/icons/lnode.js +50 -0
- package/dist/openscd/src/icons/lnode.js.map +1 -0
- package/dist/openscd/src/open-scd.js +483 -0
- package/dist/openscd/src/open-scd.js.map +1 -0
- package/dist/openscd/src/oscd-filter-button.js +89 -0
- package/dist/openscd/src/oscd-filter-button.js.map +1 -0
- package/dist/openscd/src/plain-compare-list.js +132 -0
- package/dist/openscd/src/plain-compare-list.js.map +1 -0
- package/dist/openscd/src/plugin-tag.js +23 -0
- package/dist/openscd/src/plugin-tag.js.map +1 -0
- package/dist/openscd/src/plugin.events.js +12 -0
- package/dist/openscd/src/plugin.events.js.map +1 -0
- package/dist/openscd/src/plugin.js +2 -0
- package/dist/openscd/src/plugin.js.map +1 -0
- package/dist/openscd/src/plugins.js +256 -0
- package/dist/openscd/src/plugins.js.map +1 -0
- package/dist/openscd/src/schemas.js +9325 -0
- package/dist/openscd/src/schemas.js.map +1 -0
- package/dist/openscd/src/themes.js +122 -0
- package/dist/openscd/src/themes.js.map +1 -0
- package/dist/openscd/src/translations/de.js +954 -0
- package/dist/openscd/src/translations/de.js.map +1 -0
- package/dist/openscd/src/translations/en.js +950 -0
- package/dist/openscd/src/translations/en.js.map +1 -0
- package/dist/openscd/src/translations/loader.js +10 -0
- package/dist/openscd/src/translations/loader.js.map +1 -0
- package/dist/openscd/src/wizard-checkbox.js +152 -0
- package/dist/openscd/src/wizard-checkbox.js.map +1 -0
- package/dist/openscd/src/wizard-dialog.js +374 -0
- package/dist/openscd/src/wizard-dialog.js.map +1 -0
- package/dist/openscd/src/wizard-select.js +115 -0
- package/dist/openscd/src/wizard-select.js.map +1 -0
- package/dist/openscd/src/wizard-textfield.js +191 -0
- package/dist/openscd/src/wizard-textfield.js.map +1 -0
- package/dist/openscd/src/wizards.js +196 -0
- package/dist/openscd/src/wizards.js.map +1 -0
- package/dist/oscd-filter-button.d.ts +27 -27
- package/dist/oscd-filter-button.js +59 -59
- package/dist/plain-compare-list.d.ts +36 -36
- package/dist/plain-compare-list.js +70 -70
- package/dist/plugin-tag.d.ts +6 -6
- package/dist/plugin-tag.js +22 -22
- package/dist/plugin.d.ts +23 -23
- package/dist/plugin.events.d.ts +15 -15
- package/dist/plugin.events.js +11 -11
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +255 -255
- package/dist/schemas.d.ts +58 -58
- package/dist/schemas.js +59 -59
- package/dist/themes.d.ts +3 -3
- package/dist/themes.js +13 -13
- package/dist/themes.js.map +1 -1
- package/dist/translations/de.d.ts +2 -2
- package/dist/translations/de.js +952 -952
- package/dist/translations/en.d.ts +963 -963
- package/dist/translations/en.js +948 -948
- package/dist/translations/loader.d.ts +12 -12
- package/dist/translations/loader.js +9 -9
- package/dist/translations/loader.js.map +1 -1
- package/dist/wizard-checkbox.d.ts +37 -37
- package/dist/wizard-checkbox.js +130 -130
- package/dist/wizard-dialog.d.ts +45 -45
- package/dist/wizard-dialog.js +235 -235
- package/dist/wizard-dialog.js.map +1 -1
- package/dist/wizard-select.d.ts +31 -31
- package/dist/wizard-select.js +102 -102
- package/dist/wizard-textfield.d.ts +50 -50
- package/dist/wizard-textfield.js +162 -162
- package/dist/wizards.d.ts +23 -23
- package/dist/wizards.js +148 -148
- package/dist/wizards.js.map +1 -1
- package/dist/xml/src/foundation.js +67 -0
- package/dist/xml/src/foundation.js.map +1 -0
- package/dist/xml/src/index.js +2 -0
- package/dist/xml/src/index.js.map +1 -0
- package/package.json +29 -127
- package/dist/Wizarding.d.ts +0 -10
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit-element';
|
|
2
|
-
import '@material/mwc-list';
|
|
3
|
-
import '@material/mwc-list/mwc-list-item';
|
|
4
|
-
import '@material/mwc-icon';
|
|
5
|
-
export type DiffType = 'Element' | 'Attribute' | 'Content';
|
|
6
|
-
export type Diff<T> = {
|
|
7
|
-
type: DiffType;
|
|
8
|
-
oldValue: T;
|
|
9
|
-
newValue: null;
|
|
10
|
-
} | {
|
|
11
|
-
type: DiffType;
|
|
12
|
-
oldValue: null;
|
|
13
|
-
newValue: T;
|
|
14
|
-
} | {
|
|
15
|
-
type: DiffType;
|
|
16
|
-
oldValue: T;
|
|
17
|
-
newValue: T;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Type to filter out a difference based on `tagName`.`attributeName`
|
|
21
|
-
*
|
|
22
|
-
* The matcher can be a boolean or a `consumer` that returns a boolean
|
|
23
|
-
*/
|
|
24
|
-
export interface DiffFilter<T> {
|
|
25
|
-
[selector: string]: DiffFilterSelector<T>;
|
|
26
|
-
}
|
|
27
|
-
interface DiffFilterSelector<T> {
|
|
28
|
-
full?: DiffFilterConsumer<T>;
|
|
29
|
-
attributes?: {
|
|
30
|
-
[name: string]: DiffFilterConsumer<T>;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Consumer to match if a diff should be filtered out.
|
|
35
|
-
*/
|
|
36
|
-
type DiffFilterConsumer<T> = boolean | ((value: T | null) => boolean);
|
|
37
|
-
/**
|
|
38
|
-
* Check if there are any attribute values changed between the two elements.
|
|
39
|
-
*
|
|
40
|
-
* @param elementToBeCompared - The element to check for differences.
|
|
41
|
-
* @param elementToCompareAgainst - The element used to check against.
|
|
42
|
-
*/
|
|
43
|
-
export declare function diffSclAttributes(elementToBeCompared: Element, elementToCompareAgainst: Element, filterToIgnore: DiffFilter<Element>, searchElementToBeCompared: Element): [string, Diff<string>][];
|
|
44
|
-
/**
|
|
45
|
-
* Function to retrieve the identity to compare 2 children on the same level.
|
|
46
|
-
* This means we only need to last part of the Identity string to compare the children.
|
|
47
|
-
*
|
|
48
|
-
* @param element - The element to retrieve the identity from.
|
|
49
|
-
*/
|
|
50
|
-
export declare function identityForCompare(element: Element): string | number;
|
|
51
|
-
/**
|
|
52
|
-
* Custom method for comparing to check if 2 elements are the same. Because they are on the same level
|
|
53
|
-
* we don't need to compare the full identity, we just compare the part of the Element itself.
|
|
54
|
-
*
|
|
55
|
-
* <b>Remark</b>Private elements are already filtered out, so we don't need to bother them.
|
|
56
|
-
*
|
|
57
|
-
* @param newValue - The new element to compare with the old element.
|
|
58
|
-
* @param oldValue - The old element to which the new element is compared.
|
|
59
|
-
*/
|
|
60
|
-
export declare function isSame(newValue: Element, oldValue: Element): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* List of all differences between children elements that both old and new element have.
|
|
63
|
-
* The list contains children both elements have and children that were added or removed
|
|
64
|
-
* from the new element.
|
|
65
|
-
* <b>Remark</b>: Private elements are ignored.
|
|
66
|
-
*
|
|
67
|
-
* @param elementToBeCompared - The element to check for differences.
|
|
68
|
-
* @param elementToCompareAgainst - The element used to check against.
|
|
69
|
-
*/
|
|
70
|
-
export declare function diffSclChilds(elementToBeCompared: Element, elementToCompareAgainst: Element, filterToIgnore: DiffFilter<Element>, searchElementToBeCompared: Element, searchElementToCompareAgainst: Element): Diff<Element>[];
|
|
71
|
-
/**
|
|
72
|
-
* Generate HTML (TemplateResult) containing all the differences between the two elements passed.
|
|
73
|
-
* If null is returned there are no differences between the two elements.
|
|
74
|
-
*
|
|
75
|
-
* @param elementToBeCompared - The element to check for differences.
|
|
76
|
-
* @param elementToCompareAgainst - The element used to check against.
|
|
77
|
-
*/
|
|
78
|
-
export declare function renderDiff(elementToBeCompared: Element, elementToCompareAgainst: Element, filterToIgnore?: DiffFilter<Element>): TemplateResult | null;
|
|
79
|
-
export {};
|
|
1
|
+
import { TemplateResult } from 'lit-element';
|
|
2
|
+
import '@material/mwc-list';
|
|
3
|
+
import '@material/mwc-list/mwc-list-item';
|
|
4
|
+
import '@material/mwc-icon';
|
|
5
|
+
export type DiffType = 'Element' | 'Attribute' | 'Content';
|
|
6
|
+
export type Diff<T> = {
|
|
7
|
+
type: DiffType;
|
|
8
|
+
oldValue: T;
|
|
9
|
+
newValue: null;
|
|
10
|
+
} | {
|
|
11
|
+
type: DiffType;
|
|
12
|
+
oldValue: null;
|
|
13
|
+
newValue: T;
|
|
14
|
+
} | {
|
|
15
|
+
type: DiffType;
|
|
16
|
+
oldValue: T;
|
|
17
|
+
newValue: T;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Type to filter out a difference based on `tagName`.`attributeName`
|
|
21
|
+
*
|
|
22
|
+
* The matcher can be a boolean or a `consumer` that returns a boolean
|
|
23
|
+
*/
|
|
24
|
+
export interface DiffFilter<T> {
|
|
25
|
+
[selector: string]: DiffFilterSelector<T>;
|
|
26
|
+
}
|
|
27
|
+
interface DiffFilterSelector<T> {
|
|
28
|
+
full?: DiffFilterConsumer<T>;
|
|
29
|
+
attributes?: {
|
|
30
|
+
[name: string]: DiffFilterConsumer<T>;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Consumer to match if a diff should be filtered out.
|
|
35
|
+
*/
|
|
36
|
+
type DiffFilterConsumer<T> = boolean | ((value: T | null) => boolean);
|
|
37
|
+
/**
|
|
38
|
+
* Check if there are any attribute values changed between the two elements.
|
|
39
|
+
*
|
|
40
|
+
* @param elementToBeCompared - The element to check for differences.
|
|
41
|
+
* @param elementToCompareAgainst - The element used to check against.
|
|
42
|
+
*/
|
|
43
|
+
export declare function diffSclAttributes(elementToBeCompared: Element, elementToCompareAgainst: Element, filterToIgnore: DiffFilter<Element>, searchElementToBeCompared: Element): [string, Diff<string>][];
|
|
44
|
+
/**
|
|
45
|
+
* Function to retrieve the identity to compare 2 children on the same level.
|
|
46
|
+
* This means we only need to last part of the Identity string to compare the children.
|
|
47
|
+
*
|
|
48
|
+
* @param element - The element to retrieve the identity from.
|
|
49
|
+
*/
|
|
50
|
+
export declare function identityForCompare(element: Element): string | number;
|
|
51
|
+
/**
|
|
52
|
+
* Custom method for comparing to check if 2 elements are the same. Because they are on the same level
|
|
53
|
+
* we don't need to compare the full identity, we just compare the part of the Element itself.
|
|
54
|
+
*
|
|
55
|
+
* <b>Remark</b>Private elements are already filtered out, so we don't need to bother them.
|
|
56
|
+
*
|
|
57
|
+
* @param newValue - The new element to compare with the old element.
|
|
58
|
+
* @param oldValue - The old element to which the new element is compared.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isSame(newValue: Element, oldValue: Element): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* List of all differences between children elements that both old and new element have.
|
|
63
|
+
* The list contains children both elements have and children that were added or removed
|
|
64
|
+
* from the new element.
|
|
65
|
+
* <b>Remark</b>: Private elements are ignored.
|
|
66
|
+
*
|
|
67
|
+
* @param elementToBeCompared - The element to check for differences.
|
|
68
|
+
* @param elementToCompareAgainst - The element used to check against.
|
|
69
|
+
*/
|
|
70
|
+
export declare function diffSclChilds(elementToBeCompared: Element, elementToCompareAgainst: Element, filterToIgnore: DiffFilter<Element>, searchElementToBeCompared: Element, searchElementToCompareAgainst: Element): Diff<Element>[];
|
|
71
|
+
/**
|
|
72
|
+
* Generate HTML (TemplateResult) containing all the differences between the two elements passed.
|
|
73
|
+
* If null is returned there are no differences between the two elements.
|
|
74
|
+
*
|
|
75
|
+
* @param elementToBeCompared - The element to check for differences.
|
|
76
|
+
* @param elementToCompareAgainst - The element used to check against.
|
|
77
|
+
*/
|
|
78
|
+
export declare function renderDiff(elementToBeCompared: Element, elementToCompareAgainst: Element, filterToIgnore?: DiffFilter<Element>): TemplateResult | null;
|
|
79
|
+
export {};
|
|
@@ -1,211 +1,211 @@
|
|
|
1
|
-
import { html } from 'lit-element';
|
|
2
|
-
import { repeat } from 'lit-html/directives/repeat';
|
|
3
|
-
import { get } from 'lit-translate';
|
|
4
|
-
import '@material/mwc-list';
|
|
5
|
-
import '@material/mwc-list/mwc-list-item';
|
|
6
|
-
import '@material/mwc-icon';
|
|
7
|
-
import { identity } from '../foundation.js';
|
|
8
|
-
import { attributeIcon, contentIcon, elementIcon } from '../icons/compare.js';
|
|
9
|
-
const diffTypeToIcon = new Map();
|
|
10
|
-
diffTypeToIcon.set('Attribute', attributeIcon);
|
|
11
|
-
diffTypeToIcon.set('Content', contentIcon);
|
|
12
|
-
diffTypeToIcon.set('Element', elementIcon);
|
|
13
|
-
function getDiffFilterSelector(elementToBeCompared, rootElementToBeCompared, filters) {
|
|
14
|
-
const querySelector = rootElementToBeCompared === elementToBeCompared
|
|
15
|
-
? ':scope'
|
|
16
|
-
: Object.keys(filters).find(selector => Array.from(rootElementToBeCompared.querySelectorAll(selector)).includes(elementToBeCompared));
|
|
17
|
-
return querySelector ? filters[querySelector] : undefined;
|
|
18
|
-
}
|
|
19
|
-
function shouldFilterElement(element, filter) {
|
|
20
|
-
if (!filter || !filter.full) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
const consumer = filter.full;
|
|
24
|
-
return typeof consumer === 'boolean' ? consumer : consumer(element);
|
|
25
|
-
}
|
|
26
|
-
function shouldFilterAttribute(element, attribute, filter) {
|
|
27
|
-
if (!filter || !filter.attributes || !filter.attributes[attribute]) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
const consumer = filter.attributes[attribute];
|
|
31
|
-
return typeof consumer === 'boolean' ? consumer : consumer(element);
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Returns the description of the Element that differs.
|
|
35
|
-
*
|
|
36
|
-
* @param element - The Element to retrieve the identifier from.
|
|
37
|
-
*/
|
|
38
|
-
function describe(element) {
|
|
39
|
-
const id = identity(element);
|
|
40
|
-
return typeof id === 'string' ? id : get('unidentifiable');
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Check if there are any attribute values changed between the two elements.
|
|
44
|
-
*
|
|
45
|
-
* @param elementToBeCompared - The element to check for differences.
|
|
46
|
-
* @param elementToCompareAgainst - The element used to check against.
|
|
47
|
-
*/
|
|
48
|
-
export function diffSclAttributes(elementToBeCompared, elementToCompareAgainst, filterToIgnore, searchElementToBeCompared) {
|
|
49
|
-
const attrDiffs = [];
|
|
50
|
-
// First check if there is any text inside the element and there should be no child elements.
|
|
51
|
-
const newText = elementToBeCompared.textContent?.trim() ?? '';
|
|
52
|
-
const oldText = elementToCompareAgainst.textContent?.trim() ?? '';
|
|
53
|
-
if (elementToBeCompared.childElementCount === 0 &&
|
|
54
|
-
elementToCompareAgainst.childElementCount === 0 &&
|
|
55
|
-
newText !== oldText) {
|
|
56
|
-
const shouldFilter = shouldFilterElement(elementToBeCompared, getDiffFilterSelector(elementToBeCompared, searchElementToBeCompared, filterToIgnore));
|
|
57
|
-
if (!shouldFilter) {
|
|
58
|
-
attrDiffs.push([
|
|
59
|
-
'value',
|
|
60
|
-
{ type: 'Content', newValue: newText, oldValue: oldText },
|
|
61
|
-
]);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// Next check if there are any difference between attributes.
|
|
65
|
-
const attributeNames = new Set(elementToCompareAgainst
|
|
66
|
-
.getAttributeNames()
|
|
67
|
-
.concat(elementToBeCompared.getAttributeNames()));
|
|
68
|
-
for (const name of attributeNames) {
|
|
69
|
-
const shouldFilter = shouldFilterAttribute(elementToBeCompared, name, getDiffFilterSelector(elementToBeCompared, searchElementToBeCompared, filterToIgnore));
|
|
70
|
-
if (!shouldFilter &&
|
|
71
|
-
elementToCompareAgainst.getAttribute(name) !==
|
|
72
|
-
elementToBeCompared.getAttribute(name)) {
|
|
73
|
-
attrDiffs.push([
|
|
74
|
-
name,
|
|
75
|
-
{
|
|
76
|
-
type: 'Attribute',
|
|
77
|
-
newValue: elementToBeCompared.getAttribute(name),
|
|
78
|
-
oldValue: elementToCompareAgainst.getAttribute(name),
|
|
79
|
-
},
|
|
80
|
-
]);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return attrDiffs;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Function to retrieve the identity to compare 2 children on the same level.
|
|
87
|
-
* This means we only need to last part of the Identity string to compare the children.
|
|
88
|
-
*
|
|
89
|
-
* @param element - The element to retrieve the identity from.
|
|
90
|
-
*/
|
|
91
|
-
export function identityForCompare(element) {
|
|
92
|
-
let identityOfElement = identity(element);
|
|
93
|
-
if (typeof identityOfElement === 'string') {
|
|
94
|
-
identityOfElement = identityOfElement.split('>').pop() ?? '';
|
|
95
|
-
}
|
|
96
|
-
return identityOfElement;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Custom method for comparing to check if 2 elements are the same. Because they are on the same level
|
|
100
|
-
* we don't need to compare the full identity, we just compare the part of the Element itself.
|
|
101
|
-
*
|
|
102
|
-
* <b>Remark</b>Private elements are already filtered out, so we don't need to bother them.
|
|
103
|
-
*
|
|
104
|
-
* @param newValue - The new element to compare with the old element.
|
|
105
|
-
* @param oldValue - The old element to which the new element is compared.
|
|
106
|
-
*/
|
|
107
|
-
export function isSame(newValue, oldValue) {
|
|
108
|
-
return (newValue.tagName === oldValue.tagName &&
|
|
109
|
-
identityForCompare(newValue) === identityForCompare(oldValue));
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* List of all differences between children elements that both old and new element have.
|
|
113
|
-
* The list contains children both elements have and children that were added or removed
|
|
114
|
-
* from the new element.
|
|
115
|
-
* <b>Remark</b>: Private elements are ignored.
|
|
116
|
-
*
|
|
117
|
-
* @param elementToBeCompared - The element to check for differences.
|
|
118
|
-
* @param elementToCompareAgainst - The element used to check against.
|
|
119
|
-
*/
|
|
120
|
-
export function diffSclChilds(elementToBeCompared, elementToCompareAgainst, filterToIgnore, searchElementToBeCompared, searchElementToCompareAgainst) {
|
|
121
|
-
const childDiffs = [];
|
|
122
|
-
const childrenToBeCompared = Array.from(elementToBeCompared.children);
|
|
123
|
-
const childrenToCompareTo = Array.from(elementToCompareAgainst.children);
|
|
124
|
-
childrenToBeCompared.forEach(newElement => {
|
|
125
|
-
if (!newElement.closest('Private')) {
|
|
126
|
-
const shouldFilter = shouldFilterElement(newElement, getDiffFilterSelector(newElement, searchElementToBeCompared, filterToIgnore));
|
|
127
|
-
if (!shouldFilter) {
|
|
128
|
-
const twinIndex = childrenToCompareTo.findIndex(ourChild => isSame(newElement, ourChild));
|
|
129
|
-
const oldElement = twinIndex > -1 ? childrenToCompareTo[twinIndex] : null;
|
|
130
|
-
if (oldElement) {
|
|
131
|
-
childrenToCompareTo.splice(twinIndex, 1);
|
|
132
|
-
childDiffs.push({
|
|
133
|
-
type: 'Element',
|
|
134
|
-
newValue: newElement,
|
|
135
|
-
oldValue: oldElement,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
childDiffs.push({
|
|
140
|
-
type: 'Element',
|
|
141
|
-
newValue: newElement,
|
|
142
|
-
oldValue: null,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
childrenToCompareTo.forEach(oldElement => {
|
|
149
|
-
if (!oldElement.closest('Private')) {
|
|
150
|
-
const shouldFilter = shouldFilterElement(oldElement, getDiffFilterSelector(oldElement, searchElementToCompareAgainst, filterToIgnore));
|
|
151
|
-
if (!shouldFilter) {
|
|
152
|
-
childDiffs.push({
|
|
153
|
-
type: 'Element',
|
|
154
|
-
newValue: null,
|
|
155
|
-
oldValue: oldElement,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
return childDiffs;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Generate HTML (TemplateResult) containing all the differences between the two elements passed.
|
|
164
|
-
* If null is returned there are no differences between the two elements.
|
|
165
|
-
*
|
|
166
|
-
* @param elementToBeCompared - The element to check for differences.
|
|
167
|
-
* @param elementToCompareAgainst - The element used to check against.
|
|
168
|
-
*/
|
|
169
|
-
export function renderDiff(elementToBeCompared, elementToCompareAgainst, filterToIgnore = {}) {
|
|
170
|
-
return renderDiffInternal(elementToBeCompared, elementToCompareAgainst, filterToIgnore, elementToBeCompared, elementToCompareAgainst);
|
|
171
|
-
}
|
|
172
|
-
function renderDiffInternal(elementToBeCompared, elementToCompareAgainst, filterToIgnore = {}, searchElementToBeCompared, searchElementToCompareAgainst) {
|
|
173
|
-
// Determine the ID from the current tag. These can be numbers or strings.
|
|
174
|
-
let idTitle = identity(elementToBeCompared).toString();
|
|
175
|
-
if (idTitle === 'NaN') {
|
|
176
|
-
idTitle = undefined;
|
|
177
|
-
}
|
|
178
|
-
// Set the root elements if they are not defined yet
|
|
179
|
-
searchElementToBeCompared = searchElementToBeCompared || elementToBeCompared;
|
|
180
|
-
searchElementToCompareAgainst =
|
|
181
|
-
searchElementToCompareAgainst || elementToCompareAgainst;
|
|
182
|
-
const attrDiffs = diffSclAttributes(elementToBeCompared, elementToCompareAgainst, filterToIgnore, searchElementToBeCompared);
|
|
183
|
-
// Next check which elements are added, deleted or in both elements.
|
|
184
|
-
const childDiffs = diffSclChilds(elementToBeCompared, elementToCompareAgainst, filterToIgnore, searchElementToBeCompared, searchElementToCompareAgainst);
|
|
185
|
-
const childAddedOrDeleted = [];
|
|
186
|
-
const childToCompare = [];
|
|
187
|
-
childDiffs.forEach(diff => {
|
|
188
|
-
if (!diff.oldValue || !diff.newValue) {
|
|
189
|
-
childAddedOrDeleted.push(diff);
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
childToCompare.push(diff);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
// These children exist in both old and new element, let's check if there are any difference in the children.
|
|
196
|
-
const childToCompareTemplates = childToCompare
|
|
197
|
-
.map(diff => renderDiff(diff.newValue, diff.oldValue, filterToIgnore))
|
|
198
|
-
.filter(result => result !== null);
|
|
199
|
-
// If there are difference generate the HTML otherwise just return null.
|
|
200
|
-
if (childToCompareTemplates.length > 0 ||
|
|
201
|
-
attrDiffs.length > 0 ||
|
|
202
|
-
childAddedOrDeleted.length > 0) {
|
|
203
|
-
return html ` ${attrDiffs.length > 0 || childAddedOrDeleted.length > 0
|
|
1
|
+
import { html } from 'lit-element';
|
|
2
|
+
import { repeat } from 'lit-html/directives/repeat';
|
|
3
|
+
import { get } from 'lit-translate';
|
|
4
|
+
import '@material/mwc-list';
|
|
5
|
+
import '@material/mwc-list/mwc-list-item';
|
|
6
|
+
import '@material/mwc-icon';
|
|
7
|
+
import { identity } from '../foundation.js';
|
|
8
|
+
import { attributeIcon, contentIcon, elementIcon } from '../icons/compare.js';
|
|
9
|
+
const diffTypeToIcon = new Map();
|
|
10
|
+
diffTypeToIcon.set('Attribute', attributeIcon);
|
|
11
|
+
diffTypeToIcon.set('Content', contentIcon);
|
|
12
|
+
diffTypeToIcon.set('Element', elementIcon);
|
|
13
|
+
function getDiffFilterSelector(elementToBeCompared, rootElementToBeCompared, filters) {
|
|
14
|
+
const querySelector = rootElementToBeCompared === elementToBeCompared
|
|
15
|
+
? ':scope'
|
|
16
|
+
: Object.keys(filters).find(selector => Array.from(rootElementToBeCompared.querySelectorAll(selector)).includes(elementToBeCompared));
|
|
17
|
+
return querySelector ? filters[querySelector] : undefined;
|
|
18
|
+
}
|
|
19
|
+
function shouldFilterElement(element, filter) {
|
|
20
|
+
if (!filter || !filter.full) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const consumer = filter.full;
|
|
24
|
+
return typeof consumer === 'boolean' ? consumer : consumer(element);
|
|
25
|
+
}
|
|
26
|
+
function shouldFilterAttribute(element, attribute, filter) {
|
|
27
|
+
if (!filter || !filter.attributes || !filter.attributes[attribute]) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const consumer = filter.attributes[attribute];
|
|
31
|
+
return typeof consumer === 'boolean' ? consumer : consumer(element);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Returns the description of the Element that differs.
|
|
35
|
+
*
|
|
36
|
+
* @param element - The Element to retrieve the identifier from.
|
|
37
|
+
*/
|
|
38
|
+
function describe(element) {
|
|
39
|
+
const id = identity(element);
|
|
40
|
+
return typeof id === 'string' ? id : get('unidentifiable');
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Check if there are any attribute values changed between the two elements.
|
|
44
|
+
*
|
|
45
|
+
* @param elementToBeCompared - The element to check for differences.
|
|
46
|
+
* @param elementToCompareAgainst - The element used to check against.
|
|
47
|
+
*/
|
|
48
|
+
export function diffSclAttributes(elementToBeCompared, elementToCompareAgainst, filterToIgnore, searchElementToBeCompared) {
|
|
49
|
+
const attrDiffs = [];
|
|
50
|
+
// First check if there is any text inside the element and there should be no child elements.
|
|
51
|
+
const newText = elementToBeCompared.textContent?.trim() ?? '';
|
|
52
|
+
const oldText = elementToCompareAgainst.textContent?.trim() ?? '';
|
|
53
|
+
if (elementToBeCompared.childElementCount === 0 &&
|
|
54
|
+
elementToCompareAgainst.childElementCount === 0 &&
|
|
55
|
+
newText !== oldText) {
|
|
56
|
+
const shouldFilter = shouldFilterElement(elementToBeCompared, getDiffFilterSelector(elementToBeCompared, searchElementToBeCompared, filterToIgnore));
|
|
57
|
+
if (!shouldFilter) {
|
|
58
|
+
attrDiffs.push([
|
|
59
|
+
'value',
|
|
60
|
+
{ type: 'Content', newValue: newText, oldValue: oldText },
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Next check if there are any difference between attributes.
|
|
65
|
+
const attributeNames = new Set(elementToCompareAgainst
|
|
66
|
+
.getAttributeNames()
|
|
67
|
+
.concat(elementToBeCompared.getAttributeNames()));
|
|
68
|
+
for (const name of attributeNames) {
|
|
69
|
+
const shouldFilter = shouldFilterAttribute(elementToBeCompared, name, getDiffFilterSelector(elementToBeCompared, searchElementToBeCompared, filterToIgnore));
|
|
70
|
+
if (!shouldFilter &&
|
|
71
|
+
elementToCompareAgainst.getAttribute(name) !==
|
|
72
|
+
elementToBeCompared.getAttribute(name)) {
|
|
73
|
+
attrDiffs.push([
|
|
74
|
+
name,
|
|
75
|
+
{
|
|
76
|
+
type: 'Attribute',
|
|
77
|
+
newValue: elementToBeCompared.getAttribute(name),
|
|
78
|
+
oldValue: elementToCompareAgainst.getAttribute(name),
|
|
79
|
+
},
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return attrDiffs;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Function to retrieve the identity to compare 2 children on the same level.
|
|
87
|
+
* This means we only need to last part of the Identity string to compare the children.
|
|
88
|
+
*
|
|
89
|
+
* @param element - The element to retrieve the identity from.
|
|
90
|
+
*/
|
|
91
|
+
export function identityForCompare(element) {
|
|
92
|
+
let identityOfElement = identity(element);
|
|
93
|
+
if (typeof identityOfElement === 'string') {
|
|
94
|
+
identityOfElement = identityOfElement.split('>').pop() ?? '';
|
|
95
|
+
}
|
|
96
|
+
return identityOfElement;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Custom method for comparing to check if 2 elements are the same. Because they are on the same level
|
|
100
|
+
* we don't need to compare the full identity, we just compare the part of the Element itself.
|
|
101
|
+
*
|
|
102
|
+
* <b>Remark</b>Private elements are already filtered out, so we don't need to bother them.
|
|
103
|
+
*
|
|
104
|
+
* @param newValue - The new element to compare with the old element.
|
|
105
|
+
* @param oldValue - The old element to which the new element is compared.
|
|
106
|
+
*/
|
|
107
|
+
export function isSame(newValue, oldValue) {
|
|
108
|
+
return (newValue.tagName === oldValue.tagName &&
|
|
109
|
+
identityForCompare(newValue) === identityForCompare(oldValue));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* List of all differences between children elements that both old and new element have.
|
|
113
|
+
* The list contains children both elements have and children that were added or removed
|
|
114
|
+
* from the new element.
|
|
115
|
+
* <b>Remark</b>: Private elements are ignored.
|
|
116
|
+
*
|
|
117
|
+
* @param elementToBeCompared - The element to check for differences.
|
|
118
|
+
* @param elementToCompareAgainst - The element used to check against.
|
|
119
|
+
*/
|
|
120
|
+
export function diffSclChilds(elementToBeCompared, elementToCompareAgainst, filterToIgnore, searchElementToBeCompared, searchElementToCompareAgainst) {
|
|
121
|
+
const childDiffs = [];
|
|
122
|
+
const childrenToBeCompared = Array.from(elementToBeCompared.children);
|
|
123
|
+
const childrenToCompareTo = Array.from(elementToCompareAgainst.children);
|
|
124
|
+
childrenToBeCompared.forEach(newElement => {
|
|
125
|
+
if (!newElement.closest('Private')) {
|
|
126
|
+
const shouldFilter = shouldFilterElement(newElement, getDiffFilterSelector(newElement, searchElementToBeCompared, filterToIgnore));
|
|
127
|
+
if (!shouldFilter) {
|
|
128
|
+
const twinIndex = childrenToCompareTo.findIndex(ourChild => isSame(newElement, ourChild));
|
|
129
|
+
const oldElement = twinIndex > -1 ? childrenToCompareTo[twinIndex] : null;
|
|
130
|
+
if (oldElement) {
|
|
131
|
+
childrenToCompareTo.splice(twinIndex, 1);
|
|
132
|
+
childDiffs.push({
|
|
133
|
+
type: 'Element',
|
|
134
|
+
newValue: newElement,
|
|
135
|
+
oldValue: oldElement,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
childDiffs.push({
|
|
140
|
+
type: 'Element',
|
|
141
|
+
newValue: newElement,
|
|
142
|
+
oldValue: null,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
childrenToCompareTo.forEach(oldElement => {
|
|
149
|
+
if (!oldElement.closest('Private')) {
|
|
150
|
+
const shouldFilter = shouldFilterElement(oldElement, getDiffFilterSelector(oldElement, searchElementToCompareAgainst, filterToIgnore));
|
|
151
|
+
if (!shouldFilter) {
|
|
152
|
+
childDiffs.push({
|
|
153
|
+
type: 'Element',
|
|
154
|
+
newValue: null,
|
|
155
|
+
oldValue: oldElement,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return childDiffs;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Generate HTML (TemplateResult) containing all the differences between the two elements passed.
|
|
164
|
+
* If null is returned there are no differences between the two elements.
|
|
165
|
+
*
|
|
166
|
+
* @param elementToBeCompared - The element to check for differences.
|
|
167
|
+
* @param elementToCompareAgainst - The element used to check against.
|
|
168
|
+
*/
|
|
169
|
+
export function renderDiff(elementToBeCompared, elementToCompareAgainst, filterToIgnore = {}) {
|
|
170
|
+
return renderDiffInternal(elementToBeCompared, elementToCompareAgainst, filterToIgnore, elementToBeCompared, elementToCompareAgainst);
|
|
171
|
+
}
|
|
172
|
+
function renderDiffInternal(elementToBeCompared, elementToCompareAgainst, filterToIgnore = {}, searchElementToBeCompared, searchElementToCompareAgainst) {
|
|
173
|
+
// Determine the ID from the current tag. These can be numbers or strings.
|
|
174
|
+
let idTitle = identity(elementToBeCompared).toString();
|
|
175
|
+
if (idTitle === 'NaN') {
|
|
176
|
+
idTitle = undefined;
|
|
177
|
+
}
|
|
178
|
+
// Set the root elements if they are not defined yet
|
|
179
|
+
searchElementToBeCompared = searchElementToBeCompared || elementToBeCompared;
|
|
180
|
+
searchElementToCompareAgainst =
|
|
181
|
+
searchElementToCompareAgainst || elementToCompareAgainst;
|
|
182
|
+
const attrDiffs = diffSclAttributes(elementToBeCompared, elementToCompareAgainst, filterToIgnore, searchElementToBeCompared);
|
|
183
|
+
// Next check which elements are added, deleted or in both elements.
|
|
184
|
+
const childDiffs = diffSclChilds(elementToBeCompared, elementToCompareAgainst, filterToIgnore, searchElementToBeCompared, searchElementToCompareAgainst);
|
|
185
|
+
const childAddedOrDeleted = [];
|
|
186
|
+
const childToCompare = [];
|
|
187
|
+
childDiffs.forEach(diff => {
|
|
188
|
+
if (!diff.oldValue || !diff.newValue) {
|
|
189
|
+
childAddedOrDeleted.push(diff);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
childToCompare.push(diff);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
// These children exist in both old and new element, let's check if there are any difference in the children.
|
|
196
|
+
const childToCompareTemplates = childToCompare
|
|
197
|
+
.map(diff => renderDiff(diff.newValue, diff.oldValue, filterToIgnore))
|
|
198
|
+
.filter(result => result !== null);
|
|
199
|
+
// If there are difference generate the HTML otherwise just return null.
|
|
200
|
+
if (childToCompareTemplates.length > 0 ||
|
|
201
|
+
attrDiffs.length > 0 ||
|
|
202
|
+
childAddedOrDeleted.length > 0) {
|
|
203
|
+
return html ` ${attrDiffs.length > 0 || childAddedOrDeleted.length > 0
|
|
204
204
|
? html `<div class="container container--alt">
|
|
205
205
|
<div class="list__container list__container--left">
|
|
206
206
|
<mwc-list multi right nonInteractive>
|
|
207
207
|
${repeat(attrDiffs, e => e, ([name, diff]) => html `<mwc-list-item right twoLine graphic="icon">
|
|
208
|
-
${diff.oldValue !== null
|
|
208
|
+
${diff.oldValue !== null
|
|
209
209
|
? html `
|
|
210
210
|
<span>
|
|
211
211
|
${name}:
|
|
@@ -215,11 +215,11 @@ function renderDiffInternal(elementToBeCompared, elementToCompareAgainst, filter
|
|
|
215
215
|
<mwc-icon slot="graphic">
|
|
216
216
|
${diffTypeToIcon.get(diff.type)}
|
|
217
217
|
</mwc-icon>
|
|
218
|
-
`
|
|
218
|
+
`
|
|
219
219
|
: ''}
|
|
220
220
|
</mwc-list-item>`)}
|
|
221
221
|
${repeat(childAddedOrDeleted, e => e, diff => html ` <mwc-list-item right twoLine graphic="icon">
|
|
222
|
-
${diff.oldValue
|
|
222
|
+
${diff.oldValue
|
|
223
223
|
? html `
|
|
224
224
|
<span>${diff.oldValue.tagName}</span>
|
|
225
225
|
<span slot="secondary">
|
|
@@ -228,7 +228,7 @@ function renderDiffInternal(elementToBeCompared, elementToCompareAgainst, filter
|
|
|
228
228
|
<mwc-icon slot="graphic">
|
|
229
229
|
${diffTypeToIcon.get(diff.type)}
|
|
230
230
|
</mwc-icon>
|
|
231
|
-
`
|
|
231
|
+
`
|
|
232
232
|
: ''}
|
|
233
233
|
</mwc-list-item>`)}
|
|
234
234
|
</mwc-list>
|
|
@@ -236,7 +236,7 @@ function renderDiffInternal(elementToBeCompared, elementToCompareAgainst, filter
|
|
|
236
236
|
<div class="list__container">
|
|
237
237
|
<mwc-list multi left nonInteractive>
|
|
238
238
|
${repeat(attrDiffs, e => e, ([name, diff]) => html ` <mwc-list-item left twoLine graphic="icon">
|
|
239
|
-
${diff.newValue !== null
|
|
239
|
+
${diff.newValue !== null
|
|
240
240
|
? html `
|
|
241
241
|
<span>
|
|
242
242
|
${name}:
|
|
@@ -246,11 +246,11 @@ function renderDiffInternal(elementToBeCompared, elementToCompareAgainst, filter
|
|
|
246
246
|
<mwc-icon slot="graphic">
|
|
247
247
|
${diffTypeToIcon.get(diff.type)}
|
|
248
248
|
</mwc-icon>
|
|
249
|
-
`
|
|
249
|
+
`
|
|
250
250
|
: ''}
|
|
251
251
|
</mwc-list-item>`)}
|
|
252
252
|
${repeat(childAddedOrDeleted, e => e, diff => html ` <mwc-list-item left twoLine graphic="icon">
|
|
253
|
-
${diff.newValue
|
|
253
|
+
${diff.newValue
|
|
254
254
|
? html `
|
|
255
255
|
<span>${diff.newValue.tagName}</span>
|
|
256
256
|
<span slot="secondary">
|
|
@@ -259,15 +259,15 @@ function renderDiffInternal(elementToBeCompared, elementToCompareAgainst, filter
|
|
|
259
259
|
<mwc-icon slot="graphic">
|
|
260
260
|
${diffTypeToIcon.get(diff.type)}
|
|
261
261
|
</mwc-icon>
|
|
262
|
-
`
|
|
262
|
+
`
|
|
263
263
|
: ''}
|
|
264
264
|
</mwc-list-item>`)}
|
|
265
265
|
</mwc-list>
|
|
266
266
|
</div>
|
|
267
|
-
</div>`
|
|
267
|
+
</div>`
|
|
268
268
|
: ''}
|
|
269
|
-
${childToCompareTemplates}`;
|
|
270
|
-
}
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
269
|
+
${childToCompareTemplates}`;
|
|
270
|
+
}
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
273
|
//# sourceMappingURL=compare.js.map
|