• 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/cache.js
1
'use strict'
2

3
import { can } from '../event'
4
import { exec, isString, isTagRegistered, report } from '../utils'
5

6
const cachedElements = {}
×
7

8
const createNode = (element) => {
×
9
  const { tag } = element
×
10
  if (tag) {
×
11
    if (tag === 'string') return document.createTextNode(element.text)
×
12
    else if (tag === 'fragment') {
×
13
      return document.createDocumentFragment()
×
14
    } else if (tag === 'svg' || tag === 'path') { // change that
×
15
      return document.createElementNS('http://www.w3.org/2000/svg', tag)
×
16
    } else return document.createElement(tag)
×
17
  } else {
18
    return document.createElement('div')
×
19
  }
20
}
21

22
const detectTag = element => {
×
23
  let { tag, key } = element
×
24
  tag = exec(tag, element)
×
25

26
  if (tag === true) tag = key
×
27

28
  if (isString(tag)) {
×
29
    const tagExists = isTagRegistered(tag) > -1
×
30
    if (tagExists) return tag
×
31
  } else {
32
    const isKeyATag = isTagRegistered(key) > -1
×
33
    if (isKeyATag) return key
×
34
  }
35

36
  return 'div'
×
37
}
38

39
export default (element) => {
40
  const tag = element.tag = detectTag(element)
×
41

42
  if (!can.render(element)) {
×
43
    return report('HTMLInvalidTag')
×
44
  }
45

46
  let cachedTag = cachedElements[tag]
×
47
  if (!cachedTag) cachedTag = cachedElements[tag] = createNode(element)
×
48

49
  const clonedNode = cachedTag.cloneNode(true)
×
50
  if (tag === 'string') clonedNode.nodeValue = element.text
×
51
  return clonedNode
×
52
}
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