Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
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
Gabriel Monnerat
renderjs
Commits
bce5da91
Commit
bce5da91
authored
Jan 17, 2017
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure state initialization is done before the ready callbacks.
parent
727a1ed8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
renderjs.js
renderjs.js
+2
-1
test/renderjs_test.js
test/renderjs_test.js
+22
-0
No files found.
renderjs.js
View file @
bce5da91
...
...
@@ -469,9 +469,10 @@
};
RenderJSGadget
.
setState
=
function
(
state_dict
)
{
var
json_state
=
JSON
.
stringify
(
state_dict
);
return
this
.
ready
(
function
()
{
this
.
__ready_list
.
unshift
(
function
()
{
this
.
state
=
JSON
.
parse
(
json_state
);
});
return
this
;
};
RenderJSGadget
.
onStateChange
=
function
(
callback
)
{
this
.
prototype
.
__state_change_callback
=
callback
;
...
...
test/renderjs_test.js
View file @
bce5da91
...
...
@@ -1850,6 +1850,28 @@
equal
(
Klass
.
__ready_list
.
length
,
1
);
});
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
);
});
/////////////////////////////////////////////////////////////////
// RenderJSGadgetKlass.onStateChange
/////////////////////////////////////////////////////////////////
...
...
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