Ticket #2531567 (closed enhancement)

Reporter


Luke Smith
Opened: 12/9/11
Last modified: 05/10/12
Status: closed
Type: enhancement
Resolution: fixed

Owner


Satyen Desai
Target Release: 3.5.0
Priority: P3 (normal)
Summary: Class extensions can't define what static properties to augment the built class with
Description:

If I have a class extension that wants to add a static method or properties to the class it's being mixed into, there's not currently an easy way to do this.


function ExtA() {}
ExtA.staticMethod = function () {...}

var Foo = Y.Base.create('foo', Y.Base, [ExtA], proto, statics);

Foo.staticMethod === undefined; // sadly, true

The _buildCfg property of the main class includes an aggregates and custom keys, but that requires the main class to know what properties will be added to it.

Type: enhancement Observed in Version: 3.4.1
Component: Base Severity: S3 (normal)
Assigned To: Satyen Desai Target Release: 3.5.0
Location: Library Code Priority: P3 (normal)
Tags: Relates To:
Browsers: N/A
URL:
Test Information:

Change History

Ryan Grove

YUI Developer

Posted: 01/10/12

AutoComplete and View are both currently affected by this.

Luke Smith

YUI Contributor

Posted: 01/10/12

I created this workaround: https://gist.github.com/1587085

Luke Smith

YUI Contributor

Posted: 01/10/12

Somehow my comment removed you from the cc list.

Satyen Desai

YUI Developer

Posted: 01/31/12
  • milestone changed to 3.5.0
  • status changed from new to accepted

Satyen Desai

YUI Developer

Posted: 01/31/12
  • estimated changed from 0 to 1.5
  • remaining changed from 0 to 1.5
  • sprint changed to sprint 3

Likely to move the _buildCfg concept over to extensions also, and support a "statics" : true | ["getByNode", "foo", "bar"]

Satyen Desai

YUI Developer

Posted: 02/6/12

I'm thinking of dropping the statics:true support. So we'd only support statics:[...].

There are things like "superclass", "ATTRS", "NAME", "_buildCfg" etc., set up on the constructor, which result in brokenness when copied over from the Extension (say for cases where Ext -extends-> Base), for the statics:true case, combined with the fact that we overwrite:true going from left to right in the Y.Base.create(... main, [ext1, ext2, ext3], px, sx) signature.

Now, BaseBuild, could take care of *not copying* ATTRS, NAME, _buildCfg etc - the special stuff associated with Base and which it knows about, but cleaning up "superclass" started to feel messy ("superclass" is added by Y.extend), and subject to fragility. Starting to rethink blindly copying over ALL static references (which is why we probably stopped doing it for Y.extend - we temporarily did at one point), and keeping it to a whitelist for special cases like View.getByNode.

Let me know if you have any input.

Satyen Desai

YUI Developer

Posted: 02/6/12

Another good example is "NS" on Plugins. So BaseBuild would need to know that "NS" is special and not copy it over for statics:true - which is knowledge it currently does not have.

Satyen Desai

YUI Developer

Posted: 02/7/12

Pushed MyExt._buildCfg support to master. NOTE: statics:true is not support, as mentioned above. Only ...

MyExt._buildCfg = {
statics: [listOfStaticsToAlias],
aggregate: [listOfExtCentricStaticsToAggregate],
custom: {hashOfExtCentricStaticsToCustomMix}
};

Unit tests added to src/base/tests/base.html [ Build Tests ]

Forgot to add a Fixes #, so list of relevant commits are below ...

---

commit 37dbff50927d8f03cf6b383964bd322016050ad1
Author: Satyen Desai sdesai@yahoo-inc.com
Date: Mon Feb 6 16:10:05 2012 -0800

HISTORY update for MyExt._buildCfg support

commit db748fdbe02870b4c78302a13fc95ab765d474c0
Author: Satyen Desai sdesai@yahoo-inc.com
Date: Mon Feb 6 15:55:11 2012 -0800

Trailing comma cleanup

commit 862babd913910d11edc422e00e7b97ee7e1a1948
Merge: 52e7363 9c8236c
Author: Satyen Desai sdesai@yahoo-inc.com
Date: Mon Feb 6 15:52:07 2012 -0800

Merge remote-tracking branch 'upstream/master'

commit 52e73635546b2ee315b3d99cc7145a73ebc5b30e
Author: Satyen Desai sdesai@yahoo-inc.com
Date: Mon Feb 6 15:43:28 2012 -0800

Cleaned up Ext._buildCfg support. All buildCfg meta-data now merged
into a single shared hash, used for all static/aggregate/custom mixing.

Added Ext._buildCfg test cases for static/aggregate/custom support.

Also removed statics:true support.

See #2531567

Satyen Desai

YUI Developer

Posted: 02/7/12
  • completed changed from 0 to 1.5
  • remaining changed from 1.5 to 0.1
  • status changed from accepted to checkedin

Satyen Desai

YUI Developer

Posted: 02/7/12

Cleaned up Ext._buildCfg support. All buildCfg meta-data now merged
into a single shared hash, used for all static/aggregate/custom mixing.

Added Ext._buildCfg test cases for static/aggregate/custom support.

Also removed statics:true support.

See #2531567
View Commit: 52e73635546b2ee315b3d99cc7145a73ebc5b30e

Satyen Desai

YUI Developer

Posted: 02/7/12
  • remaining changed from 0.1 to 0

Added API and landing page docs. Removed references to the deprecated 'build', and replaced with 'create'/'mix'

Satyen Desai

YUI Developer

Posted: 02/13/12

Cleaned up Ext._buildCfg support. All buildCfg meta-data now merged
into a single shared hash, used for all static/aggregate/custom mixing.

Added Ext._buildCfg test cases for static/aggregate/custom support.

Also removed statics:true support.

See #2531567
View Commit: 52e73635546b2ee315b3d99cc7145a73ebc5b30e

Jenny Donnelly

YUI Developer

Posted: 05/10/12
  • resolution changed to fixed

checkedin -> closed

Jenny Donnelly

YUI Developer

Posted: 05/10/12
  • status changed from checkedin to closed

checkedin -> closed