Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
react-vanilla
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Кубота
react-vanilla
Commits
ac2fa4a2
Commit
ac2fa4a2
authored
Dec 20, 2020
by
Иван Кубота
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
svg gradient fix, D fn array as input, renderTo can render multiple instances if is array
parent
7acd7f2f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
25 deletions
+41
-25
DOM.js
DOM.js
+41
-25
No files found.
DOM.js
View file @
ac2fa4a2
...
@@ -59,6 +59,24 @@ NS.apply = function(a,b) {
...
@@ -59,6 +59,24 @@ NS.apply = function(a,b) {
on
:
true
,
renderto
:
true
,
el
:
true
on
:
true
,
renderto
:
true
,
el
:
true
};
};
var
anyTypeClsSetter
=
function
(
el
,
cls
)
{
if
(
typeof
cls
===
'function'
){
cls
(
setters
.
cls
(
el
));
}
else
if
(
typeof
cls
===
'object'
&&
cls
.
hook
){
cls
.
hook
(
setters
.
cls
(
el
));
}
else
if
(
typeof
cls
===
'object'
){
var
resolvedCls
=
Array
.
isArray
(
cls
)?
D
.
cls
.
apply
(
D
,
cls
):
D
.
cls
(
cls
);
if
(
typeof
resolvedCls
===
'function'
){
resolvedCls
(
setters
.
cls
(
el
));
}
else
{
setters
.
cls
(
el
)(
resolvedCls
);
}
}
else
{
setters
.
cls
(
el
)(
cls
);
}
};
// ~jsx h function
// ~jsx h function
var
domEl
=
function
(
type
,
cfg
){
var
domEl
=
function
(
type
,
cfg
){
var
typeOfType
=
typeof
type
;
var
typeOfType
=
typeof
type
;
...
@@ -101,21 +119,7 @@ NS.apply = function(a,b) {
...
@@ -101,21 +119,7 @@ NS.apply = function(a,b) {
}
}
if
(
cls
){
if
(
cls
){
if
(
typeof
cls
===
'function'
){
anyTypeClsSetter
(
el
,
cls
);
cls
(
setters
.
cls
(
el
));
}
else
if
(
typeof
cls
===
'object'
&&
cls
.
hook
){
cls
.
hook
(
setters
.
cls
(
el
));
}
else
if
(
typeof
cls
===
'object'
){
var
resolvedCls
=
Array
.
isArray
(
cls
)?
D
.
cls
.
apply
(
D
,
cls
):
D
.
cls
(
cls
);
if
(
typeof
resolvedCls
===
'function'
){
resolvedCls
(
setters
.
cls
(
el
));
}
else
{
setters
.
cls
(
el
)(
resolvedCls
);
}
}
else
{
setters
.
cls
(
el
)(
cls
);
}
}
}
if
(
style
){
if
(
style
){
...
@@ -164,6 +168,20 @@ NS.apply = function(a,b) {
...
@@ -164,6 +168,20 @@ NS.apply = function(a,b) {
}
}
if
(
renderTo
){
if
(
renderTo
){
if
(
Array
.
isArray
(
renderTo
)){
var
out
=
[
el
];
for
(
i
=
0
,
_i
=
renderTo
.
length
;
i
<
_i
;
i
++
){
var
renderToElement
=
renderTo
[
i
];
if
(
i
===
0
){
D
.
appendChild
(
renderToElement
,
el
);
}
else
{
cfg
.
renderTo
=
renderToElement
;
out
.
push
(
domEl
.
apply
(
this
,
arguments
));
}
}
return
out
;
}
D
.
appendChild
(
renderTo
,
el
);
D
.
appendChild
(
renderTo
,
el
);
}
}
...
@@ -187,7 +205,11 @@ NS.apply = function(a,b) {
...
@@ -187,7 +205,11 @@ NS.apply = function(a,b) {
Text
:
function
(
val
){
return
document
.
createTextNode
(
val
);}
Text
:
function
(
val
){
return
document
.
createTextNode
(
val
);}
};
};
D
=
NS
.
D
=
NS
.
apply
(
function
(
selector
,
ext
)
{
D
=
NS
.
D
=
NS
.
apply
(
function
(
selector
,
ext
)
{
var
out
=
ArraySlice
.
call
(
document
.
querySelectorAll
(
selector
));
var
out
=
[];
selector
=
Array
.
isArray
(
selector
)
?
selector
:
[
selector
];
for
(
var
i
=
0
,
_i
=
selector
.
length
;
i
<
_i
;
i
++
){
out
=
out
.
concat
(
selector
[
i
]
instanceof
Element
?
selector
[
i
]
:
ArraySlice
.
call
(
document
.
querySelectorAll
(
selector
[
i
]
)
)
);
}
if
(
arguments
.
length
>
1
){
if
(
arguments
.
length
>
1
){
for
(
var
i
=
0
,
_i
=
out
.
length
;
i
<
_i
;
i
++
){
for
(
var
i
=
0
,
_i
=
out
.
length
;
i
<
_i
;
i
++
){
var
element
=
out
[
i
];
var
element
=
out
[
i
];
...
@@ -213,7 +235,7 @@ NS.apply = function(a,b) {
...
@@ -213,7 +235,7 @@ NS.apply = function(a,b) {
setClassNameSVG
=
function
(
el
,
cls
)
{
setClassNameSVG
=
function
(
el
,
cls
)
{
el
.
setAttribute
(
'class'
,
cls
);
el
.
setAttribute
(
'class'
,
cls
);
};
};
'svg,path,circle,g,defs,marker,ellipse,animateTransform,mask,rect'
.
split
(
','
).
forEach
(
function
(
name
){
'svg,path,circle,g,defs,marker,ellipse,animateTransform,
linearGradient,
mask,rect'
.
split
(
','
).
forEach
(
function
(
name
){
customElementCreate
[
name
]
=
createElementSVG
;
customElementCreate
[
name
]
=
createElementSVG
;
customElementClassNameSetter
[
name
]
=
setClassNameSVG
;
customElementClassNameSetter
[
name
]
=
setClassNameSVG
;
D
[
name
]
=
function
(
cfg
){
D
[
name
]
=
function
(
cfg
){
...
@@ -234,14 +256,8 @@ NS.apply = function(a,b) {
...
@@ -234,14 +256,8 @@ NS.apply = function(a,b) {
D
.
ext
=
function
(
el
,
cfg
)
{
D
.
ext
=
function
(
el
,
cfg
)
{
cfg
.
el
=
el
;
cfg
.
el
=
el
;
if
(
el
.
className
&&
cfg
.
cls
){
if
(
cfg
.
cls
){
if
(
typeof
cfg
.
cls
===
'string'
){
anyTypeClsSetter
(
el
,
[
el
.
className
,
cfg
.
cls
])
cfg
.
cls
+=
' '
+
el
.
className
;
}
else
if
(
Array
.
isArray
(
cfg
.
cls
)){
cfg
.
cls
.
push
(
el
.
className
);
}
else
{
debugger
}
}
}
return
D
.
div
(
cfg
);
return
D
.
div
(
cfg
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment