Skip to content

Commit 1ae68f1

Browse files
committed
Fix argument propagation in _signal and weave/unweave
1 parent c3e8643 commit 1ae68f1

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/application/widget.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,25 @@ define([ "module", "../component/widget", "when" ], function ApplicationWidgetMo
99
var CHILDREN = "children";
1010
var ARRAY_SLICE = Array.prototype.slice;
1111

12-
function forward(signal) {
12+
function forward() {
1313
var self = this;
14-
var args = arguments;
14+
var _signal = this.signal;
1515
var children = self[CHILDREN];
1616
var length = children ? children.length : 0;
1717
var index = 0;
18+
var args;
1819

1920
function next(_args) {
21+
// Update args
2022
args = _args || args;
2123

24+
// Return a chained promise of next callback, or a promise resolved with args
2225
return length > index
23-
? when(children[index++].signal(signal), next)
26+
? when(_signal.apply(children[index++], args), next)
2427
: when.resolve(args);
2528
}
2629

27-
return next();
30+
return next(ARRAY_SLICE.call(arguments));
2831
}
2932

3033
return Widget.extend(function ApplicationWidget($element, name, children) {

src/component/widget.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ define([ "troopjs-core/component/gadget", "jquery", "troopjs-jquery/weave", "tro
1313
var $TRIGGER = $.fn.trigger;
1414
var $ON = $.fn.on;
1515
var $OFF = $.fn.off;
16+
var $WEAVE = $.fn.weave;
17+
var $UNWEAVE = $.fn.unweave;
1618
var $ELEMENT = "$element";
1719
var $HANDLERS = "$handlers";
1820
var ATTR_WEAVE = "[data-weave]";
@@ -147,18 +149,18 @@ define([ "troopjs-core/component/gadget", "jquery", "troopjs-jquery/weave", "tro
147149

148150
/**
149151
* Weaves all children of $element
150-
* @returns self
152+
* @returns {Promise} from $.fn.weave
151153
*/
152154
"weave" : function weave() {
153-
return this[$ELEMENT].find(ATTR_WEAVE).weave();
155+
return $WEAVE.apply(this[$ELEMENT].find(ATTR_WEAVE), arguments);
154156
},
155157

156158
/**
157159
* Unweaves all children of $element _and_ self
158-
* @returns self
160+
* @returns {Promise} from $.fn.unweave
159161
*/
160162
"unweave" : function unweave() {
161-
return this[$ELEMENT].find(ATTR_WOVEN).addBack().unweave();
163+
return $UNWEAVE.apply(this[$ELEMENT].find(ATTR_WOVEN).addBack(), arguments);
162164
},
163165

164166
/**

0 commit comments

Comments
 (0)