FLUID-4166: instantiator.clearComponent() will fail to clear components which appear at multiple paths

Metadata

Source
FLUID-4166
Type
Bug
Priority
Major
Status
Closed
Resolution
Fixed
Assignee
Antranig Basman
Reporter
Antranig Basman
Created
2011-03-30T02:00:53.477-0400
Updated
2014-03-03T13:11:54.682-0500
Versions
  1. 1.3.1
Fixed Versions
  1. 1.5
Component
  1. IoC System

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"

Comments

  • y z commented 2011-03-31T10:16:23.797-0400

    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);
    });

  • Antranig Basman commented 2012-08-21T03:22:08.444-0400

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