mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-02-19 03:44:23 -05:00
stopped using __proto__, instead, using a variant of goog.inherits for extends and super()
This commit is contained in:
@@ -211,11 +211,12 @@ module CoffeeScript
|
||||
def compile_super(args, o)
|
||||
methname = o[:last_assign].sub(LEADING_DOT, '')
|
||||
arg_part = args.empty? ? '' : ", #{args}"
|
||||
"#{o[:proto_assign]}.prototype.__proto__.#{methname}.call(this#{arg_part})"
|
||||
"#{o[:proto_assign]}.__superClass__.#{methname}.call(this#{arg_part})"
|
||||
end
|
||||
end
|
||||
|
||||
# Node to extend an object's prototype with an ancestor object.
|
||||
# After goog.inherits from the Closure Library.
|
||||
class ExtendsNode < Node
|
||||
attr_reader :sub_object, :super_object
|
||||
|
||||
@@ -224,7 +225,10 @@ module CoffeeScript
|
||||
end
|
||||
|
||||
def compile(o={})
|
||||
"#{@sub_object.compile(o)}.prototype.__proto__ = #{@super_object.compile(o)}"
|
||||
sub, sup = @sub_object.compile(o), @super_object.compile(o)
|
||||
"#{sub}.__superClass__ = #{sup}.prototype;\n#{o[:indent]}" +
|
||||
"#{sub}.prototype = new #{sup}();\n#{o[:indent]}" +
|
||||
"#{sub}.prototype.constructor = #{sub}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user