native-document 1.0.30 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/native-document.dev.js +156 -137
- package/dist/native-document.dev.js.map +1 -1
- package/dist/native-document.min.js +1 -1
- package/elements.d.ts +6 -0
- package/index.d.ts +0 -5
- package/package.json +1 -1
- package/rollup.config.js +1 -0
- package/src/data/ObservableItem.js +1 -0
- package/src/data/observable-helpers/array.js +2 -1
- package/src/elements/anchor.js +20 -13
- package/src/elements/control/for-each-array.js +10 -18
- package/src/utils/args-types.js +102 -73
- package/src/utils/prototypes.js +17 -0
- package/src/wrappers/ElementCreator.js +2 -2
- package/src/wrappers/HtmlElementWrapper.js +14 -22
- package/src/wrappers/NDElement.js +4 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Validator from "../utils/validator";
|
|
2
|
-
import DebugManager from "../utils/debug-manager";
|
|
3
2
|
import {ElementCreator} from "./ElementCreator";
|
|
4
3
|
import './NdPrototype';
|
|
4
|
+
import {normalizeComponentArgs} from "../utils/args-types";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -15,6 +15,17 @@ export const createTextNode = function(value) {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
function createHtmlElement($tagName, _attributes, _children = null, customWrapper) {
|
|
19
|
+
const { props: attributes, children = null } = normalizeComponentArgs(_attributes, _children);
|
|
20
|
+
const element = ElementCreator.createElement($tagName);
|
|
21
|
+
const finalElement = (typeof customWrapper === 'function') ? customWrapper(element) : element;
|
|
22
|
+
|
|
23
|
+
ElementCreator.processAttributes(finalElement, attributes);
|
|
24
|
+
ElementCreator.processChildren(children, finalElement);
|
|
25
|
+
|
|
26
|
+
return ElementCreator.setup(finalElement, attributes, customWrapper);
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
/**
|
|
19
30
|
*
|
|
20
31
|
* @param {string} name
|
|
@@ -22,25 +33,6 @@ export const createTextNode = function(value) {
|
|
|
22
33
|
* @returns {Function}
|
|
23
34
|
*/
|
|
24
35
|
export default function HtmlElementWrapper(name, customWrapper) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return function(attributes, children = null) {
|
|
28
|
-
try {
|
|
29
|
-
if(!Validator.isJson(attributes)) {
|
|
30
|
-
const tempChildren = children;
|
|
31
|
-
children = attributes;
|
|
32
|
-
attributes = tempChildren;
|
|
33
|
-
}
|
|
34
|
-
const element = ElementCreator.createElement($tagName);
|
|
35
|
-
const finalElement = (typeof customWrapper === 'function') ? customWrapper(element) : element;
|
|
36
|
-
|
|
37
|
-
ElementCreator.processAttributes(finalElement, attributes);
|
|
38
|
-
ElementCreator.processChildren(children, finalElement);
|
|
39
|
-
|
|
40
|
-
return ElementCreator.setup(finalElement, attributes, customWrapper);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
DebugManager.error('ElementCreation', `Error creating ${$tagName}`, error);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
36
|
+
return (_attributes, _children = null) => createHtmlElement(name.toLowerCase(), _attributes, _children, customWrapper);
|
|
37
|
+
};
|
|
46
38
|
|