FLUID-5030: "createOnEvent" and events from additive grades are not merged in properly

Metadata

Source
FLUID-5030
Type
Bug
Priority
Major
Status
Closed
Resolution
Not A Bug
Assignee
Antranig Basman
Reporter
Cindy Li
Created
2013-06-03T14:43:03.119-0400
Updated
2014-03-03T11:49:41.119-0500
Versions
N/A
Fixed Versions
  1. 1.4
Component
  1. Framework

Description

Example:

A component has an additive grade defined:

fluid.defaults("fluid.tests.fluid5030Root", {
gradeNames: ["fluid.eventedComponent", "fluid.tests.fluid5030Grade", "autoInit"],
...
});

The grade component defines its own events and a subcomponent with a createOnEvent being one of these own events:

fluid.defaults("fluid.tests.fluid5030Grade", {
gradeNames: ["fluid.tests.fluid5030Root", "autoInit"],
events: {
myevent: null
},
components: {
subComponent: {
createOnEvent: "myevent"
}
}
...
});

Create an instance of "fluid.tests.fluid5030Root"; in this instance,
1. the "myevent" is not found
2. the "subComponent" is created regardless of whether or not its createOnEvent is fired.

The test case to demonstrate this issue: https://github.com/cindyli/infusion/blob/FLUID-5010/src/webapp/tests/framework-tests/core/js/FluidIoCTests.js#L2763-2802

Comments

  • Antranig Basman commented 2013-06-03T17:21:48.485-0400

    When rewritten to the following, the test case works correctly -

    /** FLUID-5030 - "createOnEvent" and events from additive grades are not merged in properly **/

    fluid.defaults("fluid.tests.fluid5030Grade", {
    gradeNames: ["fluid.eventedComponent"],
    events: {
    creationEvent: null
    },
    listeners: {
    creationEvent: {
    listener: "fluid.tests.fluid5030listener",
    args: "{that}"
    }
    },
    components: {
    subComponent: {
    createOnEvent: "creationEvent"
    }
    }
    });

    fluid.defaults("fluid.tests.fluid5030Root", {
    gradeNames: ["fluid.eventedComponent", "fluid.tests.fluid5030Grade", "autoInit"],
    components: {
    subComponent: {
    type: "fluid.tests.fluid5030Sub"
    }
    }
    });

    fluid.defaults("fluid.tests.fluid5030Sub", {
    gradeNames: ["fluid.eventedComponent", "autoInit"]
    });

    fluid.tests.fluid5030listener = function (that) {
    that.creationEventFired = true;
    };

    jqUnit.test("FLUID-5030 - createOnEvent and events from additive grades are not merged in properly", function () {
    var root = fluid.tests.fluid5030Root();

    jqUnit.assertNotUndefined("The event defined in the grade component is merged in", root.events.creationEvent);
    jqUnit.assertFalse("The createOnEvent is not fired", root.creationEventFired);
    jqUnit.assertUndefined("The subcomponent that should be created on createOnEvent is not created", root.subComponent);
    });

    This is exposing the fact that the issue is in fact a different one - I reported this as FLUID-5032 and closing in favour of that issue: You will notice that in the test you submitted, there are TWO failures rather than one - the first test, that the event defined in the grade component also fails, as well as the unexpected early creation of the subcomponent which is meant to be delayed until an event. This shows that actually none of the material in "fluid.tests.fluid5030Grade" is reaching the component, not just the "createOnEvent" annotation.

  • Antranig Basman commented 2013-06-03T17:22:21.918-0400

    Closed in favour of FLUID-5032