treeloom 0.0.0-stage → 2.1.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/LICENSE +373 -0
- package/README.md +91 -2
- package/browser/treeloom.js +11232 -0
- package/browser/treeloom.min.js +1 -0
- package/browser/treeloomRenderOnly.js +11115 -0
- package/browser/treeloomRenderOnly.min.js +1 -0
- package/dist/deflate/domItemToJson.d.ts +14 -0
- package/dist/deflate/domItemToJson.js +43 -0
- package/dist/deflate/domItemToJson.min.js +1 -0
- package/dist/deflate/index.d.ts +7 -0
- package/dist/deflate/index.js +19 -0
- package/dist/deflate/index.min.js +1 -0
- package/dist/deflate/removeEmptyProperties.d.ts +8 -0
- package/dist/deflate/removeEmptyProperties.js +43 -0
- package/dist/deflate/removeEmptyProperties.min.js +1 -0
- package/dist/diff/appliedSnapshot.d.ts +34 -0
- package/dist/diff/appliedSnapshot.js +134 -0
- package/dist/diff/appliedSnapshot.min.js +1 -0
- package/dist/diff/createChangeList.d.ts +9 -0
- package/dist/diff/createChangeList.js +44 -0
- package/dist/diff/createChangeList.min.js +1 -0
- package/dist/diff/domItemChanges.d.ts +9 -0
- package/dist/diff/domItemChanges.js +167 -0
- package/dist/diff/domItemChanges.min.js +1 -0
- package/dist/diff/domItemHasAttribute.d.ts +11 -0
- package/dist/diff/domItemHasAttribute.js +63 -0
- package/dist/diff/domItemHasAttribute.min.js +1 -0
- package/dist/diff/elementChanges.d.ts +10 -0
- package/dist/diff/elementChanges.js +151 -0
- package/dist/diff/elementChanges.min.js +1 -0
- package/dist/diff/elementHasAttribute.d.ts +10 -0
- package/dist/diff/elementHasAttribute.js +70 -0
- package/dist/diff/elementHasAttribute.min.js +1 -0
- package/dist/diff/getAssignedStyles.d.ts +9 -0
- package/dist/diff/getAssignedStyles.js +22 -0
- package/dist/diff/getAssignedStyles.min.js +1 -0
- package/dist/diff/index.d.ts +9 -0
- package/dist/diff/index.js +27 -0
- package/dist/diff/index.min.js +1 -0
- package/dist/diff/types.d.ts +17 -0
- package/dist/diff/types.js +8 -0
- package/dist/diff/types.min.js +1 -0
- package/dist/domItem/index.d.ts +34 -0
- package/dist/domItem/index.js +81 -0
- package/dist/domItem/index.min.js +1 -0
- package/dist/domItem/objects/addDomItemProperties.d.ts +7 -0
- package/dist/domItem/objects/addDomItemProperties.js +27 -0
- package/dist/domItem/objects/addDomItemProperties.min.js +1 -0
- package/dist/domItem/objects/createCoreItem.d.ts +9 -0
- package/dist/domItem/objects/createCoreItem.js +53 -0
- package/dist/domItem/objects/createCoreItem.min.js +1 -0
- package/dist/domItem/objects/createDomItem.d.ts +10 -0
- package/dist/domItem/objects/createDomItem.js +40 -0
- package/dist/domItem/objects/createDomItem.min.js +1 -0
- package/dist/domItem/objects/documentDomItem.d.ts +12 -0
- package/dist/domItem/objects/documentDomItem.js +36 -0
- package/dist/domItem/objects/documentDomItem.min.js +1 -0
- package/dist/domItem/objects/documentItem.d.ts +18 -0
- package/dist/domItem/objects/documentItem.js +40 -0
- package/dist/domItem/objects/documentItem.min.js +1 -0
- package/dist/domItem/objects/initChildren.d.ts +6 -0
- package/dist/domItem/objects/initChildren.js +44 -0
- package/dist/domItem/objects/initChildren.min.js +1 -0
- package/dist/domItem/objects/initRoot.d.ts +9 -0
- package/dist/domItem/objects/initRoot.js +32 -0
- package/dist/domItem/objects/initRoot.min.js +1 -0
- package/dist/domItem/query/gatherChildItems.d.ts +12 -0
- package/dist/domItem/query/gatherChildItems.js +19 -0
- package/dist/domItem/query/gatherChildItems.min.js +1 -0
- package/dist/domItem/query/getChildTest.d.ts +8 -0
- package/dist/domItem/query/getChildTest.js +15 -0
- package/dist/domItem/query/getChildTest.min.js +1 -0
- package/dist/domItem/query/getChildrenByClass.d.ts +11 -0
- package/dist/domItem/query/getChildrenByClass.js +26 -0
- package/dist/domItem/query/getChildrenByClass.min.js +1 -0
- package/dist/domItem/query/getChildrenByName.d.ts +9 -0
- package/dist/domItem/query/getChildrenByName.js +23 -0
- package/dist/domItem/query/getChildrenByName.min.js +1 -0
- package/dist/domItem/query/getChildrenFromAttribute.d.ts +13 -0
- package/dist/domItem/query/getChildrenFromAttribute.js +28 -0
- package/dist/domItem/query/getChildrenFromAttribute.min.js +1 -0
- package/dist/domItem/query/getItemByElement.d.ts +11 -0
- package/dist/domItem/query/getItemByElement.js +29 -0
- package/dist/domItem/query/getItemByElement.min.js +1 -0
- package/dist/domItem/query/getParentsByClass.d.ts +12 -0
- package/dist/domItem/query/getParentsByClass.js +40 -0
- package/dist/domItem/query/getParentsByClass.min.js +1 -0
- package/dist/domItem/query/getParentsByName.d.ts +9 -0
- package/dist/domItem/query/getParentsByName.js +23 -0
- package/dist/domItem/query/getParentsByName.min.js +1 -0
- package/dist/domItem/query/getParentsByTagName.d.ts +9 -0
- package/dist/domItem/query/getParentsByTagName.js +23 -0
- package/dist/domItem/query/getParentsByTagName.min.js +1 -0
- package/dist/domItem/query/getParentsFromAttribute.d.ts +13 -0
- package/dist/domItem/query/getParentsFromAttribute.js +39 -0
- package/dist/domItem/query/getParentsFromAttribute.min.js +1 -0
- package/dist/domItem/traits/defineTrait.d.ts +10 -0
- package/dist/domItem/traits/defineTrait.js +26 -0
- package/dist/domItem/traits/defineTrait.min.js +1 -0
- package/dist/domItem/traits/definitions.d.ts +7 -0
- package/dist/domItem/traits/definitions.js +20 -0
- package/dist/domItem/traits/definitions.min.js +1 -0
- package/dist/domItem/traits/getNonSerializableKeys.d.ts +9 -0
- package/dist/domItem/traits/getNonSerializableKeys.js +25 -0
- package/dist/domItem/traits/getNonSerializableKeys.min.js +1 -0
- package/dist/domItem/traits/getTraitDefinition.d.ts +7 -0
- package/dist/domItem/traits/getTraitDefinition.js +20 -0
- package/dist/domItem/traits/getTraitDefinition.min.js +1 -0
- package/dist/domItem/traits/hasTrait.d.ts +8 -0
- package/dist/domItem/traits/hasTrait.js +15 -0
- package/dist/domItem/traits/hasTrait.min.js +1 -0
- package/dist/domItem/traits/hasTraits.d.ts +9 -0
- package/dist/domItem/traits/hasTraits.js +16 -0
- package/dist/domItem/traits/hasTraits.min.js +1 -0
- package/dist/domItem/traits/isDomItem.d.ts +8 -0
- package/dist/domItem/traits/isDomItem.js +21 -0
- package/dist/domItem/traits/isDomItem.min.js +1 -0
- package/dist/domItem/traits/withTrait.d.ts +11 -0
- package/dist/domItem/traits/withTrait.js +30 -0
- package/dist/domItem/traits/withTrait.min.js +1 -0
- package/dist/domItem/tree/appendChild.d.ts +8 -0
- package/dist/domItem/tree/appendChild.js +19 -0
- package/dist/domItem/tree/appendChild.min.js +1 -0
- package/dist/domItem/tree/getItemByPath.d.ts +10 -0
- package/dist/domItem/tree/getItemByPath.js +23 -0
- package/dist/domItem/tree/getItemByPath.min.js +1 -0
- package/dist/domItem/tree/getItemPath.d.ts +9 -0
- package/dist/domItem/tree/getItemPath.js +31 -0
- package/dist/domItem/tree/getItemPath.min.js +1 -0
- package/dist/domItem/tree/getTopParentItem.d.ts +8 -0
- package/dist/domItem/tree/getTopParentItem.js +29 -0
- package/dist/domItem/tree/getTopParentItem.min.js +1 -0
- package/dist/domItem/tree/insertChild.d.ts +11 -0
- package/dist/domItem/tree/insertChild.js +22 -0
- package/dist/domItem/tree/insertChild.min.js +1 -0
- package/dist/domItem/tree/itemIdIndex.d.ts +43 -0
- package/dist/domItem/tree/itemIdIndex.js +118 -0
- package/dist/domItem/tree/itemIdIndex.min.js +1 -0
- package/dist/domItem/tree/removeChild.d.ts +8 -0
- package/dist/domItem/tree/removeChild.js +21 -0
- package/dist/domItem/tree/removeChild.min.js +1 -0
- package/dist/domItem/tree/setParentItemReferences.d.ts +7 -0
- package/dist/domItem/tree/setParentItemReferences.js +24 -0
- package/dist/domItem/tree/setParentItemReferences.min.js +1 -0
- package/dist/domItem/types.d.ts +131 -0
- package/dist/domItem/types.js +8 -0
- package/dist/domItem/types.min.js +1 -0
- package/dist/events/functions/activateListener.d.ts +10 -0
- package/dist/events/functions/activateListener.js +45 -0
- package/dist/events/functions/activateListener.min.js +1 -0
- package/dist/events/functions/addEventListener.d.ts +23 -0
- package/dist/events/functions/addEventListener.js +54 -0
- package/dist/events/functions/addEventListener.min.js +1 -0
- package/dist/events/functions/applyActiveListeners.d.ts +9 -0
- package/dist/events/functions/applyActiveListeners.js +52 -0
- package/dist/events/functions/applyActiveListeners.min.js +1 -0
- package/dist/events/functions/assignListener.d.ts +12 -0
- package/dist/events/functions/assignListener.js +39 -0
- package/dist/events/functions/assignListener.min.js +1 -0
- package/dist/events/functions/bindAllListeners.d.ts +10 -0
- package/dist/events/functions/bindAllListeners.js +28 -0
- package/dist/events/functions/bindAllListeners.min.js +1 -0
- package/dist/events/functions/bindElementListeners.d.ts +7 -0
- package/dist/events/functions/bindElementListeners.js +34 -0
- package/dist/events/functions/bindElementListeners.min.js +1 -0
- package/dist/events/functions/bindListeners.d.ts +9 -0
- package/dist/events/functions/bindListeners.js +23 -0
- package/dist/events/functions/bindListeners.min.js +1 -0
- package/dist/events/functions/deactivateListener.d.ts +13 -0
- package/dist/events/functions/deactivateListener.js +58 -0
- package/dist/events/functions/deactivateListener.min.js +1 -0
- package/dist/events/functions/deactivateListeners.d.ts +7 -0
- package/dist/events/functions/deactivateListeners.js +22 -0
- package/dist/events/functions/deactivateListeners.min.js +1 -0
- package/dist/events/functions/findEventListener.d.ts +22 -0
- package/dist/events/functions/findEventListener.js +61 -0
- package/dist/events/functions/findEventListener.min.js +1 -0
- package/dist/events/functions/fullAddEventListener.d.ts +20 -0
- package/dist/events/functions/fullAddEventListener.js +45 -0
- package/dist/events/functions/fullAddEventListener.min.js +1 -0
- package/dist/events/functions/fullRemoveEventListener.d.ts +22 -0
- package/dist/events/functions/fullRemoveEventListener.js +37 -0
- package/dist/events/functions/fullRemoveEventListener.min.js +1 -0
- package/dist/events/functions/listenerOptions.d.ts +12 -0
- package/dist/events/functions/listenerOptions.js +31 -0
- package/dist/events/functions/listenerOptions.min.js +1 -0
- package/dist/events/functions/makeEventHandler.d.ts +10 -0
- package/dist/events/functions/makeEventHandler.js +23 -0
- package/dist/events/functions/makeEventHandler.min.js +1 -0
- package/dist/events/functions/makeForwardingListener.d.ts +11 -0
- package/dist/events/functions/makeForwardingListener.js +46 -0
- package/dist/events/functions/makeForwardingListener.min.js +1 -0
- package/dist/events/functions/receiveForwardedEvent.d.ts +23 -0
- package/dist/events/functions/receiveForwardedEvent.js +40 -0
- package/dist/events/functions/receiveForwardedEvent.min.js +1 -0
- package/dist/events/functions/registerListener.d.ts +11 -0
- package/dist/events/functions/registerListener.js +25 -0
- package/dist/events/functions/registerListener.min.js +1 -0
- package/dist/events/functions/registerListeners.d.ts +10 -0
- package/dist/events/functions/registerListeners.js +26 -0
- package/dist/events/functions/registerListeners.min.js +1 -0
- package/dist/events/functions/removeEventListener.d.ts +18 -0
- package/dist/events/functions/removeEventListener.js +42 -0
- package/dist/events/functions/removeEventListener.min.js +1 -0
- package/dist/events/functions/retrieveListener.d.ts +14 -0
- package/dist/events/functions/retrieveListener.js +39 -0
- package/dist/events/functions/retrieveListener.min.js +1 -0
- package/dist/events/functions/revokeActiveListeners.d.ts +12 -0
- package/dist/events/functions/revokeActiveListeners.js +54 -0
- package/dist/events/functions/revokeActiveListeners.min.js +1 -0
- package/dist/events/functions/setForwardEvents.d.ts +11 -0
- package/dist/events/functions/setForwardEvents.js +26 -0
- package/dist/events/functions/setForwardEvents.min.js +1 -0
- package/dist/events/functions/unassignListener.d.ts +12 -0
- package/dist/events/functions/unassignListener.js +32 -0
- package/dist/events/functions/unassignListener.min.js +1 -0
- package/dist/events/index.d.ts +37 -0
- package/dist/events/index.js +72 -0
- package/dist/events/index.min.js +1 -0
- package/dist/events/objects/createEventListener.d.ts +13 -0
- package/dist/events/objects/createEventListener.js +30 -0
- package/dist/events/objects/createEventListener.min.js +1 -0
- package/dist/events/objects/createEventProxy.d.ts +10 -0
- package/dist/events/objects/createEventProxy.js +48 -0
- package/dist/events/objects/createEventProxy.min.js +1 -0
- package/dist/events/objects/createEventResponder.d.ts +8 -0
- package/dist/events/objects/createEventResponder.js +27 -0
- package/dist/events/objects/createEventResponder.min.js +1 -0
- package/dist/events/objects/options/getListenerOptions.d.ts +6 -0
- package/dist/events/objects/options/getListenerOptions.js +22 -0
- package/dist/events/objects/options/getListenerOptions.min.js +1 -0
- package/dist/events/objects/options/numberToOptions.d.ts +8 -0
- package/dist/events/objects/options/numberToOptions.js +21 -0
- package/dist/events/objects/options/numberToOptions.min.js +1 -0
- package/dist/events/objects/options/optionsToNumber.d.ts +9 -0
- package/dist/events/objects/options/optionsToNumber.js +27 -0
- package/dist/events/objects/options/optionsToNumber.min.js +1 -0
- package/dist/events/objects/options.d.ts +6 -0
- package/dist/events/objects/options.js +24 -0
- package/dist/events/objects/options.min.js +1 -0
- package/dist/events/types.d.ts +87 -0
- package/dist/events/types.js +8 -0
- package/dist/events/types.min.js +1 -0
- package/dist/inflate/index.d.ts +4 -0
- package/dist/inflate/index.js +17 -0
- package/dist/inflate/index.min.js +1 -0
- package/dist/inflate/jsonToDomItem.d.ts +7 -0
- package/dist/inflate/jsonToDomItem.js +30 -0
- package/dist/inflate/jsonToDomItem.min.js +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +24 -0
- package/dist/main.min.js +1 -0
- package/dist/render/generateElement.d.ts +7 -0
- package/dist/render/generateElement.js +41 -0
- package/dist/render/generateElement.min.js +1 -0
- package/dist/render/index.d.ts +9 -0
- package/dist/render/index.js +27 -0
- package/dist/render/index.min.js +1 -0
- package/dist/render/reconcile.d.ts +16 -0
- package/dist/render/reconcile.js +169 -0
- package/dist/render/reconcile.min.js +1 -0
- package/dist/render/renderHtml.d.ts +16 -0
- package/dist/render/renderHtml.js +57 -0
- package/dist/render/renderHtml.min.js +1 -0
- package/dist/render/updateChildNodes.d.ts +7 -0
- package/dist/render/updateChildNodes.js +53 -0
- package/dist/render/updateChildNodes.min.js +1 -0
- package/dist/render/updateElement.d.ts +14 -0
- package/dist/render/updateElement.js +113 -0
- package/dist/render/updateElement.min.js +1 -0
- package/dist/render/updateElements.d.ts +9 -0
- package/dist/render/updateElements.js +33 -0
- package/dist/render/updateElements.min.js +1 -0
- package/dist/renderOnly.d.ts +2 -0
- package/dist/renderOnly.js +27 -0
- package/dist/renderOnly.min.js +1 -0
- package/dist/sync/index.d.ts +6 -0
- package/dist/sync/index.js +21 -0
- package/dist/sync/index.min.js +1 -0
- package/dist/sync/updateChildren.d.ts +7 -0
- package/dist/sync/updateChildren.js +38 -0
- package/dist/sync/updateChildren.min.js +1 -0
- package/dist/sync/updateDomItem.d.ts +8 -0
- package/dist/sync/updateDomItem.js +53 -0
- package/dist/sync/updateDomItem.min.js +1 -0
- package/dist/sync/updateDomItems.d.ts +9 -0
- package/dist/sync/updateDomItems.js +33 -0
- package/dist/sync/updateDomItems.min.js +1 -0
- package/package.json +74 -4
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
7
|
+
return mod && mod.__esModule ? mod : {
|
|
8
|
+
"default": mod
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
const createDomItem_1 = __importDefault(require("./createDomItem"));
|
|
15
|
+
const onBodyLoad_1 = __importDefault(require("si-funciona/dist/helpers/functions/onBodyLoad"));
|
|
16
|
+
/**
|
|
17
|
+
* Initiate the children of Root / DocumentItem. This is a helper for {@link documentDomItem}.
|
|
18
|
+
*/
|
|
19
|
+
const initChildren = () => {
|
|
20
|
+
const head = document.head;
|
|
21
|
+
const body = document.body;
|
|
22
|
+
const children = [(0, createDomItem_1.default)({
|
|
23
|
+
nodeName: 'head',
|
|
24
|
+
attributes: {},
|
|
25
|
+
element: head,
|
|
26
|
+
children: []
|
|
27
|
+
}), (0, createDomItem_1.default)({
|
|
28
|
+
nodeName: 'body',
|
|
29
|
+
attributes: {},
|
|
30
|
+
element: body,
|
|
31
|
+
children: []
|
|
32
|
+
})];
|
|
33
|
+
if (!head || !body) {
|
|
34
|
+
(0, onBodyLoad_1.default)(() => {
|
|
35
|
+
if (children[1].element === null) {
|
|
36
|
+
children[0].element = document.head;
|
|
37
|
+
children[1].element = document.body;
|
|
38
|
+
}
|
|
39
|
+
return children;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return children;
|
|
43
|
+
};
|
|
44
|
+
exports.default = initChildren;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const createDomItem_1=__importDefault(require("./createDomItem")),onBodyLoad_1=__importDefault(require("si-funciona/dist/helpers/functions/onBodyLoad")),initChildren=()=>{const e=document.head,t=document.body,o=[(0,createDomItem_1.default)({nodeName:"head",attributes:{},element:e,children:[]}),(0,createDomItem_1.default)({nodeName:"body",attributes:{},element:t,children:[]})];return e&&t||(0,onBodyLoad_1.default)(()=>(null===o[1].element&&(o[0].element=document.head,o[1].element=document.body),o)),o};exports.default=initChildren;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DomItem, DomItemRoot } from '../types';
|
|
2
|
+
import type { ListenerFunction } from '../../events/types';
|
|
3
|
+
/**
|
|
4
|
+
* Initiate the Root for DocumentItem. This is primary a helper for {@link documentDomItem}.
|
|
5
|
+
* @param children - Provide an array of Head and Body (usually via {@link initChildren})
|
|
6
|
+
* @param listeners - An object of all event listeners to be registered in the Dom
|
|
7
|
+
*/
|
|
8
|
+
declare const initRoot: (children?: DomItem[], listeners?: Record<string, ListenerFunction>) => DomItemRoot;
|
|
9
|
+
export default initRoot;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
7
|
+
return mod && mod.__esModule ? mod : {
|
|
8
|
+
"default": mod
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
const createDomItem_1 = __importDefault(require("./createDomItem"));
|
|
15
|
+
/**
|
|
16
|
+
* Initiate the Root for DocumentItem. This is primary a helper for {@link documentDomItem}.
|
|
17
|
+
* @param children - Provide an array of Head and Body (usually via {@link initChildren})
|
|
18
|
+
* @param listeners - An object of all event listeners to be registered in the Dom
|
|
19
|
+
*/
|
|
20
|
+
const initRoot = (children = [{}, {}], listeners = {}) => (0, createDomItem_1.default)({
|
|
21
|
+
nodeName: '#document',
|
|
22
|
+
nodeValue: null,
|
|
23
|
+
attributes: {},
|
|
24
|
+
element: document,
|
|
25
|
+
eventActions: listeners,
|
|
26
|
+
eventListeners: {},
|
|
27
|
+
children,
|
|
28
|
+
parentItem: {},
|
|
29
|
+
head: children[0],
|
|
30
|
+
body: children[1]
|
|
31
|
+
});
|
|
32
|
+
exports.default = initRoot;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const createDomItem_1=__importDefault(require("./createDomItem")),initRoot=(e=[{},{}],t={})=>(0,createDomItem_1.default)({nodeName:"#document",nodeValue:null,attributes:{},element:document,eventActions:t,eventListeners:{},children:e,parentItem:{},head:e[0],body:e[1]});exports.default=initRoot;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ChildTest, DomItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
|
|
4
|
+
* This function will check all the children starting from and including item, and run the test function on each
|
|
5
|
+
* child encountered. The return array contains children returned from the test from all levels.
|
|
6
|
+
* WARNING: This is a recursive function.
|
|
7
|
+
* @param item - The DomItem which may have child items matching the attribute
|
|
8
|
+
* criteria
|
|
9
|
+
* @param test - Assess each child, and return the ones which qualify
|
|
10
|
+
*/
|
|
11
|
+
declare const gatherChildItems: (item: DomItem, test: ChildTest) => DomItem[];
|
|
12
|
+
export default gatherChildItems;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
|
|
11
|
+
* This function will check all the children starting from and including item, and run the test function on each
|
|
12
|
+
* child encountered. The return array contains children returned from the test from all levels.
|
|
13
|
+
* WARNING: This is a recursive function.
|
|
14
|
+
* @param item - The DomItem which may have child items matching the attribute
|
|
15
|
+
* criteria
|
|
16
|
+
* @param test - Assess each child, and return the ones which qualify
|
|
17
|
+
*/
|
|
18
|
+
const gatherChildItems = (item, test) => test(item, item.children.reduce((a, b) => a.concat(gatherChildItems(b, test)), []));
|
|
19
|
+
exports.default = gatherChildItems;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const gatherChildItems=(e,t)=>t(e,e.children.reduce((e,r)=>e.concat(gatherChildItems(r,t)),[]));exports.default=gatherChildItems;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ChildTest } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieve the {@link module:domGeneral~testChildItem} function by providing an attribute and value to check.
|
|
4
|
+
* @param attr - Provide the attribute name to be searched
|
|
5
|
+
* @param value - The attribute value to be compared
|
|
6
|
+
*/
|
|
7
|
+
declare const getChildTest: (attr: string, value: unknown) => ChildTest;
|
|
8
|
+
export default getChildTest;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Retrieve the {@link module:domGeneral~testChildItem} function by providing an attribute and value to check.
|
|
11
|
+
* @param attr - Provide the attribute name to be searched
|
|
12
|
+
* @param value - The attribute value to be compared
|
|
13
|
+
*/
|
|
14
|
+
const getChildTest = (attr, value) => (item, gatheredResults) => item.attributes[attr] && item.attributes[attr] === value ? gatheredResults.concat([item]) : gatheredResults;
|
|
15
|
+
exports.default = getChildTest;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const getChildTest=(t,e)=>(s,r)=>s.attributes[t]&&s.attributes[t]===e?r.concat([s]):r;exports.default=getChildTest;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DomItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Helper for getting all domGeneral.DomItems starting at item and carrying the given class, among possibly several
|
|
4
|
+
* space-separated classes on that item - the same membership check as the real DOM's classList.contains, not an
|
|
5
|
+
* exact match of the whole className attribute string (which getChildrenFromAttribute does, and which would miss
|
|
6
|
+
* an item that also carries other classes).
|
|
7
|
+
* @param className - The one class being searched for
|
|
8
|
+
* @param item - The DomItem which may have child items carrying the class
|
|
9
|
+
*/
|
|
10
|
+
declare const getChildrenByClass: (className: string, item?: DomItem) => DomItem[];
|
|
11
|
+
export default getChildrenByClass;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
require("core-js/modules/es.array.includes.js");
|
|
7
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
8
|
+
return mod && mod.__esModule ? mod : {
|
|
9
|
+
"default": mod
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
const documentItem_1 = __importDefault(require("../objects/documentItem"));
|
|
16
|
+
const gatherChildItems_1 = __importDefault(require("./gatherChildItems"));
|
|
17
|
+
/**
|
|
18
|
+
* Helper for getting all domGeneral.DomItems starting at item and carrying the given class, among possibly several
|
|
19
|
+
* space-separated classes on that item - the same membership check as the real DOM's classList.contains, not an
|
|
20
|
+
* exact match of the whole className attribute string (which getChildrenFromAttribute does, and which would miss
|
|
21
|
+
* an item that also carries other classes).
|
|
22
|
+
* @param className - The one class being searched for
|
|
23
|
+
* @param item - The DomItem which may have child items carrying the class
|
|
24
|
+
*/
|
|
25
|
+
const getChildrenByClass = (className, item = (0, documentItem_1.default)().body) => (0, gatherChildItems_1.default)(item, (child, gatheredResults) => (child.attributes.className ?? '').split(' ').includes(className) ? gatheredResults.concat([child]) : gatheredResults);
|
|
26
|
+
exports.default = getChildrenByClass;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("core-js/modules/es.array.includes.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const documentItem_1=__importDefault(require("../objects/documentItem")),gatherChildItems_1=__importDefault(require("./gatherChildItems")),getChildrenByClass=(e,t=(0,documentItem_1.default)().body)=>(0,gatherChildItems_1.default)(t,(t,r)=>(t.attributes.className??"").split(" ").includes(e)?r.concat([t]):r);exports.default=getChildrenByClass;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DomItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Helper for getting all domGeneral.DomItems starting at parent and having specified name attribute
|
|
4
|
+
* @param name - The name searched for
|
|
5
|
+
* @param item - The DomItem which may have child items matching the attribute
|
|
6
|
+
* criteria
|
|
7
|
+
*/
|
|
8
|
+
declare const getChildrenByName: (name: string, item?: DomItem) => DomItem[];
|
|
9
|
+
export default getChildrenByName;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
7
|
+
return mod && mod.__esModule ? mod : {
|
|
8
|
+
"default": mod
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
const si_funciona_1 = __importDefault(require("si-funciona"));
|
|
15
|
+
const getChildrenFromAttribute_1 = __importDefault(require("./getChildrenFromAttribute"));
|
|
16
|
+
/**
|
|
17
|
+
* Helper for getting all domGeneral.DomItems starting at parent and having specified name attribute
|
|
18
|
+
* @param name - The name searched for
|
|
19
|
+
* @param item - The DomItem which may have child items matching the attribute
|
|
20
|
+
* criteria
|
|
21
|
+
*/
|
|
22
|
+
const getChildrenByName = si_funciona_1.default.curry(getChildrenFromAttribute_1.default)('name');
|
|
23
|
+
exports.default = getChildrenByName;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const si_funciona_1=__importDefault(require("si-funciona")),getChildrenFromAttribute_1=__importDefault(require("./getChildrenFromAttribute")),getChildrenByName=si_funciona_1.default.curry(getChildrenFromAttribute_1.default)("name");exports.default=getChildrenByName;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DomItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
|
|
4
|
+
* This function will check all the children starting from item, and scan the attributes
|
|
5
|
+
* property for matches. The returned array contains children matching from all levels.
|
|
6
|
+
* WARNING: This calls a recursive function.
|
|
7
|
+
* @param attr - Provide the attribute name to be searched
|
|
8
|
+
* @param value - The attribute value to be compared
|
|
9
|
+
* @param item - The DomItem which may have child items matching the attribute
|
|
10
|
+
* criteria
|
|
11
|
+
*/
|
|
12
|
+
declare const getChildrenFromAttribute: (attr: string, value: unknown, item?: DomItem) => DomItem[];
|
|
13
|
+
export default getChildrenFromAttribute;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
7
|
+
return mod && mod.__esModule ? mod : {
|
|
8
|
+
"default": mod
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
const documentItem_1 = __importDefault(require("../objects/documentItem"));
|
|
15
|
+
const gatherChildItems_1 = __importDefault(require("./gatherChildItems"));
|
|
16
|
+
const getChildTest_1 = __importDefault(require("./getChildTest"));
|
|
17
|
+
/**
|
|
18
|
+
* A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
|
|
19
|
+
* This function will check all the children starting from item, and scan the attributes
|
|
20
|
+
* property for matches. The returned array contains children matching from all levels.
|
|
21
|
+
* WARNING: This calls a recursive function.
|
|
22
|
+
* @param attr - Provide the attribute name to be searched
|
|
23
|
+
* @param value - The attribute value to be compared
|
|
24
|
+
* @param item - The DomItem which may have child items matching the attribute
|
|
25
|
+
* criteria
|
|
26
|
+
*/
|
|
27
|
+
const getChildrenFromAttribute = (attr, value, item = (0, documentItem_1.default)().body) => (0, gatherChildItems_1.default)(item, (0, getChildTest_1.default)(attr, value));
|
|
28
|
+
exports.default = getChildrenFromAttribute;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const documentItem_1=__importDefault(require("../objects/documentItem")),gatherChildItems_1=__importDefault(require("./gatherChildItems")),getChildTest_1=__importDefault(require("./getChildTest")),getChildrenFromAttribute=(e,t,r=(0,documentItem_1.default)().body)=>(0,gatherChildItems_1.default)(r,(0,getChildTest_1.default)(e,t));exports.default=getChildrenFromAttribute;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DomItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Find the item (item itself, or one of its descendants) whose element is the one given, or null when none match.
|
|
4
|
+
* Only searches item and its own subtree: an event's target is always the item a listener is attached to, or one of
|
|
5
|
+
* its descendants (that is what bubbling means), so there is never a reason to search outside it.
|
|
6
|
+
* WARNING: This is a recursive function.
|
|
7
|
+
* @param item - The DomItem (and its subtree) to search.
|
|
8
|
+
* @param element - The real element to match against each item's element.
|
|
9
|
+
*/
|
|
10
|
+
declare const getItemByElement: (item: DomItem, element: EventTarget | null) => DomItem | null;
|
|
11
|
+
export default getItemByElement;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* Find the item (item itself, or one of its descendants) whose element is the one given, or null when none match.
|
|
11
|
+
* Only searches item and its own subtree: an event's target is always the item a listener is attached to, or one of
|
|
12
|
+
* its descendants (that is what bubbling means), so there is never a reason to search outside it.
|
|
13
|
+
* WARNING: This is a recursive function.
|
|
14
|
+
* @param item - The DomItem (and its subtree) to search.
|
|
15
|
+
* @param element - The real element to match against each item's element.
|
|
16
|
+
*/
|
|
17
|
+
const getItemByElement = (item, element) => {
|
|
18
|
+
if (item.element === element) {
|
|
19
|
+
return item;
|
|
20
|
+
}
|
|
21
|
+
for (const child of item.children) {
|
|
22
|
+
const found = getItemByElement(child, element);
|
|
23
|
+
if (found) {
|
|
24
|
+
return found;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
exports.default = getItemByElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const getItemByElement=(e,t)=>{if(e.element===t)return e;for(const n of e.children){const e=getItemByElement(n,t);if(e)return e}return null};exports.default=getItemByElement;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DomItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Helper for getting all domGeneral.DomItems going up from item's parent, each one carrying the given class, among
|
|
4
|
+
* possibly several space-separated classes on that item - the same membership check as the real DOM's
|
|
5
|
+
* classList.contains, not an exact match of the whole className attribute string (which getParentsFromAttribute
|
|
6
|
+
* does, and which would miss a parent that also carries other classes).
|
|
7
|
+
* WARNING: This is a recursive function.
|
|
8
|
+
* @param className - The one class being searched for
|
|
9
|
+
* @param item - The DomItem which may have parent items carrying the class
|
|
10
|
+
*/
|
|
11
|
+
declare const getParentsByClass: (className: string, item?: DomItem) => DomItem[];
|
|
12
|
+
export default getParentsByClass;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
require("core-js/modules/es.array.includes.js");
|
|
7
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
8
|
+
return mod && mod.__esModule ? mod : {
|
|
9
|
+
"default": mod
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
const documentItem_1 = __importDefault(require("../objects/documentItem"));
|
|
16
|
+
const si_funciona_1 = __importDefault(require("si-funciona"));
|
|
17
|
+
/**
|
|
18
|
+
* Helper for getting all domGeneral.DomItems going up from item's parent, each one carrying the given class, among
|
|
19
|
+
* possibly several space-separated classes on that item - the same membership check as the real DOM's
|
|
20
|
+
* classList.contains, not an exact match of the whole className attribute string (which getParentsFromAttribute
|
|
21
|
+
* does, and which would miss a parent that also carries other classes).
|
|
22
|
+
* WARNING: This is a recursive function.
|
|
23
|
+
* @param className - The one class being searched for
|
|
24
|
+
* @param item - The DomItem which may have parent items carrying the class
|
|
25
|
+
*/
|
|
26
|
+
const getParentsByClass = (className, item = (0, documentItem_1.default)().body) => {
|
|
27
|
+
if (item.parentItem === null) {
|
|
28
|
+
if (item.nodeName === '#document') {
|
|
29
|
+
throw new Error('Root parent item must be an empty object, null reference found.');
|
|
30
|
+
}
|
|
31
|
+
throw new Error('Detached child, missing parentItem reference. Use empty object if this is the root item.');
|
|
32
|
+
}
|
|
33
|
+
if (si_funciona_1.default.emptyObject(item.parentItem)) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
const parent = item.parentItem;
|
|
37
|
+
const carriesClass = (parent.attributes.className ?? '').split(' ').includes(className);
|
|
38
|
+
return carriesClass ? getParentsByClass(className, parent).concat([parent]) : getParentsByClass(className, parent);
|
|
39
|
+
};
|
|
40
|
+
exports.default = getParentsByClass;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("core-js/modules/es.array.includes.js");var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const documentItem_1=__importDefault(require("../objects/documentItem")),si_funciona_1=__importDefault(require("si-funciona")),getParentsByClass=(e,t=(0,documentItem_1.default)().body)=>{if(null===t.parentItem){if("#document"===t.nodeName)throw new Error("Root parent item must be an empty object, null reference found.");throw new Error("Detached child, missing parentItem reference. Use empty object if this is the root item.")}if(si_funciona_1.default.emptyObject(t.parentItem))return[];const r=t.parentItem;return(r.attributes.className??"").split(" ").includes(e)?getParentsByClass(e,r).concat([r]):getParentsByClass(e,r)};exports.default=getParentsByClass;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DomItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Helper for getting all domGeneral.DomItems starting at child and having specified name attribute
|
|
4
|
+
* @param name - The name to search for
|
|
5
|
+
* @param item - The DomItem which may have parent items matching the
|
|
6
|
+
* attribute criteria
|
|
7
|
+
*/
|
|
8
|
+
declare const getParentsByName: (name: string, item?: DomItem) => DomItem[];
|
|
9
|
+
export default getParentsByName;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
7
|
+
return mod && mod.__esModule ? mod : {
|
|
8
|
+
"default": mod
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
const si_funciona_1 = __importDefault(require("si-funciona"));
|
|
15
|
+
const getParentsFromAttribute_1 = __importDefault(require("./getParentsFromAttribute"));
|
|
16
|
+
/**
|
|
17
|
+
* Helper for getting all domGeneral.DomItems starting at child and having specified name attribute
|
|
18
|
+
* @param name - The name to search for
|
|
19
|
+
* @param item - The DomItem which may have parent items matching the
|
|
20
|
+
* attribute criteria
|
|
21
|
+
*/
|
|
22
|
+
const getParentsByName = si_funciona_1.default.curry(getParentsFromAttribute_1.default)('name');
|
|
23
|
+
exports.default = getParentsByName;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const si_funciona_1=__importDefault(require("si-funciona")),getParentsFromAttribute_1=__importDefault(require("./getParentsFromAttribute")),getParentsByName=si_funciona_1.default.curry(getParentsFromAttribute_1.default)("name");exports.default=getParentsByName;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DomItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Helper for getting all domGeneral.DomItems starting at child and having specified nodeName
|
|
4
|
+
* @param nodeName - The nodeName to search for
|
|
5
|
+
* @param item - The DomItem which may have parent items matching the
|
|
6
|
+
* attribute criteria
|
|
7
|
+
*/
|
|
8
|
+
declare const getParentsByTagName: (nodeName: string, item?: DomItem) => DomItem[];
|
|
9
|
+
export default getParentsByTagName;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
7
|
+
return mod && mod.__esModule ? mod : {
|
|
8
|
+
"default": mod
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
const si_funciona_1 = __importDefault(require("si-funciona"));
|
|
15
|
+
const getParentsFromAttribute_1 = __importDefault(require("./getParentsFromAttribute"));
|
|
16
|
+
/**
|
|
17
|
+
* Helper for getting all domGeneral.DomItems starting at child and having specified nodeName
|
|
18
|
+
* @param nodeName - The nodeName to search for
|
|
19
|
+
* @param item - The DomItem which may have parent items matching the
|
|
20
|
+
* attribute criteria
|
|
21
|
+
*/
|
|
22
|
+
const getParentsByTagName = si_funciona_1.default.curry(getParentsFromAttribute_1.default)('nodeName');
|
|
23
|
+
exports.default = getParentsByTagName;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const si_funciona_1=__importDefault(require("si-funciona")),getParentsFromAttribute_1=__importDefault(require("./getParentsFromAttribute")),getParentsByTagName=si_funciona_1.default.curry(getParentsFromAttribute_1.default)("nodeName");exports.default=getParentsByTagName;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DomItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
|
|
4
|
+
* This function will check all the children starting from item, and scan the attributes
|
|
5
|
+
* property for matches. The return array contains children matching from all levels.
|
|
6
|
+
* WARNING: This is a recursive function.
|
|
7
|
+
* @param attr - Provide the attribute name to be searched
|
|
8
|
+
* @param value - The attribute value to be compared
|
|
9
|
+
* @param item - The DomItem which may have parent items matching the
|
|
10
|
+
* attribute criteria
|
|
11
|
+
*/
|
|
12
|
+
declare const getParentsFromAttribute: (attr: string, value: unknown, item?: DomItem) => DomItem[];
|
|
13
|
+
export default getParentsFromAttribute;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
7
|
+
return mod && mod.__esModule ? mod : {
|
|
8
|
+
"default": mod
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
const documentItem_1 = __importDefault(require("../objects/documentItem"));
|
|
15
|
+
const si_funciona_1 = __importDefault(require("si-funciona"));
|
|
16
|
+
/**
|
|
17
|
+
* A selector function for retrieving existing child domGeneral.DomItems from the given parent item.
|
|
18
|
+
* This function will check all the children starting from item, and scan the attributes
|
|
19
|
+
* property for matches. The return array contains children matching from all levels.
|
|
20
|
+
* WARNING: This is a recursive function.
|
|
21
|
+
* @param attr - Provide the attribute name to be searched
|
|
22
|
+
* @param value - The attribute value to be compared
|
|
23
|
+
* @param item - The DomItem which may have parent items matching the
|
|
24
|
+
* attribute criteria
|
|
25
|
+
*/
|
|
26
|
+
const getParentsFromAttribute = (attr, value, item = (0, documentItem_1.default)().body) => {
|
|
27
|
+
if (item.parentItem === null) {
|
|
28
|
+
if (item.nodeName === '#document') {
|
|
29
|
+
throw new Error('Root parent item must be an empty object, null reference found.');
|
|
30
|
+
}
|
|
31
|
+
throw new Error('Detached child, missing parentItem reference. Use empty object if this is the root item.');
|
|
32
|
+
}
|
|
33
|
+
if (si_funciona_1.default.emptyObject(item.parentItem)) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
const parent = item.parentItem;
|
|
37
|
+
return (parent.attributes[attr] || item[attr] || false) === value ? getParentsFromAttribute(attr, value, parent).concat([parent]) : getParentsFromAttribute(attr, value, parent);
|
|
38
|
+
};
|
|
39
|
+
exports.default = getParentsFromAttribute;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const documentItem_1=__importDefault(require("../objects/documentItem")),si_funciona_1=__importDefault(require("si-funciona")),getParentsFromAttribute=(e,t,r=(0,documentItem_1.default)().body)=>{if(null===r.parentItem){if("#document"===r.nodeName)throw new Error("Root parent item must be an empty object, null reference found.");throw new Error("Detached child, missing parentItem reference. Use empty object if this is the root item.")}if(si_funciona_1.default.emptyObject(r.parentItem))return[];const n=r.parentItem;return(n.attributes[e]||r[e]||!1)===t?getParentsFromAttribute(e,t,n).concat([n]):getParentsFromAttribute(e,t,n)};exports.default=getParentsFromAttribute;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TraitDefinition } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Describe a trait so treeloom knows what it is at runtime: the properties it puts on an item (so they can be left out
|
|
4
|
+
* of json when they only make sense where the item lives), and the defaults a new item gets. Types are added
|
|
5
|
+
* separately, by merging into TraitRegistry.
|
|
6
|
+
* @param name - The name of the trait, prefixed by the package which defines it: matrix.row
|
|
7
|
+
* @param definition - The properties the trait puts on an item, whether they are serializable and the defaults.
|
|
8
|
+
*/
|
|
9
|
+
declare const defineTrait: (name: string, definition: TraitDefinition) => TraitDefinition;
|
|
10
|
+
export default defineTrait;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
|
|
7
|
+
return mod && mod.__esModule ? mod : {
|
|
8
|
+
"default": mod
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: true
|
|
13
|
+
});
|
|
14
|
+
const definitions_1 = __importDefault(require("./definitions"));
|
|
15
|
+
/**
|
|
16
|
+
* Describe a trait so treeloom knows what it is at runtime: the properties it puts on an item (so they can be left out
|
|
17
|
+
* of json when they only make sense where the item lives), and the defaults a new item gets. Types are added
|
|
18
|
+
* separately, by merging into TraitRegistry.
|
|
19
|
+
* @param name - The name of the trait, prefixed by the package which defines it: matrix.row
|
|
20
|
+
* @param definition - The properties the trait puts on an item, whether they are serializable and the defaults.
|
|
21
|
+
*/
|
|
22
|
+
const defineTrait = (name, definition) => {
|
|
23
|
+
definitions_1.default.set(name, definition);
|
|
24
|
+
return definition;
|
|
25
|
+
};
|
|
26
|
+
exports.default = defineTrait;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const definitions_1=__importDefault(require("./definitions")),defineTrait=(e,t)=>(definitions_1.default.set(e,t),t);exports.default=defineTrait;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TraitDefinition } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* What each trait is at runtime, by name. render is the one treeloom brings; other libraries add theirs with
|
|
4
|
+
* defineTrait.
|
|
5
|
+
*/
|
|
6
|
+
declare const definitions: Map<string, TraitDefinition>;
|
|
7
|
+
export default definitions;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
4
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
5
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* What each trait is at runtime, by name. render is the one treeloom brings; other libraries add theirs with
|
|
11
|
+
* defineTrait.
|
|
12
|
+
*/
|
|
13
|
+
const definitions = new Map([['render', {
|
|
14
|
+
keys: ['element', 'activeListeners'],
|
|
15
|
+
serializable: false,
|
|
16
|
+
defaults: () => ({
|
|
17
|
+
element: null
|
|
18
|
+
})
|
|
19
|
+
}]]);
|
|
20
|
+
exports.default = definitions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const definitions=new Map([["render",{keys:["element","activeListeners"],serializable:!1,defaults:()=>({element:null})}]]);exports.default=definitions;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CoreItem } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* The properties an item has only because of its traits, and which do not belong in json (the element of the render
|
|
4
|
+
* trait, for one).
|
|
5
|
+
* @param item - The item to look at.
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
declare const getNonSerializableKeys: (item: CoreItem) => string[];
|
|
9
|
+
export default getNonSerializableKeys;
|