Skip to content

Commit d4eb250

Browse files
committed
Merge pull request #34 from troopjs/feature/weave-bridge
Publishing weave/unweave to bridge troopjs 1.x widgets.
2 parents c994421 + 52ae995 commit d4eb250

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

component/widget.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ define([ "troopjs-core/component/gadget", "jquery", "../loom/config", "../loom/w
5858
var args = ARRAY_SLICE.call(arguments, 1);
5959

6060
// Call render with contents (or result of contents if it's a function)
61-
return weave.call($fn.call(me[$ELEMENT],
62-
typeof contents === TYPEOF_FUNCTION ? contents.apply(me,args) : contents
63-
).find(SELECTOR_WEAVE));
61+
$fn.call(
62+
me[$ELEMENT],
63+
typeof contents === TYPEOF_FUNCTION ? contents.apply(me, args) : contents
64+
);
65+
return me.weave();
6466
}
6567

6668
return render;
@@ -149,6 +151,8 @@ define([ "troopjs-core/component/gadget", "jquery", "../loom/config", "../loom/w
149151
* @returns {Promise} from weave
150152
*/
151153
"weave" : function () {
154+
// Publishing for weaving in, to notify parties that use a different loom configuration, e.g. other Troop versions.
155+
this.publish("weave", this);
152156
return weave.apply(this[$ELEMENT].find(SELECTOR_WEAVE), arguments);
153157
},
154158

@@ -157,6 +161,8 @@ define([ "troopjs-core/component/gadget", "jquery", "../loom/config", "../loom/w
157161
* @returns {Promise} from unweave
158162
*/
159163
"unweave" : function () {
164+
// Publishing for unweaveing.
165+
this.publish("unweave", this);
160166
return unweave.apply(this[$ELEMENT].find(SELECTOR_UNWEAVE).addBack(), arguments);
161167
},
162168

0 commit comments

Comments
 (0)