Skip to content

Commit b88a94a

Browse files
committedFeb 25, 2015
Fix Opal.alias_native
…after has been cleaned up by @meh ;)
1 parent d0aaf2f commit b88a94a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed
 

‎opal/corelib/runtime.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1174,12 +1174,12 @@
11741174
return obj;
11751175
};
11761176

1177-
Opal.alias_native = function(obj, name, old) {
1177+
Opal.alias_native = function(obj, name, native_name) {
11781178
var id = '$' + name,
1179-
body = obj.$$proto['$' + old];
1179+
body = obj.$$proto[native_name];
11801180

11811181
if (typeof(body) !== "function" || body.$$stub) {
1182-
throw Opal.NameError.$new("undefined method `" + old + "' for class `" + obj.$name() + "'")
1182+
throw Opal.NameError.$new("undefined native method `" + native_name + "' for class `" + obj.$name() + "'")
11831183
}
11841184

11851185
Opal.defn(obj, id, wrap(body));

‎spec/opal/stdlib/native/alias_native_spec.rb

+9
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,12 @@
2525
}.new(`{ a: 42 }`).a.should == 42
2626
end
2727
end
28+
29+
describe 'Module#alias_native' do
30+
it 'exposes a native method' do
31+
klass = Class.new
32+
`klass.$$proto.a = function() { return 123 }`
33+
klass.alias_native :a, :a
34+
klass.new.a.should == 123
35+
end
36+
end

2 commit comments

Comments
 (2)

meh commented on Feb 25, 2015

@meh
Member

Yeah, I was backporting fixes/cleanups from proper-bridging to keep myself sane, some changes broke themselves and didn't fail.

elia commented on Feb 25, 2015

@elia
MemberAuthor

No worries, was just for fun :)

Please sign in to comment.