domql 1.5.39 → 1.5.41

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": "symbo.ls",
6
- "version": "1.5.39",
6
+ "version": "1.5.41",
7
7
  "repository": "https://github.com/domql/domql",
8
8
  "publishConfig": {
9
9
  "registry": "https://registry.npmjs.org"
@@ -12,7 +12,7 @@ import update from './update'
12
12
  import { on } from '../event'
13
13
  import { assignClass } from './mixins/classList'
14
14
  import { isFunction, isNumber, isString, createID, isNode, exec } from '../utils'
15
- import { remove, lookup, setProps, log, keys, parse, parseDeep, spotByPath } from './methods'
15
+ import { remove, lookup, setProps, log, keys, parse, parseDeep, spotByPath, nextElement, previousElement } from './methods'
16
16
  import cacheNode from './cache'
17
17
  import { registry } from './mixins'
18
18
  import OPTIONS from './options'
@@ -58,7 +58,8 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
58
58
  const { extend, props, state, childExtend, childProps } = element
59
59
 
60
60
  if (isKeyComponent(assignedKey)) {
61
- if (!extend && !childExtend && !props && !state || childProps) {
61
+ const hasComponentAttrs = extend || childExtend || props || state || element.on
62
+ if (!hasComponentAttrs || childProps) {
62
63
  parent[assignedKey] = element = {
63
64
  extend: assignedKey.split('_')[0],
64
65
  props: {
@@ -147,6 +148,8 @@ const create = (element, parent, key, options = OPTIONS.create || {}) => {
147
148
  element.parse = parse
148
149
  element.parseDeep = parseDeep
149
150
  element.keys = keys
151
+ element.nextElement = nextElement
152
+ element.previousElement = previousElement
150
153
  if (ENV === 'test' || ENV === 'development') {
151
154
  element.log = log
152
155
  }
@@ -11,7 +11,7 @@ const ENV = process.env.NODE_ENV
11
11
  export const applyExtend = (element, parent, options = {}) => {
12
12
  if (isFunction(element)) element = exec(element, parent)
13
13
 
14
- let { extend } = element
14
+ let { extend, props } = element
15
15
  if (isString(extend)) extend = options.components[extend]
16
16
  const extendStack = getExtendStack(extend)
17
17
 
@@ -23,6 +23,8 @@ export const applyExtend = (element, parent, options = {}) => {
23
23
  // Assign parent attr to the element
24
24
  element.parent = parent
25
25
  if (!options.ignoreChildExtend) {
26
+ if (props && props.ignoreChildExtend) return
27
+
26
28
  childExtendStack = getExtendStack(parent.childExtend)
27
29
 
28
30
  if (parent.childExtendRecursive) {
@@ -129,5 +129,30 @@ export const isMethod = function (param) {
129
129
  param === 'setProps' ||
130
130
  param === 'parseDeep' ||
131
131
  param === 'if' ||
132
- param === 'log'
132
+ param === 'log' ||
133
+ param === 'nextElement' ||
134
+ param === 'previousElement'
135
+ }
136
+
137
+ export const nextElement = function () {
138
+ const element = this
139
+ const { key, parent } = element
140
+ const { __children } = parent
141
+
142
+ const currentIndex = __children.indexOf(key)
143
+ const nextChild = __children[currentIndex + 1]
144
+ console.log(nextChild)
145
+
146
+ return parent[nextChild]
147
+ }
148
+
149
+ export const previousElement = function (el) {
150
+ const element = el || this
151
+ const { key, parent } = element
152
+ const { __children } = parent
153
+
154
+ if (!__children) return
155
+
156
+ const currentIndex = __children.indexOf(key)
157
+ return parent[__children[currentIndex - 1]]
133
158
  }
@@ -8,15 +8,15 @@ import { exec, report } from '../../utils'
8
8
  */
9
9
  export default (params, element, node) => {
10
10
  const { __attr } = element
11
+ if (isNot('object')) report('HTMLInvalidAttr', params)
11
12
  if (params) {
12
- if (isNot('object')) report('HTMLInvalidAttr', params)
13
13
  for (const attr in params) {
14
- // if (!node) node = element.node
15
14
  const val = exec(params[attr], element)
16
- if (__attr[attr] === val) return
15
+ // if (__attr[attr] === val) return
17
16
  if (val && node.setAttribute) node.setAttribute(attr, val)
18
17
  else if (node.removeAttribute) node.removeAttribute(attr)
19
18
  __attr[attr] = val
20
19
  }
21
20
  }
21
+ console.groupEnd(params, __attr)
22
22
  }
@@ -50,6 +50,8 @@ export default {
50
50
  __classNames: {},
51
51
  __attr: {},
52
52
  __currentSnapshot: {},
53
+ nextElement: {},
54
+ previousElement: {},
53
55
  key: {},
54
56
  tag: {},
55
57
  query: {},
@@ -61,7 +63,7 @@ export default {
61
63
  remove: {},
62
64
  removeContent: {},
63
65
  lookup: {},
64
- spot: {},
66
+ spotByPath: {},
65
67
  keys: {},
66
68
  log: {},
67
69
  parse: {},