FLUID-4285: Provide diagnostics in common cases of error in defining component and subcomponent options

Metadata

Source
FLUID-4285
Type
Bug
Priority
Major
Status
Closed
Resolution
Fixed
Assignee
Colin Clark
Reporter
Antranig Basman
Created
2011-06-07T17:49:22.763-0400
Updated
2011-07-04T15:00:49.000-0400
Versions
  1. 1.3.1
Fixed Versions
  1. 1.4
Component
  1. IoC System

Description

Reported on IRC by athena7 - the following code snippet will fail

var news = news || {};
			fluid.defaults("news.parent", {
				gradeNames: ["fluid.littleComponent", "autoInit"],
				options: {
					test: "test"
				},
				components: {
					child: {
						type: "news.child",
						options: {
							test: "{parent}.options.test"
						}
					}
				}
			});

			fluid.defaults("news.child", {
				gradeNames: ["fluid.littleComponent", "autoInit"],
			});
			
			var parent = news.parent({});
			console.log(parent.child.options.test);

Comments

  • Antranig Basman commented 2011-06-07T18:10:59.394-0400

    This is caused by an extra layer of wrapping in the defaults structure - the term "options" is unnecessary since ALL of the rh argument of fluid.defaults consists of options... this causes the value in question to appear at the path "options.options.test" rather than "options.test" as expected by the context expression (and, presumably, the component user)

  • Antranig Basman commented 2011-06-08T04:38:27.689-0400

    A further mishap in the same vein was caused by the following:

    var news = news || {};
    			fluid.defaults("news.parent", {
    				gradeNames: ["fluid.modelComponent", "autoInit"],
    				model: { test: "test" },
    				components: {
    					child: {
    						type: "news.child",
    						model: "{parent}.model"
    					}
    				}
    			});
    
    			fluid.defaults("news.child", {
    				gradeNames: ["fluid.modelComponent", "autoInit"],
    			});
    			
    			var parent = news.parent({});
    			console.log(parent.child.model);
    

    In this case, the necessarily "options" wrapping for options was omitted from the subcomponent record. Both of these situations should be detected by diagnostics and prevented.

  • Antranig Basman commented 2011-06-08T05:16:02.860-0400

    Bug Parade Infusion

  • Michelle D'Souza commented 2011-06-20T16:15:48.224-0400

    Pull request: https://github.com/fluid-project/infusion/pull/68

  • Colin Clark commented 2011-07-04T15:00:38.322-0400

    I pushed Antranig's changes to improve diagnostics into the project repo at https://github.com/fluid-project/infusion/commit/4df58836453b4a79a92237fc84e412ce5b260db5

  • Colin Clark commented 2011-07-04T15:00:48.998-0400

    Reviewed and pushed.