FLUID-4939: Init functions that are specified in the defaults run multiple times when modifying gradeNames at instantiation

Metadata

Source
FLUID-4939
Type
Bug
Priority
Critical
Status
Closed
Resolution
Fixed
Assignee
N/A
Reporter
Justin Obara
Created
2013-03-20T09:27:42.202-0400
Updated
2013-03-26T08:48:12.397-0400
Versions
N/A
Fixed Versions
N/A
Component
  1. Framework
  2. IoC System

Description

If you specify init functions in the components defaults and modify the components gradeNames when you initialize it. The init functions will be run multiple times.

Example:

fluid.defaults("fluid.someComp", {
gradeNames: ["fluid.littleComponent", "autoInit"]
finalInitFunction: "fluid.someComp.finalInit"
});

fluid.someComp.finalInit = function (that) { //do something};

// This will cause fluid.someComp.finalInit to be executed twice.
fluid.someComp({
gradeNames: ["newGrade"]
});

Comments

  • Justin Obara commented 2013-03-20T09:32:43.348-0400

    Added a test case in a branch on my github repo
    https://github.com/jobara/infusion/tree/FLUID-4939

  • Michelle D'Souza commented 2013-03-22T12:21:06.923-0400

    Merged pull request https://github.com/fluid-project/infusion/pull/272 into project repo at e6152e3

  • Justin Obara commented 2013-03-22T13:26:37.130-0400

    Found another variant of the issue. This time it happens when there is a circular grade reference. For example if the component adds a grade that had included the component itself as a grade. The framework is supposed to ignore duplicate grades, so this should work. I've added another test to my branch for this.

    Example:

    fluid.defaults("fluid.someComp", {
    gradeNames: ["fluid.littleComponent", "autoInit"]
    finalInitFunction: "fluid.someComp.finalInit"
    });

    fluid.someComp.finalInit = function (that) { //do something};

    fluid.defaults("fluid.newGrade", {
    gradeNames: ["fluid.someComp", "autoInit"]
    });

    // This will cause fluid.someComp.finalInit to be executed twice.
    fluid.someComp({
    gradeNames: ["fluid.newGrade"]
    });

  • Antranig Basman commented 2013-03-24T15:26:36.636-0400

    Thanks for the additional test case, jobara - this has now also a fix applied

  • Michelle D'Souza commented 2013-03-25T11:05:40.502-0400

    Pull request https://github.com/fluid-project/infusion/pull/273 merged into project repo at 8211b41