domql 1.4.1 → 1.4.4

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "DOM rendering Javascript framework at early stage.",
4
4
  "private": false,
5
5
  "author": "rackai",
6
- "version": "1.4.1",
6
+ "version": "1.4.4",
7
7
  "repository": "https://github.com/rackai/domql",
8
8
  "publishConfig": {
9
9
  "registry": "https://registry.npmjs.org"
@@ -27,29 +27,17 @@ const create = (element, parent, key, options = {}) => {
27
27
  if (element === undefined) element = {}
28
28
  if (element === null) return
29
29
 
30
- if (Object.keys(options).length) {
31
- registry.defaultOptions = options
32
- if (options.ignoreChildProto) delete options.ignoreChildProto
33
- }
34
-
35
30
  // if element is proto
36
31
  if (element.__hash) {
37
32
  element = { proto: element }
38
33
  }
39
34
 
40
- // if KEY is PROTO
41
35
  if (options.components) {
42
36
  const { components } = options
43
-
44
- const k = element.key || key
45
- const keyIsProto = isString(k) && k.charAt(0) === k.charAt(0).toUpperCase()
46
- let component
47
- if (keyIsProto) component = key
48
-
49
- // if proto comes from library as string
50
- const fromLibrary = component || isString(element.proto) ? element.proto : element.component
51
- const isInLibrary = components[fromLibrary]
52
- if (isInLibrary) element = { proto: isInLibrary, props: element }
37
+ const { proto, component } = element
38
+ if (isString(proto))
39
+ if (components[proto]) element.proto = components[proto]
40
+ else console.warn(proto, 'is not in library', components, element)
53
41
  }
54
42
 
55
43
  // define KEY
@@ -75,6 +63,11 @@ const create = (element, parent, key, options = {}) => {
75
63
  // create PROTOtypal inheritance
76
64
  applyPrototype(element, parent, options)
77
65
 
66
+ if (Object.keys(options).length) {
67
+ registry.defaultOptions = options
68
+ if (options.ignoreChildProto) delete options.ignoreChildProto
69
+ }
70
+
78
71
  // enable STATE
79
72
  element.state = createState(element, parent)
80
73
 
@@ -62,7 +62,13 @@ export const applyPrototype = (element, parent, options = {}) => {
62
62
  }
63
63
 
64
64
  element.__proto = stack
65
- const mergedProto = cloneAndMergeArrayProto(stack)
65
+ let mergedProto = cloneAndMergeArrayProto(stack)
66
+
67
+ const component = exec(element.component || mergedProto.component, element)
68
+ if (component && options.components && options.components[component]) {
69
+ const componentProto = cloneAndMergeArrayProto(getProtoStack(options.components[component]))
70
+ mergedProto = deepMergeProto(mergedProto, componentProto)
71
+ }
66
72
 
67
73
  // console.log(mergedProto)
68
74
  return deepMergeProto(element, mergedProto)