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
Labels
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
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
Show 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 @@
...
@@ -1100,7 +1100,6 @@
scope_increment
+=
1
;
scope_increment
+=
1
;
}
}
}
}
parent_gadget
.
__sub_gadget_dict
[
scope
]
=
gadget_instance
;
gadget_instance
.
element
.
setAttribute
(
"
data-gadget-scope
"
,
gadget_instance
.
element
.
setAttribute
(
"
data-gadget-scope
"
,
scope
);
scope
);
...
@@ -1120,6 +1119,10 @@
...
@@ -1120,6 +1119,10 @@
if
(
document
.
contains
(
gadget_instance
.
element
))
{
if
(
document
.
contains
(
gadget_instance
.
element
))
{
startService
(
gadget_instance
);
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
// Always return the gadget instance after ready function
return
gadget_instance
;
return
gadget_instance
;
}
}
...
...
test/renderjs_test.js
View file @
ffd3d0c2
...
@@ -4190,23 +4190,26 @@
...
@@ -4190,23 +4190,26 @@
},
"
<html><body></body></html>
"
]);
},
"
<html><body></body></html>
"
]);
stop
();
stop
();
expect
(
3
);
expect
(
6
);
renderJS
.
declareGadgetKlass
(
html_url
)
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
// Create a ready function
// Create a ready function
Klass
.
ready
(
function
(
g
)
{
Klass
.
ready
(
function
(
g
)
{
deepEqual
(
gadget
.
__sub_gadget_dict
,
{});
equal
(
g
,
this
,
"
Context should be the gadget instance
"
);
equal
(
g
,
this
,
"
Context should be the gadget instance
"
);
ready_gadget
=
g
;
ready_gadget
=
g
;
return
RSVP
.
delay
(
50
).
then
(
function
()
{
return
RSVP
.
delay
(
50
).
then
(
function
()
{
// Modify the value after 50ms
// Modify the value after 50ms
called
=
true
;
called
=
true
;
deepEqual
(
gadget
.
__sub_gadget_dict
,
{});
});
});
});
});
return
gadget
.
declareGadget
(
html_url
);
return
gadget
.
declareGadget
(
html_url
,
{
scope
:
'
sub
'
}
);
})
})
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
equal
(
result
,
ready_gadget
,
"
Context should be the gadget instance
"
);
equal
(
result
,
ready_gadget
,
"
Context should be the gadget instance
"
);
ok
(
called
);
ok
(
called
);
deepEqual
(
gadget
.
__sub_gadget_dict
,
{
'
sub
'
:
result
});
})
})
.
fail
(
function
(
e
)
{
.
fail
(
function
(
e
)
{
ok
(
false
);
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