Skip to content

Commit

Permalink
Merge pull request #3 from Rich-Harris/trusktr/buble-master
Browse files Browse the repository at this point in the history
Make class accessors (static or not) configurable, like spec.
  • Loading branch information
Rich-Harris authored Sep 23, 2017
2 parents eeb40c8 + 9cb532b commit 59ddefc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/program/types/ClassBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ export default class ClassBody extends Node {
let outro = [];

if ( prototypeGettersAndSetters.length ) {
intro.push( `var ${prototypeAccessors} = { ${prototypeGettersAndSetters.map( name => `${name}: {}` ).join( ',' )} };` );
intro.push( `var ${prototypeAccessors} = { ${prototypeGettersAndSetters.map( name => `${name}: { configurable: true }` ).join( ',' )} };` );
outro.push( `Object.defineProperties( ${name}.prototype, ${prototypeAccessors} );` );
}

if ( staticGettersAndSetters.length ) {
intro.push( `var ${staticAccessors} = { ${staticGettersAndSetters.map( name => `${name}: {}` ).join( ',' )} };` );
intro.push( `var ${staticAccessors} = { ${staticGettersAndSetters.map( name => `${name}: { configurable: true }` ).join( ',' )} };` );
outro.push( `Object.defineProperties( ${name}, ${staticAccessors} );` );
}

Expand Down
10 changes: 5 additions & 5 deletions test/samples/classes-no-named-function-expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,8 @@ module.exports = [
this.radius = radius;
};
var prototypeAccessors = { area: {} };
var staticAccessors = { description: {} };
var prototypeAccessors = { area: { configurable: true } };
var staticAccessors = { description: { configurable: true } };
prototypeAccessors.area.get = function () {
return Math.PI * Math.pow( this.radius, 2 );
Expand Down Expand Up @@ -516,8 +516,8 @@ module.exports = [
Circle.prototype = Object.create( Shape && Shape.prototype );
Circle.prototype.constructor = Circle;
var prototypeAccessors = { area: {} };
var staticAccessors = { description: {} };
var prototypeAccessors = { area: { configurable: true } };
var staticAccessors = { description: { configurable: true } };
prototypeAccessors.area.get = function () {
return Math.PI * Math.pow( this.radius, 2 );
Expand Down Expand Up @@ -828,7 +828,7 @@ module.exports = [
output: `
var Foo = function () {};
var staticAccessors = { bar: {} };
var staticAccessors = { bar: { configurable: true } };
staticAccessors.bar.get = function () { return 'baz' };
Expand Down
10 changes: 5 additions & 5 deletions test/samples/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ module.exports = [
this.radius = radius;
};
var prototypeAccessors = { area: {} };
var staticAccessors = { description: {} };
var prototypeAccessors = { area: { configurable: true } };
var staticAccessors = { description: { configurable: true } };
prototypeAccessors.area.get = function () {
return Math.PI * Math.pow( this.radius, 2 );
Expand Down Expand Up @@ -500,8 +500,8 @@ module.exports = [
Circle.prototype = Object.create( Shape && Shape.prototype );
Circle.prototype.constructor = Circle;
var prototypeAccessors = { area: {} };
var staticAccessors = { description: {} };
var prototypeAccessors = { area: { configurable: true } };
var staticAccessors = { description: { configurable: true } };
prototypeAccessors.area.get = function () {
return Math.PI * Math.pow( this.radius, 2 );
Expand Down Expand Up @@ -803,7 +803,7 @@ module.exports = [
output: `
var Foo = function Foo () {};
var staticAccessors = { bar: {} };
var staticAccessors = { bar: { configurable: true } };
staticAccessors.bar.get = function () { return 'baz' };
Expand Down

0 comments on commit 59ddefc

Please sign in to comment.