domql 1.4.3 → 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.3",
6
+ "version": "1.4.4",
7
7
  "repository": "https://github.com/rackai/domql",
8
8
  "publishConfig": {
9
9
  "registry": "https://registry.npmjs.org"
@@ -27,11 +27,6 @@ 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 }
@@ -39,19 +34,10 @@ const create = (element, parent, key, options = {}) => {
39
34
 
40
35
  if (options.components) {
41
36
  const { components } = options
42
- const { proto } = element
37
+ const { proto, component } = element
43
38
  if (isString(proto))
44
39
  if (components[proto]) element.proto = components[proto]
45
40
  else console.warn(proto, 'is not in library', components, element)
46
-
47
- // // if KEY is PROTO
48
- // const k = element.key || key
49
- // const keyIsProto = isString(k) && k.charAt(0) === k.charAt(0).toUpperCase()
50
- // if (keyIsProto) component = key
51
- // let { match, ...rest } = element
52
- // if proto comes from library as string
53
- // const fromLibrary = isString(match) ? components[match] : match
54
- // if (fromLibrary) element = { proto: fromLibrary, ...rest }
55
41
  }
56
42
 
57
43
  // define KEY
@@ -77,6 +63,11 @@ const create = (element, parent, key, options = {}) => {
77
63
  // create PROTOtypal inheritance
78
64
  applyPrototype(element, parent, options)
79
65
 
66
+ if (Object.keys(options).length) {
67
+ registry.defaultOptions = options
68
+ if (options.ignoreChildProto) delete options.ignoreChildProto
69
+ }
70
+
80
71
  // enable STATE
81
72
  element.state = createState(element, parent)
82
73
 
@@ -51,5 +51,6 @@ export default {
51
51
  log: {},
52
52
  parse: {},
53
53
  parseDeep: {},
54
- on: {}
54
+ on: {},
55
+ component: {}
55
56
  }
@@ -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)