Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

FLUID-5279: Stopgap fix for "produceTree is undefined" error #473

Merged
merged 3 commits into from

3 participants

@cindyli
Owner

Thanks for the fix, @amb26. I tried with this pull and "produceTree is undefined" error has been fixed.

However, it seems having another issue with renderer relay components that "protoTree"s always receive the default model value rather than the relayed new value. I created a unit test and sent a pull request against your FLUID-5279 branch to show it: amb26#2

The unit test would pass by removing the declaration of the default model structure, which is these three lines: https://github.com/cindyli/infusion/blob/1bd4befc6a4ed4329b5f0ff570c9361055909e39/src/tests/framework-tests/renderer/js/RendererUtilitiesTests.js#L848-L850

Thanks.

@colinbdclark colinbdclark merged commit a65561c into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 18, 2014
  1. Merge branch 'master' into FLUID-5279

    Cindy Qi Li authored
Commits on Feb 19, 2014
  1. @amb26

    FLUID-5279: Stopgap fix for FLUID-5279 (old renderer will be destroye…

    amb26 authored
    …d, no better is warranted)
This page is out of date. Refresh to see the latest.
View
26 src/framework/renderer/js/RendererUtilities.js
@@ -154,21 +154,29 @@ fluid_1_5 = fluid_1_5 || {};
});
fluid.rendererComponent.renderOnInit = function (renderOnInit, that) {
- if (renderOnInit) {
+ if (renderOnInit || that.renderOnInit) {
that.refreshView();
}
};
fluid.rendererComponent.refreshView = function (that) {
- fluid.renderer.clearDecorators(that);
- that.events.prepareModelForRender.fire(that.model, that.applier, that);
- var tree = that.produceTree(that);
- if (that.renderer.expander) {
- tree = that.renderer.expander(tree);
+ if (!that.renderer) {
+ // Terrible stopgap fix for FLUID-5279 - all of this implementation will be swept away
+ // model relay may cause this to be called during init, and we have no proper definition for "that.renderer" since it is
+ // constructed in a terrible way
+ that.renderOnInit = true;
+ return;
+ } else {
+ fluid.renderer.clearDecorators(that);
+ that.events.prepareModelForRender.fire(that.model, that.applier, that);
+ var tree = that.produceTree(that);
+ if (that.renderer.expander) {
+ tree = that.renderer.expander(tree);
+ }
+ that.events.onRenderTree.fire(that, tree);
+ that.renderer.render(tree);
+ that.events.afterRender.fire(that);
}
- that.events.onRenderTree.fire(that, tree);
- that.renderer.render(tree);
- that.events.afterRender.fire(that);
};
fluid.rendererComponent.produceTree = function (that) {
View
5 src/tests/framework-tests/renderer/html/RendererUtilities-test.html
@@ -177,6 +177,11 @@ <h2 id="qunit-userAgent"></h2>
<span class="flc-fluid4986-simpleBound6"></span>
</div>
+ <div id="FLUID-5279">
+ <div class="flc-main"></div>
+ <div class="flc-sub"></div>
+ </div>
+
</div>
<script>
View
60 src/tests/framework-tests/renderer/js/RendererUtilitiesTests.js
@@ -744,6 +744,64 @@ fluid.registerNamespace("fluid.tests");
fluid.each(inputs, function (element) {element.click();});
jqUnit.assertDomEquals("Click handlers registered by afterRender", inputs, that.clicked);
});
+
+ // FLUID-5279: "that.produceTree is not a function" when refreshView() is called as a model (relayed) listenr on a renderer relay component
+ fluid.defaults("fluid.tests.fluid5279", {
+ gradeNames: ["fluid.rendererRelayComponent", "autoInit"],
+ components: {
+ attributes: {
+ type: "fluid.rendererRelayComponent",
+ createOnEvent: "afterRender",
+ container: ".flc-sub",
+ options: {
+ model: "{fluid5279}.model",
+ modelListeners: {
+ "audio": "{that}.refreshView"
+ },
+ events: {
+ afterRender: "{fluid5279}.events.afterAttributesRendered"
+ },
+ resources: {
+ template: {
+ resourceText: "<div></div>"
+ }
+ }
+ }
+ }
+ },
+ model: {
+ audio: "available"
+ },
+ resources: {
+ template: {
+ resourceText: "<div></div>"
+ }
+ },
+ events: {
+ afterAttributesRendered: null,
+ onReady: {
+ events: {
+ onCreate: "onCreate",
+ afterAttributesRendered: "afterAttributesRendered"
+ },
+ args: "{that}"
+ }
+ },
+ listeners: {
+ "onCreate.init": "{that}.refreshView"
+ }
+ });
+
+ jqUnit.asyncTest("FLUID-5279: Direct model sharing for renderer relay components", function () {
+ var that = fluid.tests.fluid5279(".flc-main", {
+ listeners: {
+ onReady: function (that) {
+ jqUnit.assertNotUndefined("The component has been instantiated", that);
+ jqUnit.start();
+ }
+ }
+ });
+ });
jqUnit.module("Protocomponent Expander Tests");
@@ -1814,6 +1872,7 @@ fluid.registerNamespace("fluid.tests");
},
renderOnInit: true
});
+
jqUnit.test("FLUID-4986: Select", function () {
var that = fluid.tests.fluid4986("#FLUID-4986");
jqUnit.assertEquals("Select should be rendered properly", that.model.select, that.locate("select").val());
@@ -1831,4 +1890,5 @@ fluid.registerNamespace("fluid.tests");
"${{test}.string}", that.locate("simpleBound6").text());
});
};
+
})(jQuery);
Something went wrong with that request. Please try again.