Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
renderjs
Commits
f245293e
Commit
f245293e
authored
May 15, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No need to set default gadget state asynchronously.
parent
be2d115f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
28 deletions
+6
-28
renderjs.js
renderjs.js
+4
-4
test/renderjs_test.js
test/renderjs_test.js
+2
-24
No files found.
renderjs.js
View file @
f245293e
...
@@ -494,6 +494,9 @@
...
@@ -494,6 +494,9 @@
function
clearGadgetInternalParameters
(
gadget
)
{
function
clearGadgetInternalParameters
(
gadget
)
{
gadget
.
__sub_gadget_dict
=
{};
gadget
.
__sub_gadget_dict
=
{};
if
(
gadget
.
__json_state
!==
undefined
)
{
gadget
.
state
=
JSON
.
parse
(
gadget
.
__json_state
);
}
createGadgetMonitor
(
gadget
);
createGadgetMonitor
(
gadget
);
}
}
...
@@ -545,10 +548,7 @@
...
@@ -545,10 +548,7 @@
return
this
;
return
this
;
};
};
RenderJSGadget
.
setState
=
function
setState
(
state_dict
)
{
RenderJSGadget
.
setState
=
function
setState
(
state_dict
)
{
var
json_state
=
JSON
.
stringify
(
state_dict
);
this
.
prototype
.
__json_state
=
JSON
.
stringify
(
state_dict
);
this
.
__ready_list
.
unshift
(
function
setStateDefaultValue
()
{
this
.
state
=
JSON
.
parse
(
json_state
);
});
return
this
;
return
this
;
};
};
RenderJSGadget
.
onStateChange
=
function
onStateChange
(
callback
)
{
RenderJSGadget
.
onStateChange
=
function
onStateChange
(
callback
)
{
...
...
test/renderjs_test.js
View file @
f245293e
...
@@ -1988,7 +1988,7 @@
...
@@ -1988,7 +1988,7 @@
equal
(
result
,
Klass
);
equal
(
result
,
Klass
);
});
});
test
(
'
create
callback in the ready_list property
'
,
function
()
{
test
(
'
create
__json_state property on prototype
'
,
function
()
{
// Subclass RenderJSGadget to not pollute its namespace
// Subclass RenderJSGadget to not pollute its namespace
var
Klass
=
function
()
{
var
Klass
=
function
()
{
RenderJSGadget
.
call
(
this
);
RenderJSGadget
.
call
(
this
);
...
@@ -2000,29 +2000,7 @@
...
@@ -2000,29 +2000,7 @@
Klass
.
setState
=
RenderJSGadget
.
setState
;
Klass
.
setState
=
RenderJSGadget
.
setState
;
Klass
.
setState
({
foo
:
'
bar
'
});
Klass
.
setState
({
foo
:
'
bar
'
});
equal
(
Klass
.
__ready_list
.
length
,
1
);
equal
(
Klass
.
prototype
.
__json_state
,
JSON
.
stringify
({
foo
:
'
bar
'
}));
});
test
(
'
is called before other ready callbacks
'
,
function
()
{
// Subclass RenderJSGadget to not pollute its namespace
var
Klass
=
function
()
{
RenderJSGadget
.
call
(
this
);
},
ready_callback
;
Klass
.
prototype
=
new
RenderJSGadget
();
Klass
.
prototype
.
constructor
=
Klass
;
Klass
.
__ready_list
=
[];
Klass
.
ready
=
RenderJSGadget
.
ready
;
Klass
.
setState
=
RenderJSGadget
.
setState
;
Klass
.
ready
(
function
()
{
return
;
});
ready_callback
=
Klass
.
__ready_list
[
0
];
Klass
.
setState
({
foo
:
'
bar
'
});
equal
(
Klass
.
__ready_list
.
length
,
2
);
deepEqual
(
Klass
.
__ready_list
[
1
],
ready_callback
);
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
...
...
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