treeloom 0.0.0-stage → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +72 -2
  3. package/browser/treeloom.js +11006 -0
  4. package/browser/treeloom.min.js +1 -0
  5. package/browser/treeloomRenderOnly.js +10530 -0
  6. package/browser/treeloomRenderOnly.min.js +1 -0
  7. package/dist/deflate/domItemToJson.d.ts +14 -0
  8. package/dist/deflate/domItemToJson.js +43 -0
  9. package/dist/deflate/domItemToJson.min.js +1 -0
  10. package/dist/deflate/index.d.ts +7 -0
  11. package/dist/deflate/index.js +19 -0
  12. package/dist/deflate/index.min.js +1 -0
  13. package/dist/deflate/removeEmptyProperties.d.ts +8 -0
  14. package/dist/deflate/removeEmptyProperties.js +43 -0
  15. package/dist/deflate/removeEmptyProperties.min.js +1 -0
  16. package/dist/diff/createChangeList.d.ts +9 -0
  17. package/dist/diff/createChangeList.js +44 -0
  18. package/dist/diff/createChangeList.min.js +1 -0
  19. package/dist/diff/domItemChanges.d.ts +9 -0
  20. package/dist/diff/domItemChanges.js +154 -0
  21. package/dist/diff/domItemChanges.min.js +1 -0
  22. package/dist/diff/domItemHasAttribute.d.ts +11 -0
  23. package/dist/diff/domItemHasAttribute.js +63 -0
  24. package/dist/diff/domItemHasAttribute.min.js +1 -0
  25. package/dist/diff/elementChanges.d.ts +10 -0
  26. package/dist/diff/elementChanges.js +151 -0
  27. package/dist/diff/elementChanges.min.js +1 -0
  28. package/dist/diff/elementHasAttribute.d.ts +10 -0
  29. package/dist/diff/elementHasAttribute.js +70 -0
  30. package/dist/diff/elementHasAttribute.min.js +1 -0
  31. package/dist/diff/getAssignedStyles.d.ts +9 -0
  32. package/dist/diff/getAssignedStyles.js +22 -0
  33. package/dist/diff/getAssignedStyles.min.js +1 -0
  34. package/dist/diff/index.d.ts +9 -0
  35. package/dist/diff/index.js +27 -0
  36. package/dist/diff/index.min.js +1 -0
  37. package/dist/diff/types.d.ts +17 -0
  38. package/dist/diff/types.js +8 -0
  39. package/dist/diff/types.min.js +1 -0
  40. package/dist/domItem/index.d.ts +34 -0
  41. package/dist/domItem/index.js +81 -0
  42. package/dist/domItem/index.min.js +1 -0
  43. package/dist/domItem/objects/addDomItemProperties.d.ts +7 -0
  44. package/dist/domItem/objects/addDomItemProperties.js +27 -0
  45. package/dist/domItem/objects/addDomItemProperties.min.js +1 -0
  46. package/dist/domItem/objects/createCoreItem.d.ts +9 -0
  47. package/dist/domItem/objects/createCoreItem.js +53 -0
  48. package/dist/domItem/objects/createCoreItem.min.js +1 -0
  49. package/dist/domItem/objects/createDomItem.d.ts +10 -0
  50. package/dist/domItem/objects/createDomItem.js +40 -0
  51. package/dist/domItem/objects/createDomItem.min.js +1 -0
  52. package/dist/domItem/objects/documentDomItem.d.ts +12 -0
  53. package/dist/domItem/objects/documentDomItem.js +36 -0
  54. package/dist/domItem/objects/documentDomItem.min.js +1 -0
  55. package/dist/domItem/objects/documentItem.d.ts +18 -0
  56. package/dist/domItem/objects/documentItem.js +40 -0
  57. package/dist/domItem/objects/documentItem.min.js +1 -0
  58. package/dist/domItem/objects/initChildren.d.ts +6 -0
  59. package/dist/domItem/objects/initChildren.js +44 -0
  60. package/dist/domItem/objects/initChildren.min.js +1 -0
  61. package/dist/domItem/objects/initRoot.d.ts +9 -0
  62. package/dist/domItem/objects/initRoot.js +32 -0
  63. package/dist/domItem/objects/initRoot.min.js +1 -0
  64. package/dist/domItem/query/gatherChildItems.d.ts +12 -0
  65. package/dist/domItem/query/gatherChildItems.js +19 -0
  66. package/dist/domItem/query/gatherChildItems.min.js +1 -0
  67. package/dist/domItem/query/getChildTest.d.ts +8 -0
  68. package/dist/domItem/query/getChildTest.js +15 -0
  69. package/dist/domItem/query/getChildTest.min.js +1 -0
  70. package/dist/domItem/query/getChildrenByClass.d.ts +11 -0
  71. package/dist/domItem/query/getChildrenByClass.js +26 -0
  72. package/dist/domItem/query/getChildrenByClass.min.js +1 -0
  73. package/dist/domItem/query/getChildrenByName.d.ts +9 -0
  74. package/dist/domItem/query/getChildrenByName.js +23 -0
  75. package/dist/domItem/query/getChildrenByName.min.js +1 -0
  76. package/dist/domItem/query/getChildrenFromAttribute.d.ts +13 -0
  77. package/dist/domItem/query/getChildrenFromAttribute.js +28 -0
  78. package/dist/domItem/query/getChildrenFromAttribute.min.js +1 -0
  79. package/dist/domItem/query/getItemByElement.d.ts +11 -0
  80. package/dist/domItem/query/getItemByElement.js +29 -0
  81. package/dist/domItem/query/getItemByElement.min.js +1 -0
  82. package/dist/domItem/query/getParentsByClass.d.ts +12 -0
  83. package/dist/domItem/query/getParentsByClass.js +40 -0
  84. package/dist/domItem/query/getParentsByClass.min.js +1 -0
  85. package/dist/domItem/query/getParentsByName.d.ts +9 -0
  86. package/dist/domItem/query/getParentsByName.js +23 -0
  87. package/dist/domItem/query/getParentsByName.min.js +1 -0
  88. package/dist/domItem/query/getParentsByTagName.d.ts +9 -0
  89. package/dist/domItem/query/getParentsByTagName.js +23 -0
  90. package/dist/domItem/query/getParentsByTagName.min.js +1 -0
  91. package/dist/domItem/query/getParentsFromAttribute.d.ts +13 -0
  92. package/dist/domItem/query/getParentsFromAttribute.js +39 -0
  93. package/dist/domItem/query/getParentsFromAttribute.min.js +1 -0
  94. package/dist/domItem/traits/defineTrait.d.ts +10 -0
  95. package/dist/domItem/traits/defineTrait.js +26 -0
  96. package/dist/domItem/traits/defineTrait.min.js +1 -0
  97. package/dist/domItem/traits/definitions.d.ts +7 -0
  98. package/dist/domItem/traits/definitions.js +20 -0
  99. package/dist/domItem/traits/definitions.min.js +1 -0
  100. package/dist/domItem/traits/getNonSerializableKeys.d.ts +9 -0
  101. package/dist/domItem/traits/getNonSerializableKeys.js +25 -0
  102. package/dist/domItem/traits/getNonSerializableKeys.min.js +1 -0
  103. package/dist/domItem/traits/getTraitDefinition.d.ts +7 -0
  104. package/dist/domItem/traits/getTraitDefinition.js +20 -0
  105. package/dist/domItem/traits/getTraitDefinition.min.js +1 -0
  106. package/dist/domItem/traits/hasTrait.d.ts +8 -0
  107. package/dist/domItem/traits/hasTrait.js +15 -0
  108. package/dist/domItem/traits/hasTrait.min.js +1 -0
  109. package/dist/domItem/traits/hasTraits.d.ts +9 -0
  110. package/dist/domItem/traits/hasTraits.js +16 -0
  111. package/dist/domItem/traits/hasTraits.min.js +1 -0
  112. package/dist/domItem/traits/isDomItem.d.ts +8 -0
  113. package/dist/domItem/traits/isDomItem.js +21 -0
  114. package/dist/domItem/traits/isDomItem.min.js +1 -0
  115. package/dist/domItem/traits/withTrait.d.ts +11 -0
  116. package/dist/domItem/traits/withTrait.js +30 -0
  117. package/dist/domItem/traits/withTrait.min.js +1 -0
  118. package/dist/domItem/tree/appendChild.d.ts +8 -0
  119. package/dist/domItem/tree/appendChild.js +19 -0
  120. package/dist/domItem/tree/appendChild.min.js +1 -0
  121. package/dist/domItem/tree/getItemByPath.d.ts +10 -0
  122. package/dist/domItem/tree/getItemByPath.js +23 -0
  123. package/dist/domItem/tree/getItemByPath.min.js +1 -0
  124. package/dist/domItem/tree/getItemPath.d.ts +9 -0
  125. package/dist/domItem/tree/getItemPath.js +31 -0
  126. package/dist/domItem/tree/getItemPath.min.js +1 -0
  127. package/dist/domItem/tree/getTopParentItem.d.ts +8 -0
  128. package/dist/domItem/tree/getTopParentItem.js +29 -0
  129. package/dist/domItem/tree/getTopParentItem.min.js +1 -0
  130. package/dist/domItem/tree/insertChild.d.ts +11 -0
  131. package/dist/domItem/tree/insertChild.js +22 -0
  132. package/dist/domItem/tree/insertChild.min.js +1 -0
  133. package/dist/domItem/tree/itemIdIndex.d.ts +43 -0
  134. package/dist/domItem/tree/itemIdIndex.js +118 -0
  135. package/dist/domItem/tree/itemIdIndex.min.js +1 -0
  136. package/dist/domItem/tree/removeChild.d.ts +8 -0
  137. package/dist/domItem/tree/removeChild.js +21 -0
  138. package/dist/domItem/tree/removeChild.min.js +1 -0
  139. package/dist/domItem/tree/setParentItemReferences.d.ts +7 -0
  140. package/dist/domItem/tree/setParentItemReferences.js +24 -0
  141. package/dist/domItem/tree/setParentItemReferences.min.js +1 -0
  142. package/dist/domItem/types.d.ts +131 -0
  143. package/dist/domItem/types.js +8 -0
  144. package/dist/domItem/types.min.js +1 -0
  145. package/dist/events/functions/activateListener.d.ts +10 -0
  146. package/dist/events/functions/activateListener.js +45 -0
  147. package/dist/events/functions/activateListener.min.js +1 -0
  148. package/dist/events/functions/addEventListener.d.ts +23 -0
  149. package/dist/events/functions/addEventListener.js +54 -0
  150. package/dist/events/functions/addEventListener.min.js +1 -0
  151. package/dist/events/functions/applyActiveListeners.d.ts +9 -0
  152. package/dist/events/functions/applyActiveListeners.js +52 -0
  153. package/dist/events/functions/applyActiveListeners.min.js +1 -0
  154. package/dist/events/functions/assignListener.d.ts +12 -0
  155. package/dist/events/functions/assignListener.js +39 -0
  156. package/dist/events/functions/assignListener.min.js +1 -0
  157. package/dist/events/functions/bindAllListeners.d.ts +10 -0
  158. package/dist/events/functions/bindAllListeners.js +28 -0
  159. package/dist/events/functions/bindAllListeners.min.js +1 -0
  160. package/dist/events/functions/bindElementListeners.d.ts +7 -0
  161. package/dist/events/functions/bindElementListeners.js +34 -0
  162. package/dist/events/functions/bindElementListeners.min.js +1 -0
  163. package/dist/events/functions/bindListeners.d.ts +9 -0
  164. package/dist/events/functions/bindListeners.js +23 -0
  165. package/dist/events/functions/bindListeners.min.js +1 -0
  166. package/dist/events/functions/deactivateListener.d.ts +13 -0
  167. package/dist/events/functions/deactivateListener.js +58 -0
  168. package/dist/events/functions/deactivateListener.min.js +1 -0
  169. package/dist/events/functions/deactivateListeners.d.ts +7 -0
  170. package/dist/events/functions/deactivateListeners.js +22 -0
  171. package/dist/events/functions/deactivateListeners.min.js +1 -0
  172. package/dist/events/functions/findEventListener.d.ts +22 -0
  173. package/dist/events/functions/findEventListener.js +61 -0
  174. package/dist/events/functions/findEventListener.min.js +1 -0
  175. package/dist/events/functions/fullAddEventListener.d.ts +20 -0
  176. package/dist/events/functions/fullAddEventListener.js +45 -0
  177. package/dist/events/functions/fullAddEventListener.min.js +1 -0
  178. package/dist/events/functions/fullRemoveEventListener.d.ts +22 -0
  179. package/dist/events/functions/fullRemoveEventListener.js +37 -0
  180. package/dist/events/functions/fullRemoveEventListener.min.js +1 -0
  181. package/dist/events/functions/listenerOptions.d.ts +12 -0
  182. package/dist/events/functions/listenerOptions.js +31 -0
  183. package/dist/events/functions/listenerOptions.min.js +1 -0
  184. package/dist/events/functions/makeEventHandler.d.ts +10 -0
  185. package/dist/events/functions/makeEventHandler.js +23 -0
  186. package/dist/events/functions/makeEventHandler.min.js +1 -0
  187. package/dist/events/functions/makeForwardingListener.d.ts +11 -0
  188. package/dist/events/functions/makeForwardingListener.js +46 -0
  189. package/dist/events/functions/makeForwardingListener.min.js +1 -0
  190. package/dist/events/functions/receiveForwardedEvent.d.ts +23 -0
  191. package/dist/events/functions/receiveForwardedEvent.js +40 -0
  192. package/dist/events/functions/receiveForwardedEvent.min.js +1 -0
  193. package/dist/events/functions/registerListener.d.ts +11 -0
  194. package/dist/events/functions/registerListener.js +25 -0
  195. package/dist/events/functions/registerListener.min.js +1 -0
  196. package/dist/events/functions/registerListeners.d.ts +10 -0
  197. package/dist/events/functions/registerListeners.js +26 -0
  198. package/dist/events/functions/registerListeners.min.js +1 -0
  199. package/dist/events/functions/removeEventListener.d.ts +18 -0
  200. package/dist/events/functions/removeEventListener.js +42 -0
  201. package/dist/events/functions/removeEventListener.min.js +1 -0
  202. package/dist/events/functions/retrieveListener.d.ts +14 -0
  203. package/dist/events/functions/retrieveListener.js +39 -0
  204. package/dist/events/functions/retrieveListener.min.js +1 -0
  205. package/dist/events/functions/revokeActiveListeners.d.ts +12 -0
  206. package/dist/events/functions/revokeActiveListeners.js +54 -0
  207. package/dist/events/functions/revokeActiveListeners.min.js +1 -0
  208. package/dist/events/functions/setForwardEvents.d.ts +11 -0
  209. package/dist/events/functions/setForwardEvents.js +26 -0
  210. package/dist/events/functions/setForwardEvents.min.js +1 -0
  211. package/dist/events/functions/unassignListener.d.ts +12 -0
  212. package/dist/events/functions/unassignListener.js +32 -0
  213. package/dist/events/functions/unassignListener.min.js +1 -0
  214. package/dist/events/index.d.ts +37 -0
  215. package/dist/events/index.js +72 -0
  216. package/dist/events/index.min.js +1 -0
  217. package/dist/events/objects/createEventListener.d.ts +13 -0
  218. package/dist/events/objects/createEventListener.js +30 -0
  219. package/dist/events/objects/createEventListener.min.js +1 -0
  220. package/dist/events/objects/createEventProxy.d.ts +10 -0
  221. package/dist/events/objects/createEventProxy.js +48 -0
  222. package/dist/events/objects/createEventProxy.min.js +1 -0
  223. package/dist/events/objects/createEventResponder.d.ts +8 -0
  224. package/dist/events/objects/createEventResponder.js +27 -0
  225. package/dist/events/objects/createEventResponder.min.js +1 -0
  226. package/dist/events/objects/options/getListenerOptions.d.ts +6 -0
  227. package/dist/events/objects/options/getListenerOptions.js +22 -0
  228. package/dist/events/objects/options/getListenerOptions.min.js +1 -0
  229. package/dist/events/objects/options/numberToOptions.d.ts +8 -0
  230. package/dist/events/objects/options/numberToOptions.js +21 -0
  231. package/dist/events/objects/options/numberToOptions.min.js +1 -0
  232. package/dist/events/objects/options/optionsToNumber.d.ts +9 -0
  233. package/dist/events/objects/options/optionsToNumber.js +27 -0
  234. package/dist/events/objects/options/optionsToNumber.min.js +1 -0
  235. package/dist/events/objects/options.d.ts +6 -0
  236. package/dist/events/objects/options.js +24 -0
  237. package/dist/events/objects/options.min.js +1 -0
  238. package/dist/events/types.d.ts +87 -0
  239. package/dist/events/types.js +8 -0
  240. package/dist/events/types.min.js +1 -0
  241. package/dist/inflate/index.d.ts +4 -0
  242. package/dist/inflate/index.js +17 -0
  243. package/dist/inflate/index.min.js +1 -0
  244. package/dist/inflate/jsonToDomItem.d.ts +7 -0
  245. package/dist/inflate/jsonToDomItem.js +30 -0
  246. package/dist/inflate/jsonToDomItem.min.js +1 -0
  247. package/dist/main.d.ts +2 -0
  248. package/dist/main.js +24 -0
  249. package/dist/main.min.js +1 -0
  250. package/dist/render/generateElement.d.ts +7 -0
  251. package/dist/render/generateElement.js +41 -0
  252. package/dist/render/generateElement.min.js +1 -0
  253. package/dist/render/index.d.ts +8 -0
  254. package/dist/render/index.js +25 -0
  255. package/dist/render/index.min.js +1 -0
  256. package/dist/render/renderHtml.d.ts +16 -0
  257. package/dist/render/renderHtml.js +57 -0
  258. package/dist/render/renderHtml.min.js +1 -0
  259. package/dist/render/updateChildNodes.d.ts +7 -0
  260. package/dist/render/updateChildNodes.js +56 -0
  261. package/dist/render/updateChildNodes.min.js +1 -0
  262. package/dist/render/updateElement.d.ts +14 -0
  263. package/dist/render/updateElement.js +110 -0
  264. package/dist/render/updateElement.min.js +1 -0
  265. package/dist/render/updateElements.d.ts +9 -0
  266. package/dist/render/updateElements.js +33 -0
  267. package/dist/render/updateElements.min.js +1 -0
  268. package/dist/renderOnly.d.ts +2 -0
  269. package/dist/renderOnly.js +27 -0
  270. package/dist/renderOnly.min.js +1 -0
  271. package/dist/sync/index.d.ts +6 -0
  272. package/dist/sync/index.js +21 -0
  273. package/dist/sync/index.min.js +1 -0
  274. package/dist/sync/updateChildren.d.ts +7 -0
  275. package/dist/sync/updateChildren.js +38 -0
  276. package/dist/sync/updateChildren.min.js +1 -0
  277. package/dist/sync/updateDomItem.d.ts +8 -0
  278. package/dist/sync/updateDomItem.js +49 -0
  279. package/dist/sync/updateDomItem.min.js +1 -0
  280. package/dist/sync/updateDomItems.d.ts +9 -0
  281. package/dist/sync/updateDomItems.js +33 -0
  282. package/dist/sync/updateDomItems.min.js +1 -0
  283. package/package.json +74 -4
@@ -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;
@@ -0,0 +1,25 @@
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
+ * The properties an item has only because of its traits, and which do not belong in json (the element of the render
17
+ * trait, for one).
18
+ * @param item - The item to look at.
19
+ * @private
20
+ */
21
+ const getNonSerializableKeys = item => Object.keys(item.has ?? {}).flatMap(trait => {
22
+ const definition = definitions_1.default.get(trait);
23
+ return definition && definition.serializable === false ? definition.keys : [];
24
+ });
25
+ exports.default = getNonSerializableKeys;
@@ -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")),getNonSerializableKeys=e=>Object.keys(e.has??{}).flatMap(e=>{const t=definitions_1.default.get(e);return t&&!1===t.serializable?t.keys:[]});exports.default=getNonSerializableKeys;
@@ -0,0 +1,7 @@
1
+ import type { TraitDefinition } from '../types';
2
+ /**
3
+ * The runtime definition of a trait, if it was defined.
4
+ * @param name - The name of the trait.
5
+ */
6
+ declare const getTraitDefinition: (name: string) => TraitDefinition | undefined;
7
+ export default getTraitDefinition;
@@ -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
+ 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
+ * The runtime definition of a trait, if it was defined.
17
+ * @param name - The name of the trait.
18
+ */
19
+ const getTraitDefinition = name => definitions_1.default.get(name);
20
+ exports.default = getTraitDefinition;
@@ -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")),getTraitDefinition=e=>definitions_1.default.get(e);exports.default=getTraitDefinition;
@@ -0,0 +1,8 @@
1
+ import type { CoreItem, TraitName, WithTraits } from '../types';
2
+ /**
3
+ * Whether an item has a trait. It is also a type guard: after the check the trait's data is typed on the item.
4
+ * @param item - The item to check.
5
+ * @param trait - The name of the trait.
6
+ */
7
+ declare const hasTrait: <Trait extends TraitName>(item: CoreItem, trait: Trait) => item is CoreItem & WithTraits<Trait>;
8
+ export default hasTrait;
@@ -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
+ * Whether an item has a trait. It is also a type guard: after the check the trait's data is typed on the item.
11
+ * @param item - The item to check.
12
+ * @param trait - The name of the trait.
13
+ */
14
+ const hasTrait = (item, trait) => (item.has ?? {})[trait] === true;
15
+ exports.default = hasTrait;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const hasTrait=(e,t)=>!0===(e.has??{})[t];exports.default=hasTrait;
@@ -0,0 +1,9 @@
1
+ import type { CoreItem, TraitName, WithTraits } from '../types';
2
+ /**
3
+ * Whether an item has all of these traits. It is also a type guard: after the check the data of every one of the traits
4
+ * is typed on the item.
5
+ * @param item - The item to check.
6
+ * @param traits - The names of the traits.
7
+ */
8
+ declare const hasTraits: <Trait extends TraitName>(item: CoreItem, ...traits: Trait[]) => item is CoreItem & WithTraits<Trait>;
9
+ export default hasTraits;
@@ -0,0 +1,16 @@
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
+ * Whether an item has all of these traits. It is also a type guard: after the check the data of every one of the traits
11
+ * is typed on the item.
12
+ * @param item - The item to check.
13
+ * @param traits - The names of the traits.
14
+ */
15
+ const hasTraits = (item, ...traits) => traits.every(trait => (item.has ?? {})[trait] === true);
16
+ exports.default = hasTraits;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const hasTraits=(e,...s)=>s.every(s=>!0===(e.has??{})[s]);exports.default=hasTraits;
@@ -0,0 +1,8 @@
1
+ import type { CoreItem, DomItem } from '../types';
2
+ /**
3
+ * Whether an item, and every item below it, has the render trait: the tree treeloom's render and sync functions work
4
+ * on. hasTrait only checks the one item, so use this where a tree comes from somewhere else. It is also a type guard.
5
+ * @param item - The item at the top of the tree to check.
6
+ */
7
+ declare const isDomItem: (item: CoreItem) => item is DomItem;
8
+ export default isDomItem;
@@ -0,0 +1,21 @@
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 hasTrait_1 = __importDefault(require("./hasTrait"));
15
+ /**
16
+ * Whether an item, and every item below it, has the render trait: the tree treeloom's render and sync functions work
17
+ * on. hasTrait only checks the one item, so use this where a tree comes from somewhere else. It is also a type guard.
18
+ * @param item - The item at the top of the tree to check.
19
+ */
20
+ const isDomItem = item => (0, hasTrait_1.default)(item, 'render') && item.children.every(isDomItem);
21
+ exports.default = isDomItem;
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});const hasTrait_1=__importDefault(require("./hasTrait")),isDomItem=e=>(0,hasTrait_1.default)(e,"render")&&e.children.every(isDomItem);exports.default=isDomItem;
@@ -0,0 +1,11 @@
1
+ import type { CoreItem, TraitName, TraitRegistry, WithTraits } from '../types';
2
+ /**
3
+ * Give an item a trait: the trait's defaults and the given data are put on the item (the same object, not a copy), and
4
+ * it is added to the item's has map.
5
+ * @param item - The item which gains the trait.
6
+ * @param trait - The name of the trait.
7
+ * @param data - The data the trait puts on the item.
8
+ * @returns The same item, now with the trait.
9
+ */
10
+ declare const withTrait: <Item extends CoreItem, Trait extends TraitName>(item: Item, trait: Trait, data: TraitRegistry[Trait]) => Item & WithTraits<Trait>;
11
+ export default withTrait;
@@ -0,0 +1,30 @@
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
+ * Give an item a trait: the trait's defaults and the given data are put on the item (the same object, not a copy), and
17
+ * it is added to the item's has map.
18
+ * @param item - The item which gains the trait.
19
+ * @param trait - The name of the trait.
20
+ * @param data - The data the trait puts on the item.
21
+ * @returns The same item, now with the trait.
22
+ */
23
+ const withTrait = (item, trait, data) => {
24
+ Object.assign(item, definitions_1.default.get(trait)?.defaults?.(), data);
25
+ item.has = Object.assign(item.has ?? {}, {
26
+ [trait]: true
27
+ });
28
+ return item;
29
+ };
30
+ exports.default = withTrait;
@@ -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")),withTrait=(e,t,i)=>(Object.assign(e,definitions_1.default.get(t)?.defaults?.(),i),e.has=Object.assign(e.has??{},{[t]:!0}),e);exports.default=withTrait;
@@ -0,0 +1,8 @@
1
+ import type { DomItem } from '../types';
2
+ /**
3
+ * Append a child to the end of given parent's children list.
4
+ * @param parent - The parent that will receive the child.
5
+ * @param child - The new child to attach to the parent.
6
+ */
7
+ declare const appendChild: (parent: DomItem, child: DomItem) => DomItem;
8
+ export default appendChild;
@@ -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
+ * Append a child to the end of given parent's children list.
11
+ * @param parent - The parent that will receive the child.
12
+ * @param child - The new child to attach to the parent.
13
+ */
14
+ const appendChild = (parent, child) => {
15
+ parent.children.push(child);
16
+ child.parentItem = parent;
17
+ return parent;
18
+ };
19
+ exports.default = appendChild;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const appendChild=(e,t)=>(e.children.push(t),t.parentItem=e,e);exports.default=appendChild;