Page MenuHomePhabricator

OOjs: Mixin doesn't work properly with inherited classes
Closed, InvalidPublic

Description

Example:
ve.ce.MWBlockImageNode mixes in ve.ce.MWResizableNode which inherits from ve.ce.ResizableNode, however the methods from ve.ce.ResizableNode are not mixed in automatically if you just mix in ve.ce.MWResizableNode.


Version: unspecified
Severity: normal

Details

Reference
bz55557

Event Timeline

bzimport raised the priority of this task from to High.Nov 22 2014, 2:23 AM
bzimport added a project: OOjs core.
bzimport set Reference to bz55557.

This is by design.

Mixing in a class only copies over own properties. Not inherited properties.

JavaScript can't have an object inherit from multiple parents. We have the convention to not alter mixins once defined. So copying over one is fine. But the parent of a mixin, I'm not so sure (and we'd have to distinguish it from any prototypes in the chain we don't want to copy manually, such as Function prototype and Object prototype).

If the "sub mixin" doesn't care about live inheritance (and it can't care, because mixins can't be live since they always copy over), then the sub mixin should just use 'mixin' for its 'parent' not 'inherit'.