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
6602a3ae
Commit
6602a3ae
authored
Sep 06, 2016
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'this' in ready is now the gadget instance
parent
df5631bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
11 deletions
+30
-11
renderjs.js
renderjs.js
+14
-3
test/renderjs_test.js
test/renderjs_test.js
+16
-8
No files found.
renderjs.js
View file @
6602a3ae
...
...
@@ -808,10 +808,17 @@
function
ready_wrapper
()
{
return
gadget_instance
;
}
function
ready_executable_wrapper
(
fct
)
{
return
function
(
g
)
{
return
fct
.
call
(
g
,
g
);
};
}
for
(
i
=
0
;
i
<
gadget_instance
.
constructor
.
__ready_list
.
length
;
i
+=
1
)
{
// Put a timeout?
queue
.
push
(
gadget_instance
.
constructor
.
__ready_list
[
i
]);
queue
.
push
(
ready_executable_wrapper
(
gadget_instance
.
constructor
.
__ready_list
[
i
]
));
// Always return the gadget instance after ready function
queue
.
push
(
ready_wrapper
);
}
...
...
@@ -1422,7 +1429,11 @@
function
ready_wrapper
()
{
return
root_gadget
;
}
function
ready_executable_wrapper
(
fct
)
{
return
function
(
g
)
{
return
fct
.
call
(
g
,
g
);
};
}
tmp_constructor
.
ready
(
function
(
g
)
{
return
startService
(
g
);
});
...
...
@@ -1431,7 +1442,7 @@
for
(
i
=
0
;
i
<
tmp_constructor
.
__ready_list
.
length
;
i
+=
1
)
{
// Put a timeout?
loading_gadget_promise
.
push
(
tmp_constructor
.
__ready_list
[
i
]
)
.
push
(
ready_executable_wrapper
(
tmp_constructor
.
__ready_list
[
i
])
)
// Always return the gadget instance after ready function
.
push
(
ready_wrapper
);
}
...
...
test/renderjs_test.js
View file @
6602a3ae
...
...
@@ -18,11 +18,11 @@
// Keep track of the root gadget
renderJS
(
window
).
ready
(
function
(
g
)
{
root_gadget_defer
.
resolve
(
g
);
root_gadget_defer
.
resolve
(
[
g
,
this
]
);
});
QUnit
.
config
.
testTimeout
=
1000
;
QUnit
.
config
.
testTimeout
=
1000
0
;
// QUnit.config.reorder = false;
// sinon.log = function (message) {
// console.log(message);
...
...
@@ -2649,6 +2649,7 @@
// Subclass RenderJSGadget to not pollute its namespace
var
called
=
false
,
gadget
=
new
RenderJSGadget
(),
ready_gadget
,
html_url
=
'
https://example.org/files/qunittest/test98.html
'
;
gadget
.
__sub_gadget_dict
=
{};
...
...
@@ -2660,7 +2661,9 @@
renderJS
.
declareGadgetKlass
(
html_url
)
.
then
(
function
(
Klass
)
{
// Create a ready function
Klass
.
ready
(
function
()
{
Klass
.
ready
(
function
(
g
)
{
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
;
...
...
@@ -2668,7 +2671,8 @@
});
return
gadget
.
declareGadget
(
html_url
);
})
.
then
(
function
()
{
.
then
(
function
(
result
)
{
equal
(
result
,
ready_gadget
,
"
Context should be the gadget instance
"
);
ok
(
called
);
})
.
fail
(
function
(
e
)
{
...
...
@@ -4052,8 +4056,12 @@
stop
();
root_gadget_defer
.
promise
.
then
(
function
(
root_gadget
)
{
.
then
(
function
(
root_gadget_list
)
{
var
root_gadget
=
root_gadget_list
[
0
],
html
;
// Check instance
equal
(
root_gadget_list
[
0
],
root_gadget_list
[
1
],
"
Context should be the gadget instance
"
);
equal
(
root_gadget
.
__path
,
root_gadget_path_without_hash
);
equal
(
typeof
root_gadget
.
__acquired_method_dict
,
'
object
'
);
...
...
@@ -4099,7 +4107,7 @@
URI
(
"
renderjs_test.js
"
)
.
absoluteTo
(
parent_path
).
toString
()
]);
var
html
=
root_gadget
.
constructor
.
__template_element
.
outerHTML
;
html
=
root_gadget
.
constructor
.
__template_element
.
outerHTML
;
ok
(
/^<div>
\s
*<h1 id="qunit-header">/
.
test
(
html
),
html
);
ok
(
root_gadget
instanceof
RenderJSGadget
);
ok
(
root_gadget_klass
,
root_gadget
.
constructor
);
...
...
@@ -4129,8 +4137,8 @@
test
(
'
__aq_parent fails on the root gadget
'
,
function
()
{
stop
();
root_gadget_defer
.
promise
.
then
(
function
(
root_gadget
)
{
return
root_gadget
.
__aq_parent
(
"
foo
"
,
"
bar
"
);
.
then
(
function
(
root_gadget
_list
)
{
return
root_gadget
_list
[
0
]
.
__aq_parent
(
"
foo
"
,
"
bar
"
);
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
renderJS
.
AcquisitionError
);
...
...
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