FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
custom-react-elements/tests/utils.js at fix/severity-issues · thread/custom-react-elements · GitHub
This repository was archived by the owner on May 14, 2024. It is now read-only.
thread
/
custom-react-elements
Public archive
Notifications
You must be signed in to change notification settings
Fork
0
Star
18
Code
Issues
0
Pull requests
3
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Security and quality
Insights
Expand file tree
Breadcrumbs
custom-react-elements
/
tests
/
utils.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (31 loc) · 855 Bytes
Breadcrumbs
custom-react-elements
/
tests
/
utils.js
Copy path
File metadata and controls
38 lines (31 loc) · 855 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const
testId
=
'__custom_react_elements_karma__tests__'
;
const
testRoot
=
(
)
=>
document
.
getElementById
(
testId
)
;
const
insertTestRoot
=
(
)
=>
{
clearDom
(
)
;
const
testDiv
=
document
.
createElement
(
'div'
)
;
testDiv
.
id
=
testId
;
document
.
body
.
appendChild
(
testDiv
)
;
}
;
const
clearDom
=
(
)
=>
{
const
testElem
=
testRoot
(
)
;
if
(
testElem
)
{
testElem
.
parentNode
.
removeChild
(
testElem
)
;
}
}
;
export
const
insertCustomElementIntoDom
=
(
name
,
attributes
=
{
}
,
innerHTML
=
''
)
=>
{
insertTestRoot
(
)
;
const
x
=
document
.
createElement
(
name
)
;
Object
.
keys
(
attributes
)
.
forEach
(
attrName
=>
{
x
.
setAttribute
(
attrName
,
attributes
[
attrName
]
)
;
}
)
;
x
.
innerHTML
=
innerHTML
;
testRoot
(
)
.
appendChild
(
x
)
;
}
;
let
selectorNameIndex
=
0
;
export
const
randomSelectorName
=
(
)
=>
{
return
`thread-test-element-
${
selectorNameIndex
++
}
`
;
}
;
Back
|
FazBrowse Home
|
New Git URL