From 0d80db47924c135698305f91db28489561858c59 Mon Sep 17 00:00:00 2001 From: Mikael Karon Date: Thu, 21 Feb 2013 11:52:31 +0800 Subject: [PATCH] Filter promises for .woven. Closes troopjs/troopjs-jquery#14 Complete new weave implementation. Closes troopjs/troopjs-jquery#13 --- src/weave.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/weave.js b/src/weave.js index 95c887c..c5cbc74 100644 --- a/src/weave.js +++ b/src/weave.js @@ -363,13 +363,13 @@ define([ "require", "jquery", "when", "troopjs-utils/getargs", "troopjs-utils/fi // Iterate $(this).each(function (index, element) { - // Add promise of widgets to woven - woven[wovenLength++] = when.all($.data(element, WIDGETS), function (widgets) { - // Filter widgets using re - return widgets.filter(function (widget) { - return re.test(widget.displayName); - }); + // Filter widget promises + var $widgets = ($.data(element, WIDGETS) || []).filter(function ($widget) { + return re.test($widget[WEAVE]); }); + + // Add promise of widgets to woven + woven[wovenLength++] = when.all($widgets); }); } // Otherwise we can use a faster approach