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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
renderjs
Commits
68780336
Commit
68780336
authored
Apr 11, 2014
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aq_parent is not part of the API.
Use declareAcquiredMethod instead.
parent
d267fc0e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
36 deletions
+36
-36
renderjs.js
renderjs.js
+6
-6
test/renderjs_test.js
test/renderjs_test.js
+30
-30
No files found.
renderjs.js
View file @
68780336
...
...
@@ -104,7 +104,7 @@
})
.
push
(
undefined
,
function
(
error
)
{
if
(
error
instanceof
renderJS
.
AcquisitionError
)
{
return
gadget
.
aq_parent
(
method_name
,
argument_list
);
return
gadget
.
__
aq_parent
(
method_name
,
argument_list
);
}
throw
error
;
});
...
...
@@ -359,8 +359,8 @@
// Set the HTML context
.
push
(
function
(
gadget_instance
)
{
var
i
;
// Define aq_parent to reach parent gadget
gadget_instance
.
aq_parent
=
function
(
method_name
,
argument_list
)
{
// Define
__
aq_parent to reach parent gadget
gadget_instance
.
__
aq_parent
=
function
(
method_name
,
argument_list
)
{
return
acquire
.
apply
(
parent_gadget
,
[
method_name
,
argument_list
]);
};
// Drop the current loading klass info used by selector
...
...
@@ -723,7 +723,7 @@
// Stop acquisition on the original root gadget
// Do not put this on the klass, as their could be multiple instances
root_gadget
.
aq_parent
=
function
(
method_name
)
{
root_gadget
.
__
aq_parent
=
function
(
method_name
)
{
throw
new
renderJS
.
AcquisitionError
(
"
No gadget provides
"
+
method_name
);
...
...
@@ -796,8 +796,8 @@
tmp_constructor
.
allowPublicAcquisition
=
RenderJSGadget
.
allowPublicAcquisition
;
// Define aq_parent to inform parent window
tmp_constructor
.
prototype
.
aq_parent
=
function
(
method_name
,
// Define
__
aq_parent to inform parent window
tmp_constructor
.
prototype
.
__
aq_parent
=
function
(
method_name
,
argument_list
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
embedded_channel
.
call
({
...
...
test/renderjs_test.js
View file @
68780336
...
...
@@ -1306,7 +1306,7 @@
});
});
test
(
'
returns aq_parent result if acquired_method raises AcquisitionError
'
,
test
(
'
returns
__
aq_parent result if acquired_method raises AcquisitionError
'
,
function
()
{
// Subclass RenderJSGadget to not pollute its namespace
var
Klass
=
function
()
{
...
...
@@ -1314,7 +1314,7 @@
},
gadget
,
i
=
0
,
aq_dynamic_called
=
false
,
aq_parent_called
=
false
,
__
aq_parent_called
=
false
,
original_method_name
=
"
foo
"
,
original_argument_list
=
[
"
foobar
"
,
"
barfoo
"
];
Klass
.
prototype
=
new
RenderJSGadget
();
...
...
@@ -1330,14 +1330,14 @@
aq_dynamic_called
=
true
;
equal
(
i
,
0
,
"
aquired_method called first
"
);
i
+=
1
;
throw
new
renderJS
.
AcquisitionError
(
"
please call aq_parent!
"
);
throw
new
renderJS
.
AcquisitionError
(
"
please call
__
aq_parent!
"
);
};
gadget
=
new
Klass
();
gadget
.
aq_parent
=
function
(
method_name
,
argument_list
)
{
aq_parent_called
=
true
;
equal
(
i
,
1
,
"
aq_parent called after acquired_method
"
);
gadget
.
__
aq_parent
=
function
(
method_name
,
argument_list
)
{
__
aq_parent_called
=
true
;
equal
(
i
,
1
,
"
__
aq_parent called after acquired_method
"
);
equal
(
this
,
gadget
,
"
Context should be kept
"
);
equal
(
method_name
,
original_method_name
,
"
Method name should be kept
"
);
deepEqual
(
argument_list
,
original_argument_list
,
...
...
@@ -1351,20 +1351,20 @@
.
then
(
function
(
result
)
{
equal
(
result
,
"
FOO
"
);
equal
(
aq_dynamic_called
,
true
);
equal
(
aq_parent_called
,
true
);
equal
(
__
aq_parent_called
,
true
);
})
.
always
(
function
()
{
start
();
});
});
test
(
'
returns aq_parent result if acquired_method does not exists
'
,
test
(
'
returns
__
aq_parent result if acquired_method does not exists
'
,
function
()
{
// Subclass RenderJSGadget to not pollute its namespace
var
Klass
=
function
()
{
RenderJSGadget
.
call
(
this
);
},
gadget
,
aq_parent_called
=
false
,
__
aq_parent_called
=
false
,
original_method_name
=
"
foo
"
,
original_argument_list
=
[
"
foobar
"
,
"
barfoo
"
];
Klass
.
prototype
=
new
RenderJSGadget
();
...
...
@@ -1377,8 +1377,8 @@
gadget
=
new
Klass
();
gadget
.
aq_parent
=
function
(
method_name
,
argument_list
)
{
aq_parent_called
=
true
;
gadget
.
__
aq_parent
=
function
(
method_name
,
argument_list
)
{
__
aq_parent_called
=
true
;
equal
(
this
,
gadget
,
"
Context should be kept
"
);
equal
(
method_name
,
original_method_name
,
"
Method name should be kept
"
);
deepEqual
(
argument_list
,
original_argument_list
,
...
...
@@ -1391,14 +1391,14 @@
gadget
.
checkIfAqDynamicIsUndefined
(
"
foobar
"
,
"
barfoo
"
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
FOO
"
);
equal
(
aq_parent_called
,
true
);
equal
(
__
aq_parent_called
,
true
);
})
.
always
(
function
()
{
start
();
});
});
test
(
'
fails if aq_parent throws an error
'
,
function
()
{
test
(
'
fails if
__
aq_parent throws an error
'
,
function
()
{
// Subclass RenderJSGadget to not pollute its namespace
var
Klass
=
function
()
{
RenderJSGadget
.
call
(
this
);
...
...
@@ -1413,7 +1413,7 @@
gadget
=
new
Klass
();
gadget
.
aq_parent
=
function
()
{
gadget
.
__
aq_parent
=
function
()
{
throw
original_error
;
};
...
...
@@ -1428,7 +1428,7 @@
});
});
test
(
'
fails if aq_parent is not defined
'
,
function
()
{
test
(
'
fails if
__
aq_parent is not defined
'
,
function
()
{
// Subclass RenderJSGadget to not pollute its namespace
var
Klass
=
function
()
{
RenderJSGadget
.
call
(
this
);
...
...
@@ -1447,7 +1447,7 @@
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
TypeError
);
ok
((
error
.
message
===
"
gadget.aq_parent is not a function
"
)
||
"
gadget.
__
aq_parent is not a function
"
)
||
(
error
.
message
===
"
undefined is not a function
"
),
error
);
})
...
...
@@ -1507,17 +1507,17 @@
});
/////////////////////////////////////////////////////////////////
// RenderJSGadget.aq_parent
// RenderJSGadget.
__
aq_parent
/////////////////////////////////////////////////////////////////
module
(
"
RenderJSGadget.aq_parent
"
,
{
module
(
"
RenderJSGadget.
__
aq_parent
"
,
{
setup
:
function
()
{
renderJS
.
clearGadgetKlassList
();
}
});
test
(
'
aq_parent does not exist by default
'
,
function
()
{
test
(
'
__
aq_parent does not exist by default
'
,
function
()
{
var
gadget
=
new
RenderJSGadget
();
equal
(
gadget
.
aq_parent
,
undefined
);
equal
(
gadget
.
__
aq_parent
,
undefined
);
});
/////////////////////////////////////////////////////////////////
...
...
@@ -1761,7 +1761,7 @@
ok
(
gadget
instanceof
RenderJSGadget
);
ok
(
gadget
instanceof
RenderJSIframeGadget
);
ok
(
RenderJSIframeGadget
!==
RenderJSGadget
);
ok
(
gadget
.
aq_parent
===
undefined
);
ok
(
gadget
.
__
aq_parent
===
undefined
);
});
/////////////////////////////////////////////////////////////////
...
...
@@ -1803,7 +1803,7 @@
ok
(
gadget
instanceof
RenderJSGadget
);
ok
(
gadget
instanceof
RenderJSEmbeddedGadget
);
ok
(
RenderJSEmbeddedGadget
!==
RenderJSGadget
);
ok
(
gadget
.
aq_parent
===
undefined
);
ok
(
gadget
.
__
aq_parent
===
undefined
);
});
/////////////////////////////////////////////////////////////////
...
...
@@ -2302,15 +2302,15 @@
});
});
test
(
'
Generate aq_parent on created gadget
'
,
function
()
{
// Check that aq_parent returns parent gadget acquire result
test
(
'
Generate
__
aq_parent on created gadget
'
,
function
()
{
// Check that
__
aq_parent returns parent gadget acquire result
var
gadget
=
new
RenderJSGadget
(),
acquire_called
=
false
,
original_method_name
=
"
foo
"
,
original_argument_list
=
[
"
foobar
"
,
"
barfoo
"
],
html_url
=
'
http://example.org/files/qunittest/test353.html
'
;
gadget
.
aq_parent
=
function
(
method_name
,
argument_list
)
{
gadget
.
__
aq_parent
=
function
(
method_name
,
argument_list
)
{
acquire_called
=
true
;
equal
(
this
,
gadget
,
"
Context should be kept
"
);
equal
(
method_name
,
original_method_name
,
"
Method name should be kept
"
);
...
...
@@ -2327,7 +2327,7 @@
stop
();
gadget
.
declareGadget
(
html_url
)
.
then
(
function
(
new_gadget
)
{
return
new_gadget
.
aq_parent
(
return
new_gadget
.
__
aq_parent
(
original_method_name
,
original_argument_list
);
...
...
@@ -2517,7 +2517,7 @@
acquire_called
=
false
,
url
=
"
./embedded.html
"
;
gadget
.
aq_parent
=
function
(
method_name
,
argument_list
)
{
gadget
.
__
aq_parent
=
function
(
method_name
,
argument_list
)
{
acquire_called
=
true
;
equal
(
this
,
gadget
,
"
Context should be kept
"
);
if
(
method_name
===
"
acquireMethodRequested
"
)
{
...
...
@@ -2791,7 +2791,7 @@
ok
(
/^<div>
\s
*<h1 id="qunit-header">/
.
test
(
html
),
html
);
ok
(
root_gadget
instanceof
RenderJSGadget
);
ok
(
root_gadget_klass
,
root_gadget
.
constructor
);
ok
(
root_gadget
.
aq_parent
!==
undefined
);
ok
(
root_gadget
.
__
aq_parent
!==
undefined
);
ok
(
root_gadget
.
hasOwnProperty
(
"
__sub_gadget_dict
"
));
deepEqual
(
root_gadget
.
__sub_gadget_dict
,
{});
})
...
...
@@ -2803,11 +2803,11 @@
});
});
test
(
'
aq_parent fails on the root gadget
'
,
function
()
{
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
"
);
return
root_gadget
.
__
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