Uploaded image for project: 'Fluid Infusion'
  1. Fluid Infusion
  2. FLUID-6126

Failure when using fluid.construct to construct component as direct child of root which is target of a distribution

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: None
    • Component/s: IoC System
    • Labels:
      None

      Description

      An annoying edge case creates a bad interaction between fluid.construct and fluid.computeDistributionPriority -> fluid.getMemberNames.

      If there is a global distribution which is capable of hitting components which are directly attached to the root, e.g.

      fluid.defaults("fluid.authoring.nexus.componentTracker", {
          gradeNames: ["fluid.component", "fluid.resolveRoot"],
          distributeOptions: {
              modelTracker: {
                  record: "fluid.authoring.nexus.modelTracker",
                  target: "{/ fluid.modelComponent}.options.gradeNames"
              }
          }
      });
      

      using fluid.construct, say, with a path of "sample-model-component-0" to construct a component directly attached to the root will trigger a failure

      TypeError: Cannot read property 'id' of undefined
          at Object.fluid.getMemberNames (E:\\source\\gits\\fluid-authoring\\node_modules\\infusion\\src\\framework\\core\\js\\FluidIoC.js:87:73)
      

      since we don't handle the case where the path stack is empty. fluid.getMemberNames is pretty suspect anyway and has been ripe for fencepost errors for many years:

          fluid.getMemberNames = function (instantiator, thatStack) {
              var path = instantiator.idToPath(thatStack[thatStack.length - 1].id);
              var segs = instantiator.parseEL(path);
                  // TODO: we should now have no longer shortness in the stack
              segs.unshift.apply(segs, fluid.generate(thatStack.length - segs.length, ""));
      
              return segs;
          };
      

        Attachments

          Activity

            People

            Assignee:
            antranig Antranig Basman
            Reporter:
            antranig Antranig Basman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: