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
d37a613b
Commit
d37a613b
authored
May 15, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not try to load subgadget if not needed.
parent
f245293e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
7 deletions
+35
-7
renderjs.js
renderjs.js
+12
-6
test/renderjs_test.js
test/renderjs_test.js
+23
-1
No files found.
renderjs.js
View file @
d37a613b
...
...
@@ -542,7 +542,7 @@
return
RSVP
.
all
(
promise_list
);
}
RenderJSGadget
.
__ready_list
=
[
loadSubGadgetDOMDeclaration
];
RenderJSGadget
.
__ready_list
=
[];
RenderJSGadget
.
ready
=
function
ready
(
callback
)
{
this
.
__ready_list
.
push
(
callback
);
return
this
;
...
...
@@ -830,7 +830,7 @@
}
RenderJSGadget
.
call
(
this
);
}
RenderJSEmbeddedGadget
.
__ready_list
=
RenderJSGadget
.
__ready_list
.
slice
()
;
RenderJSEmbeddedGadget
.
__ready_list
=
[]
;
RenderJSEmbeddedGadget
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
();
RenderJSEmbeddedGadget
.
ready
=
...
...
@@ -890,14 +890,14 @@
}
RenderJSGadget
.
call
(
this
);
}
RenderJSIframeGadget
.
__ready_list
=
RenderJSGadget
.
__ready_list
.
slice
()
;
RenderJSIframeGadget
.
__ready_list
=
[]
;
RenderJSIframeGadget
.
ready
=
RenderJSGadget
.
ready
;
RenderJSIframeGadget
.
setState
=
RenderJSGadget
.
setState
;
RenderJSIframeGadget
.
onStateChange
=
RenderJSGadget
.
onStateChange
;
RenderJSIframeGadget
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
()
;
RenderJSIframeGadget
.
__service_list
=
[]
;
RenderJSIframeGadget
.
declareService
=
RenderJSGadget
.
declareService
;
RenderJSIframeGadget
.
onEvent
=
...
...
@@ -1257,7 +1257,7 @@
tmp_constructor
=
function
createSuperKlass
()
{
RenderJSGadget
.
call
(
this
);
};
tmp_constructor
.
__ready_list
=
RenderJSGadget
.
__ready_list
.
slice
()
;
tmp_constructor
.
__ready_list
=
[]
;
tmp_constructor
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
();
tmp_constructor
.
declareMethod
=
RenderJSGadget
.
declareMethod
;
...
...
@@ -1297,6 +1297,11 @@
tmp_constructor
.
prototype
[
'
__
'
+
key
]
=
parsed_html
[
key
];
}
}
// Check if there is a HTML declared subgadget
if
(
tmp_constructor
.
__template_element
.
querySelectorAll
(
'
[data-gadget-url]
'
).
length
)
{
tmp_constructor
.
__ready_list
.
push
(
loadSubGadgetDOMDeclaration
);
}
return
tmp_constructor
;
}
...
...
@@ -1610,7 +1615,7 @@
// Create the root gadget instance and put it in the loading stack
TmpConstructor
=
RenderJSEmbeddedGadget
;
TmpConstructor
.
__ready_list
=
RenderJSGadget
.
__ready_list
.
slice
()
;
TmpConstructor
.
__ready_list
=
[]
;
TmpConstructor
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
();
TmpConstructor
.
prototype
.
__path
=
url
;
root_gadget
=
new
RenderJSEmbeddedGadget
();
...
...
@@ -1804,6 +1809,7 @@
})
.
push
(
function
waitForReadyList
()
{
clearGadgetInternalParameters
(
root_gadget
);
TmpConstructor
.
__ready_list
.
unshift
(
loadSubGadgetDOMDeclaration
);
// Trigger all ready functions
return
triggerReadyList
(
TmpConstructor
,
root_gadget
);
})
...
...
test/renderjs_test.js
View file @
d37a613b
...
...
@@ -524,7 +524,7 @@
);
stop
();
expect
(
7
);
expect
(
8
);
renderJS
.
declareGadgetKlass
(
url
)
.
then
(
function
(
Klass
)
{
var
instance
;
...
...
@@ -533,6 +533,7 @@
deepEqual
(
Klass
.
prototype
.
__acquired_method_dict
,
{});
equal
(
Klass
.
prototype
.
__foo
,
'
bar
'
);
equal
(
Klass
.
__template_element
.
nodeType
,
9
);
deepEqual
(
Klass
.
__ready_list
,
[],
'
Ready list is empty by default
'
);
instance
=
new
Klass
();
ok
(
instance
instanceof
RenderJSGadget
);
...
...
@@ -616,6 +617,27 @@
});
});
test
(
'
Ready list length is one if HTML sub gadget
'
,
function
()
{
var
url
=
'
https://example.org/files/qunittest/test
'
;
this
.
server
.
respondWith
(
"
GET
"
,
url
,
[
200
,
{
"
Content-Type
"
:
"
text/html; charset=utf-8
"
},
"
<html><body><div data-gadget-url='foo'></div></body></html>
"
]);
stop
();
expect
(
1
);
renderJS
.
declareGadgetKlass
(
url
)
.
then
(
function
(
Klass
)
{
equal
(
Klass
.
__ready_list
.
length
,
1
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// declareJS
/////////////////////////////////////////////////////////////////
...
...
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