instantiator.clearComponent() will fail to clear components which appear at multiple paths

Description

As a result of directly reusing the fluid.visitComponentChildren implementation from the core context resolution algorithm, instantiator.clearComponent() will cease traversal on encountering the SAME COMPONENT, rather than ceasing at the weaker condition of encountering the SAME PATH - in fact condition ii) will be met immediately following condition i) as the children of the "misplaced component" will be discovered at presumably already discovered paths. However, clearComponent() still requires to clear them even if they are not used as recursion points. THER CATTT agrees: "MRRAOURW"

Environment

None

Activity

Show:

Antranig Basman August 21, 2012 at 7:22 AM

This was resolved at commit 47d38c9 which will land for the 1.5 release

y z March 31, 2011 at 2:16 PM

Here's a pastie of a failing test: http://pastebin.com/96HYca6z
Here's a code just in case:

fluid.defaults("fluid.tests.component4166", {
gradeNames: ["fluid.littleComponent"],
components: {
instantiator: "{instantiator}"
}
});
fluid.defaults("fluid.tests.component4166child", {
gradeNames: ["fluid.littleComponent", "autoInit"],
components: {
instantiator: "{instantiator}"
}
});
fluid.defaults("fluid.tests.component4166grandchild", {
gradeNames: ["fluid.littleComponent", "autoInit"],
components: {
greatgrandchild: {
type: "fluid.tests.component4166greatgrandchild"
}
}
});
fluid.defaults("fluid.tests.component4166greatgrandchild", {
gradeNames: "fluid.littleComponent",
components: {
greatgreatgrandchild: {
type: "fluid.tests.component4166greatgreatgrandchild"
}
}
});
fluid.defaults("fluid.tests.component4166greatgreatgrandchild", {
gradeNames: ["fluid.littleComponent", "autoInit"]
});
fluid.tests.component4166greatgrandchild = function (options) {
var that = fluid.initLittleComponent("fluid.tests.component4166greatgrandchild", options);
fluid.initDependents(that);
return that.greatgreatgrandchild;
};

fluid.tests.component4166 = fluid.littleComponent("fluid.tests.component4166");

var testCreation = function (parent) {
parent.options.components.child = {
type: "fluid.tests.component4166child"
};
fluid.initDependent(parent, "child", parent.instantiator);
jqUnit.assertValue("Child is created", parent.child);
var child = parent.child;
child.options.components.grandchild = {
type: "fluid.tests.component4166grandchild"
};
fluid.initDependent(child, "grandchild", child.instantiator);
jqUnit.assertValue("Grandchild is created", child.grandchild);
jqUnit.assertValue("Greatgrandchild is created", child.grandchild.greatgrandchild);
};

fluidIoCTests.test("FLUID-4166 recreation after clear component", function() {
var parent = fluid.tests.component4166();
jqUnit.assertValue("Parent is created", parent);
testCreation(parent);
parent.instantiator.clearComponent(parent, "child");
testCreation(parent);
});

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created March 30, 2011 at 6:00 AM
Updated March 3, 2014 at 6:11 PM
Resolved August 21, 2012 at 7:22 AM