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
ffd3d0c2
Commit
ffd3d0c2
authored
Nov 12, 2018
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wait for ready to be finished before setting the child gadget reference.
parent
6389d855
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
renderjs.js
renderjs.js
+4
-1
test/renderjs_test.js
test/renderjs_test.js
+5
-2
No files found.
renderjs.js
View file @
ffd3d0c2
...
...
@@ -1100,7 +1100,6 @@
scope_increment
+=
1
;
}
}
parent_gadget
.
__sub_gadget_dict
[
scope
]
=
gadget_instance
;
gadget_instance
.
element
.
setAttribute
(
"
data-gadget-scope
"
,
scope
);
...
...
@@ -1120,6 +1119,10 @@
if
(
document
.
contains
(
gadget_instance
.
element
))
{
startService
(
gadget_instance
);
}
// Always set the parent reference when all ready are finished
// in case the gadget declaration is cancelled
// (and ready are not finished)
parent_gadget
.
__sub_gadget_dict
[
scope
]
=
gadget_instance
;
// Always return the gadget instance after ready function
return
gadget_instance
;
}
...
...
test/renderjs_test.js
View file @
ffd3d0c2
...
...
@@ -4190,23 +4190,26 @@
},
"
<html><body></body></html>
"
]);
stop
();
expect
(
3
);
expect
(
6
);
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
// Create a ready function
Klass
.
ready
(
function
(
g
)
{
deepEqual
(
gadget
.
__sub_gadget_dict
,
{});
equal
(
g
,
this
,
"
Context should be the gadget instance
"
);
ready_gadget
=
g
;
return
RSVP
.
delay
(
50
).
then
(
function
()
{
// Modify the value after 50ms
called
=
true
;
deepEqual
(
gadget
.
__sub_gadget_dict
,
{});
});
});
return
gadget
.
declareGadget
(
html_url
);
return
gadget
.
declareGadget
(
html_url
,
{
scope
:
'
sub
'
}
);
})
.
then
(
function
(
result
)
{
equal
(
result
,
ready_gadget
,
"
Context should be the gadget instance
"
);
ok
(
called
);
deepEqual
(
gadget
.
__sub_gadget_dict
,
{
'
sub
'
:
result
});
})
.
fail
(
function
(
e
)
{
ok
(
false
);
...
...
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