Comparing version 0.3.3 to 0.3.4
# buble changelog | ||
## 0.3.4 | ||
* Class inheritance | ||
## 0.3.3 | ||
@@ -4,0 +8,0 @@ |
@@ -161,4 +161,7 @@ import { parse } from 'acorn'; | ||
const name = this.id.name; | ||
const superName = this.superClass && this.superClass.name; | ||
if ( this.superClass ) { | ||
magicString.overwrite( this.start, this.start + 5, `var ${this.id.name} = (function (${this.superClass.name}) {\n${indentation + indentStr}function` ); | ||
magicString.overwrite( this.start, this.start + 5, `var ${name} = (function (${superName}) {\n${indentation + indentStr}function` ); | ||
magicString.remove( this.id.end, this.superClass.end ); | ||
@@ -170,8 +173,11 @@ | ||
} else { | ||
magicString.insert( this.body.start, `() {\n${indentation + indentStr + indentStr}${this.superClass.name}.call(this);\n${indentation + indentStr}}\n\n${indentation + indentStr}` ); | ||
magicString.insert( this.body.start, `() {\n${indentation + indentStr + indentStr}${superName}.apply(this, arguments);\n${indentation + indentStr}}` ); | ||
} | ||
magicString.insert( this.body.start, `\n\n${indentation + indentStr}${name}.prototype = Object.create( ${superName} && ${superName}.prototype );\n${indentation + indentStr}${name}.prototype.constructor = ${name};` ); | ||
if ( !this.constructor ) magicString.insert( this.body.start, `\n\n${indentation + indentStr}` ); | ||
} else { | ||
deindent( this.body, magicString ); | ||
magicString.overwrite( this.start, this.start + 5, `var ${this.id.name} = function` ); | ||
magicString.overwrite( this.start, this.start + 5, `var ${name} = function` ); | ||
@@ -199,4 +205,4 @@ if ( this.constructor ) { | ||
const lhs = method.static ? | ||
`${this.id.name}.${method.key.name}` : | ||
`${this.id.name}.prototype.${method.key.name}`; | ||
`${name}.${method.key.name}` : | ||
`${name}.prototype.${method.key.name}`; | ||
@@ -210,3 +216,3 @@ magicString.insert( method.start, `${lhs} = function ` ); | ||
if ( this.superClass ) { | ||
magicString.insert( this.end, `\n\n${indentation + indentStr}return ${this.id.name};\n${indentation}}(${this.superClass.name}));` ); | ||
magicString.insert( this.end, `\n\n${indentation + indentStr}return ${name};\n${indentation}}(${superName}));` ); | ||
} | ||
@@ -213,0 +219,0 @@ |
@@ -165,4 +165,7 @@ (function (global, factory) { | ||
const name = this.id.name; | ||
const superName = this.superClass && this.superClass.name; | ||
if ( this.superClass ) { | ||
magicString.overwrite( this.start, this.start + 5, `var ${this.id.name} = (function (${this.superClass.name}) {\n${indentation + indentStr}function` ); | ||
magicString.overwrite( this.start, this.start + 5, `var ${name} = (function (${superName}) {\n${indentation + indentStr}function` ); | ||
magicString.remove( this.id.end, this.superClass.end ); | ||
@@ -174,8 +177,11 @@ | ||
} else { | ||
magicString.insert( this.body.start, `() {\n${indentation + indentStr + indentStr}${this.superClass.name}.call(this);\n${indentation + indentStr}}\n\n${indentation + indentStr}` ); | ||
magicString.insert( this.body.start, `() {\n${indentation + indentStr + indentStr}${superName}.apply(this, arguments);\n${indentation + indentStr}}` ); | ||
} | ||
magicString.insert( this.body.start, `\n\n${indentation + indentStr}${name}.prototype = Object.create( ${superName} && ${superName}.prototype );\n${indentation + indentStr}${name}.prototype.constructor = ${name};` ); | ||
if ( !this.constructor ) magicString.insert( this.body.start, `\n\n${indentation + indentStr}` ); | ||
} else { | ||
deindent( this.body, magicString ); | ||
magicString.overwrite( this.start, this.start + 5, `var ${this.id.name} = function` ); | ||
magicString.overwrite( this.start, this.start + 5, `var ${name} = function` ); | ||
@@ -203,4 +209,4 @@ if ( this.constructor ) { | ||
const lhs = method.static ? | ||
`${this.id.name}.${method.key.name}` : | ||
`${this.id.name}.prototype.${method.key.name}`; | ||
`${name}.${method.key.name}` : | ||
`${name}.prototype.${method.key.name}`; | ||
@@ -214,3 +220,3 @@ magicString.insert( method.start, `${lhs} = function ` ); | ||
if ( this.superClass ) { | ||
magicString.insert( this.end, `\n\n${indentation + indentStr}return ${this.id.name};\n${indentation}}(${this.superClass.name}));` ); | ||
magicString.insert( this.end, `\n\n${indentation + indentStr}return ${name};\n${indentation}}(${superName}));` ); | ||
} | ||
@@ -217,0 +223,0 @@ |
{ | ||
"name": "buble", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Common sense JavaScript transpilation", | ||
@@ -5,0 +5,0 @@ "main": "dist/buble.umd.js", |
@@ -20,4 +20,7 @@ import Node from '../Node.js'; | ||
const name = this.id.name; | ||
const superName = this.superClass && this.superClass.name; | ||
if ( this.superClass ) { | ||
magicString.overwrite( this.start, this.start + 5, `var ${this.id.name} = (function (${this.superClass.name}) {\n${indentation + indentStr}function` ); | ||
magicString.overwrite( this.start, this.start + 5, `var ${name} = (function (${superName}) {\n${indentation + indentStr}function` ); | ||
magicString.remove( this.id.end, this.superClass.end ); | ||
@@ -29,8 +32,11 @@ | ||
} else { | ||
magicString.insert( this.body.start, `() {\n${indentation + indentStr + indentStr}${this.superClass.name}.call(this);\n${indentation + indentStr}}\n\n${indentation + indentStr}` ); | ||
magicString.insert( this.body.start, `() {\n${indentation + indentStr + indentStr}${superName}.apply(this, arguments);\n${indentation + indentStr}}` ); | ||
} | ||
magicString.insert( this.body.start, `\n\n${indentation + indentStr}${name}.prototype = Object.create( ${superName} && ${superName}.prototype );\n${indentation + indentStr}${name}.prototype.constructor = ${name};` ); | ||
if ( !this.constructor ) magicString.insert( this.body.start, `\n\n${indentation + indentStr}` ); | ||
} else { | ||
deindent( this.body, magicString ); | ||
magicString.overwrite( this.start, this.start + 5, `var ${this.id.name} = function` ); | ||
magicString.overwrite( this.start, this.start + 5, `var ${name} = function` ); | ||
@@ -58,4 +64,4 @@ if ( this.constructor ) { | ||
const lhs = method.static ? | ||
`${this.id.name}.${method.key.name}` : | ||
`${this.id.name}.prototype.${method.key.name}`; | ||
`${name}.${method.key.name}` : | ||
`${name}.prototype.${method.key.name}`; | ||
@@ -69,3 +75,3 @@ magicString.insert( method.start, `${lhs} = function ` ); | ||
if ( this.superClass ) { | ||
magicString.insert( this.end, `\n\n${indentation + indentStr}return ${this.id.name};\n${indentation}}(${this.superClass.name}));` ); | ||
magicString.insert( this.end, `\n\n${indentation + indentStr}return ${name};\n${indentation}}(${superName}));` ); | ||
} | ||
@@ -72,0 +78,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
221566
2259