Closed
Bug 869983
Opened 11 years ago
Closed 11 years ago
Class does not seem to work as advertised in the documentation (for FX 20, 21)
Categories
(Add-on SDK Graveyard :: Documentation, defect)
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: mgoodwin, Assigned: zer0)
Details
I'm trying to use heritage.Class as documented here: https://addons.mozilla.org/en-US/developers/docs/sdk/1.14/modules/sdk/core/heritage.html My code is here: https://github.com/mozmark/Mitm-Tool/blob/2ff482224c8043d5b06ca7a4bde5cee6147a5b75/lib/config.js#L101 On FX 20 and 21, the properties set via ConfigManager.prototype (e.g. https://github.com/mozmark/Mitm-Tool/blob/2ff482224c8043d5b06ca7a4bde5cee6147a5b75/lib/config.js#L116 ) are undefined when I attempt to use them.
Assignee | ||
Updated•11 years ago
|
Component: General → Documentation
Assignee | ||
Comment 1•11 years ago
|
||
So, the issue here is that in Add-on SDK 1.14, `Class` returns a non extensible constructor, with a non extensible `prototype`. It means that this is working:
var { Class } = require('sdk/core/heritage');
var Dog = Class({
initialize: function initialize(name) {
this.name = name;
},
type: 'dog',
bark: function bark() {
return 'Ruff! Ruff!'
}
});
But this is not:
var { Class } = require('sdk/core/heritage');
var Dog = Class({
initialize: function initialize(name) {
this.name = name;
}
});
Dog.prototype.type = 'dog';
Dog.prototype.bark = function bark() {
return 'Ruff! Ruff!'
};
And if the add-on dev is not using "use strict", no exceptions are raised, it will silently fails – properties not added to the prototype.
Probably the misleading part in the documentation was:
> Please note that Class is just an utility function which we use in SDK, and
> recommend our users to use it, but it's in no way enforced. As a matter of fact
> since result is just a plain constructor function with proper prototype chain
> setup
However notice that after 1.14, `Class` returns an extensible constructor and prototype, so also extends the prototype works without issues.
Will, I don't think we need to updated the 1.14 documentation, but what do you think?
Flags: needinfo?(wbamberg)
Comment 2•11 years ago
|
||
Will, ping?
Comment 3•11 years ago
|
||
I don't think it's worth revving the 1.14 documentation for this.
Flags: needinfo?(wbamberg)
Assignee | ||
Comment 4•11 years ago
|
||
In that case I will set it as "WONTFIX", because the issue is related only for 1.14 documentation.
Assignee | ||
Updated•11 years ago
|
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•