• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rackai / domql / #431

16 Feb 2022 03:27AM UTC coverage: 3.504% (-65.5%) from 68.987%
#431

push

web-flow
Merge pull request #66 from rackai/dependabot/npm_and_yarn/eslint-plugin-jest-25.3.2

Bump eslint-plugin-jest from 24.7.0 to 25.3.2

8 of 543 branches covered (1.47%)

Branch coverage included in aggregate %.

33 of 627 relevant lines covered (5.26%)

0.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/element/createNode.js
1
'use strict'
2

3
import create from './create'
4
import cacheNode from './cache'
5
import * as on from '../event/on'
6

7
import { isFunction, isObject } from '../utils'
8
import {
9
  throughInitialDefine,
10
  throughInitialExec,
11
  applyEvents
12
} from './iterate'
13
import { registry } from './mixins'
14
import { isMethod } from './methods'
15
// import { defineSetter } from './methods'
16

17
const ENV = process.env.NODE_ENV
×
18

19
// const defineSetter = (element, key) => Object.defineProperty(element, key, {
20
//   get: function () {
21
//     console.log('GET', key)
22
//     return element.__data[key]
23
//   },
24
//   set: function (new_value) {
25
//     console.log('SET', key, new_value)
26
//     element.__data[key] = new_value
27
//     element.__data['modified'] = (new Date()).getTime()
28
//   }
29
// })
30

31
const createNode = (element) => {
×
32
  // create and assign a node
33
  let { node, tag } = element
×
34

35
  let isNewNode
36

37
  // console.groupCollapsed('CREATE:')
38
  // console.log(element)
39
  // console.groupEnd('CREATE:')
40

41
  if (!node) {
×
42
    isNewNode = true
×
43

44
    if (tag === 'shadow') {
×
45
      node = element.node = element.parent.node.attachShadow({ mode: 'open' })
×
46
    } else node = element.node = cacheNode(element)
×
47

48
    // run `on.attachNode`
49
    if (element.on && isFunction(element.on.attachNode)) {
×
50
      on.attachNode(element.on.attachNode, element, element.state)
×
51
    }
52
  }
53

54
  // node.dataset // .key = element.key
55

56
  if (ENV === 'test' || ENV === 'development') {
×
57
    node.ref = element
×
58
    if (isFunction(node.setAttribute)) node.setAttribute('key', element.key)
×
59
  }
60

61
  // iterate through all given params
62
  if (element.tag !== 'string' || element.tag !== 'fragment') {
×
63
    // iterate through define
64
    if (isObject(element.define)) throughInitialDefine(element)
×
65

66
    // iterate through exec
67
    throughInitialExec(element)
×
68

69
    // apply events
70
    if (isNewNode && isObject(element.on)) applyEvents(element)
×
71

72
    for (const param in element) {
×
73
      const prop = element[param]
×
74

75
      if (isMethod(param) || isObject(registry[param]) || prop === undefined) continue
×
76

77
      const hasDefined = element.define && element.define[param]
×
78
      const ourParam = registry[param]
×
79

80
      if (ourParam) { // Check if param is in our method registry
×
81
        if (isFunction(ourParam)) ourParam(prop, element, node)
×
82
      } else if (element[param] && !hasDefined) {
×
83
        create(prop, element, param) // Create element
×
84
      }
85
    }
86
  }
87

88
  // node.dataset.key = key
89
  return element
×
90
}
91

92
export default createNode
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc