Created
January 12, 2018 15:06
-
-
Save the-t-in-rtf/6a85c3cf9676d227748a20180a09b929 to your computer and use it in GitHub Desktop.
Demonstration of problem with dynamic components and member options.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-env node */ | |
| "use strict"; | |
| var fluid = require("infusion"); | |
| fluid.setLogging(true); | |
| var my = fluid.registerNamespace("my"); | |
| fluid.defaults("my.generatingComponent", { | |
| gradeNames: ["fluid.component"], | |
| events: { | |
| createWithNormalOption: null, | |
| createWithMemberOption: null, | |
| createWithMemberOptionWorkaround: null | |
| }, | |
| dynamicComponents: { | |
| normal: { | |
| type: "fluid.component", | |
| createOnEvent: "createWithNormalOption", | |
| options: { | |
| normalOption: "{arguments}.0", | |
| listeners: { | |
| "onCreate.logArgumentOption": { | |
| funcName: "fluid.log", | |
| args: ["normal option:", "{that}.options.normalOption"] | |
| } | |
| } | |
| } | |
| }, | |
| member: { | |
| type: "fluid.component", | |
| createOnEvent: "createWithMemberOption", | |
| options: { | |
| members: { | |
| memberOption: "{arguments}.0" | |
| }, | |
| listeners: { | |
| "onCreate.logArgumentOption": { | |
| funcName: "fluid.log", | |
| args: ["member option:", "{that}.memberOption"] | |
| } | |
| } | |
| } | |
| }, | |
| memberWorkaround: { | |
| type: "fluid.component", | |
| createOnEvent: "createWithMemberOptionWorkaround", | |
| options: { | |
| normalOption: "{arguments}.0", | |
| members: { | |
| memberOption: "{that}.options.normalOption" | |
| }, | |
| listeners: { | |
| "onCreate.logArgumentOption": { | |
| funcName: "fluid.log", | |
| args: ["member option (workaround):", "{that}.memberOption"] | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| var that = my.generatingComponent(); | |
| that.events.createWithNormalOption.fire("works fine."); | |
| that.events.createWithMemberOptionWorkaround.fire("also works fine."); | |
| that.events.createWithMemberOption.fire("does not work."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment