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
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 @@
...
@@ -542,7 +542,7 @@
return
RSVP
.
all
(
promise_list
);
return
RSVP
.
all
(
promise_list
);
}
}
RenderJSGadget
.
__ready_list
=
[
loadSubGadgetDOMDeclaration
];
RenderJSGadget
.
__ready_list
=
[];
RenderJSGadget
.
ready
=
function
ready
(
callback
)
{
RenderJSGadget
.
ready
=
function
ready
(
callback
)
{
this
.
__ready_list
.
push
(
callback
);
this
.
__ready_list
.
push
(
callback
);
return
this
;
return
this
;
...
@@ -830,7 +830,7 @@
...
@@ -830,7 +830,7 @@
}
}
RenderJSGadget
.
call
(
this
);
RenderJSGadget
.
call
(
this
);
}
}
RenderJSEmbeddedGadget
.
__ready_list
=
RenderJSGadget
.
__ready_list
.
slice
()
;
RenderJSEmbeddedGadget
.
__ready_list
=
[]
;
RenderJSEmbeddedGadget
.
__service_list
=
RenderJSEmbeddedGadget
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
();
RenderJSGadget
.
__service_list
.
slice
();
RenderJSEmbeddedGadget
.
ready
=
RenderJSEmbeddedGadget
.
ready
=
...
@@ -890,14 +890,14 @@
...
@@ -890,14 +890,14 @@
}
}
RenderJSGadget
.
call
(
this
);
RenderJSGadget
.
call
(
this
);
}
}
RenderJSIframeGadget
.
__ready_list
=
RenderJSGadget
.
__ready_list
.
slice
()
;
RenderJSIframeGadget
.
__ready_list
=
[]
;
RenderJSIframeGadget
.
ready
=
RenderJSIframeGadget
.
ready
=
RenderJSGadget
.
ready
;
RenderJSGadget
.
ready
;
RenderJSIframeGadget
.
setState
=
RenderJSIframeGadget
.
setState
=
RenderJSGadget
.
setState
;
RenderJSGadget
.
setState
;
RenderJSIframeGadget
.
onStateChange
=
RenderJSIframeGadget
.
onStateChange
=
RenderJSGadget
.
onStateChange
;
RenderJSGadget
.
onStateChange
;
RenderJSIframeGadget
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
()
;
RenderJSIframeGadget
.
__service_list
=
[]
;
RenderJSIframeGadget
.
declareService
=
RenderJSIframeGadget
.
declareService
=
RenderJSGadget
.
declareService
;
RenderJSGadget
.
declareService
;
RenderJSIframeGadget
.
onEvent
=
RenderJSIframeGadget
.
onEvent
=
...
@@ -1257,7 +1257,7 @@
...
@@ -1257,7 +1257,7 @@
tmp_constructor
=
function
createSuperKlass
()
{
tmp_constructor
=
function
createSuperKlass
()
{
RenderJSGadget
.
call
(
this
);
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
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
();
tmp_constructor
.
declareMethod
=
tmp_constructor
.
declareMethod
=
RenderJSGadget
.
declareMethod
;
RenderJSGadget
.
declareMethod
;
...
@@ -1297,6 +1297,11 @@
...
@@ -1297,6 +1297,11 @@
tmp_constructor
.
prototype
[
'
__
'
+
key
]
=
parsed_html
[
key
];
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
;
return
tmp_constructor
;
}
}
...
@@ -1610,7 +1615,7 @@
...
@@ -1610,7 +1615,7 @@
// Create the root gadget instance and put it in the loading stack
// Create the root gadget instance and put it in the loading stack
TmpConstructor
=
RenderJSEmbeddedGadget
;
TmpConstructor
=
RenderJSEmbeddedGadget
;
TmpConstructor
.
__ready_list
=
RenderJSGadget
.
__ready_list
.
slice
()
;
TmpConstructor
.
__ready_list
=
[]
;
TmpConstructor
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
();
TmpConstructor
.
__service_list
=
RenderJSGadget
.
__service_list
.
slice
();
TmpConstructor
.
prototype
.
__path
=
url
;
TmpConstructor
.
prototype
.
__path
=
url
;
root_gadget
=
new
RenderJSEmbeddedGadget
();
root_gadget
=
new
RenderJSEmbeddedGadget
();
...
@@ -1804,6 +1809,7 @@
...
@@ -1804,6 +1809,7 @@
})
})
.
push
(
function
waitForReadyList
()
{
.
push
(
function
waitForReadyList
()
{
clearGadgetInternalParameters
(
root_gadget
);
clearGadgetInternalParameters
(
root_gadget
);
TmpConstructor
.
__ready_list
.
unshift
(
loadSubGadgetDOMDeclaration
);
// Trigger all ready functions
// Trigger all ready functions
return
triggerReadyList
(
TmpConstructor
,
root_gadget
);
return
triggerReadyList
(
TmpConstructor
,
root_gadget
);
})
})
...
...
test/renderjs_test.js
View file @
d37a613b
...
@@ -524,7 +524,7 @@
...
@@ -524,7 +524,7 @@
);
);
stop
();
stop
();
expect
(
7
);
expect
(
8
);
renderJS
.
declareGadgetKlass
(
url
)
renderJS
.
declareGadgetKlass
(
url
)
.
then
(
function
(
Klass
)
{
.
then
(
function
(
Klass
)
{
var
instance
;
var
instance
;
...
@@ -533,6 +533,7 @@
...
@@ -533,6 +533,7 @@
deepEqual
(
Klass
.
prototype
.
__acquired_method_dict
,
{});
deepEqual
(
Klass
.
prototype
.
__acquired_method_dict
,
{});
equal
(
Klass
.
prototype
.
__foo
,
'
bar
'
);
equal
(
Klass
.
prototype
.
__foo
,
'
bar
'
);
equal
(
Klass
.
__template_element
.
nodeType
,
9
);
equal
(
Klass
.
__template_element
.
nodeType
,
9
);
deepEqual
(
Klass
.
__ready_list
,
[],
'
Ready list is empty by default
'
);
instance
=
new
Klass
();
instance
=
new
Klass
();
ok
(
instance
instanceof
RenderJSGadget
);
ok
(
instance
instanceof
RenderJSGadget
);
...
@@ -616,6 +617,27 @@
...
@@ -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
// 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