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
Ivan Tyagov
renderjs
Commits
acd9abbf
Commit
acd9abbf
authored
Aug 05, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load gadget dependencies in the right order.
parent
2a499e62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
8 deletions
+33
-8
renderjs.js
renderjs.js
+25
-8
test/renderjs_test.js
test/renderjs_test.js
+8
-0
No files found.
renderjs.js
View file @
acd9abbf
...
...
@@ -213,8 +213,6 @@
// };
gadget
.
chan
.
bind
(
"
declareMethod
"
,
function
(
trans
,
method_name
)
{
console
.
log
(
"
Receive declaration
"
+
method_name
+
"
on
"
+
gadget
.
path
);
gadget
[
method_name
]
=
function
()
{
var
dfr
=
$
.
Deferred
();
gadget
.
chan
.
call
({
...
...
@@ -233,7 +231,6 @@
// Wait for the iframe to be loaded before continuing
gadget
.
chan
.
bind
(
"
ready
"
,
function
(
trans
)
{
console
.
log
(
gadget
.
path
+
"
is ready
"
);
next_loading_gadget_deferred
.
resolve
(
gadget
);
});
gadget
.
chan
.
bind
(
"
failed
"
,
function
(
trans
)
{
...
...
@@ -279,12 +276,32 @@
// Load dependencies if needed
$
.
when
(
gadget
.
getRequiredJSList
(),
gadget
.
getRequiredCSSList
())
.
done
(
function
(
js_list
,
css_list
)
{
var
result_list
=
[];
var
result_list
=
[],
first_deferred
=
$
.
Deferred
(),
first_promise
=
first_deferred
.
promise
();
gadget_loading_klass
=
Klass
;
// Load all JS and CSS
$
.
each
(
js_list
,
function
(
i
,
required_url
)
{
result_list
.
push
(
renderJS
.
declareJS
(
required_url
));
});
// Load JS and follow the dependency declaration defined in the
// head
function
next
(
next_js_list
)
{
var
next_js
=
next_js_list
.
shift
();
if
(
next_js
===
undefined
)
{
first_deferred
.
resolve
();
}
else
{
renderJS
.
declareJS
(
next_js
)
.
done
(
function
()
{
next
(
next_js_list
);
})
.
fail
(
function
()
{
first_deferred
.
reject
.
apply
(
first_deferred
,
arguments
);
});
}
}
next
(
js_list
);
result_list
.
push
(
first_promise
);
// Load CSS
$
.
each
(
css_list
,
function
(
i
,
required_url
)
{
result_list
.
push
(
renderJS
.
declareCSS
(
required_url
));
});
...
...
test/renderjs_test.js
View file @
acd9abbf
...
...
@@ -1323,6 +1323,14 @@
server
.
respond
();
});
// test('load dependency in the right order', function () {
// // Check that JS dependencies are loaded in the right order
// // Can be reproduce with real loading (http):
// // * enormous 1 js
// // * second small js which require the 1 one to be loaded
// // How to mock the loading time?
// });
test
(
'
Fail if klass can not be loaded
'
,
function
()
{
// Check that gadget is not created if klass is can not be loaded
var
gadget
=
new
RenderJSGadget
(),
...
...
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