Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#5426 closed defect (worksforme)

dojo.declare: Mixin Sets Inherited Property to '' When Inheritied Class and Mixed In Class Share a Common Base Class

Reported by: ole.ersoy@… Owned by: sjmiles
Priority: high Milestone: 1.1
Component: Core Version: 1.0
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

Hi,

This passes, but I'm expecting it to fail because isContainer should be true:

doh.assertTrue(this.uiContainerSelectableMix.isContainer == "");

In the tests below I have defined two classes that share a common base class. When I define a third class that inherits from UIContainer and mixes in UISelectable the UIContainer.isContainer property is set to "". If I comment out the UISelectable mixin, then the UIContainer.isContainer property is true. Note that it should be possible to duplicate the tests with any base class for UIContainer and UISelectable.

Here's the full test along with setup (Note that both UISelectable and UIContainer inherit from a common base class):

			name: UIContainerSelectableMix Test",

			uiContainerSelectableMix: "",

			setUp: function()
			{
				dojo.declare(	"UISelectable", 
								dojo4jsf.components.UIComponent,
				{
					isSelected: false,
				});
				
				dojo.declare(	"UIContainer", 
								dojo4jsf.components.UIComponent,
				{
					isContainer: true,
				});
								
				dojo.declare(	"UIContainerSelectableMix", 
								[UIContainer,
								 UISelectable],
				{
					
				});
				
				this.uiContainerSelectableMix = 
					new UIContainerSelectableMix();
					
						
						
	
			},
			
			runTest: function(t)
			{
				doh.assertTrue(this.uiContainerSelectableMix.isContainer == "");

                         }

If I replace dojo4jsf.components.UIComponent with null when defining the UIContainer and UISelectable the test works as expected...with isContainer being true.

Also if I comment out the UISelectable mixin on the definition of "UIContainerSelectableMix" like this:

				dojo.declare(	"UIContainerSelectableMix", 
								[UIContainer/*,
								 UISelectable*/],
				{
					
				});

Then this passes:

doh.assertTrue(this.uiContainerSelectableMix.isContainer);

Cheers,

  • Ole

Change History (6)

comment:1 Changed 12 years ago by guest

I thought I added my email...but I don't see it in the cc...in any case here it is: ole.ersoy@…

comment:2 Changed 12 years ago by bill

Component: GeneralCore
Description: modified (diff)
Owner: changed from anonymous to sjmiles
Reporter: changed from guest to ole.ersoy@…
Summary: Mixin Sets Inherited Property to '' When Inheritied Class and Mixed In Class Share a Common Base Classdojo.declare: Mixin Sets Inherited Property to '' When Inheritied Class and Mixed In Class Share a Common Base Class

comment:3 Changed 12 years ago by sjmiles

Status: newassigned
Note that it should be possible to duplicate the tests 
with any base class for UIContainer and UISelectable.

I wasn't able to recreate this problem with arbitrary base classes. That implies that dojo4jsf.components.UIComponent has an isContainer property of it's own.

Mixing two classes together that share a base class is not a standard use case. Generally the idea is to create classes for the unique parts.

dojo.declare("UISelectableMixin", null, {
  isSelected: false,
});
dojo.declare("UISelectable", [dojo4jsf.components.UIComponent, UISelectableMixin]);

dojo.declare("UIContainerMixin", null, {
  isContainer: true,
});
dojo.declare("UIContainer", [dojo4jsf.components.UIComponent, UIContainerMixin]);

dojo.declare("UIContainerSelectableMix", [dojo4jsf.components.UIComponent, UIContainerMixin, UISelectableMixin]);

comment:4 Changed 11 years ago by dylan

Milestone: 1.2

comment:5 Changed 11 years ago by sjmiles

Milestone: 1.21.1
Resolution: worksforme
Status: assignedclosed

comment:6 Changed 11 years ago by guest

Shoot - Sorry - Now that you mention it, I did add a isContainer() template method to UIComponent while experimenting.

So now the UIContainerSelectableMix has both a isContainer() method and a isContainer property.

Sorry again, I'll be more careful in the future.

Thanks for the class definition examples. I'll definitely be using that pattern more :-),

  • Ole
Note: See TracTickets for help on using tickets.