#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: | Owned by: | sjmiles | |
---|---|---|---|
Priority: | high | Milestone: | 1.1 |
Component: | Core | Version: | 1.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description (last modified by )
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 15 years ago by
comment:2 Changed 15 years ago by
Component: | General → Core |
---|---|
Description: | modified (diff) |
Owner: | changed from anonymous to sjmiles |
Reporter: | changed from guest to [email protected]… |
Summary: | Mixin Sets Inherited Property to '' When Inheritied Class and Mixed In Class Share a Common Base Class → dojo.declare: Mixin Sets Inherited Property to '' When Inheritied Class and Mixed In Class Share a Common Base Class |
comment:3 Changed 14 years ago by
Status: | new → assigned |
---|
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 14 years ago by
Milestone: | → 1.2 |
---|
comment:5 Changed 14 years ago by
Milestone: | 1.2 → 1.1 |
---|---|
Resolution: | → worksforme |
Status: | assigned → closed |
comment:6 Changed 14 years ago by
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
I thought I added my email...but I don't see it in the cc...in any case here it is: [email protected]…