Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 880977e343db
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8ba881b43737
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 25, 2013

  1. Cleanup Module#include

    meh committed Nov 25, 2013
    Copy the full SHA
    be81630 View commit details
  2. Fix Kernel#extend

    meh committed Nov 25, 2013
    Copy the full SHA
    8ba881b View commit details
Showing with 19 additions and 13 deletions.
  1. +9 −4 opal/corelib/kernel.rb
  2. +10 −9 opal/corelib/module.rb
13 changes: 9 additions & 4 deletions opal/corelib/kernel.rb
Original file line number Diff line number Diff line change
@@ -147,12 +147,17 @@ def equal?(other)

def extend(*mods)
%x{
for (var i = 0, length = mods.length; i < length; i++) {
#{ self.singleton_class.include `mods[i]` };
}
var singleton = #{singleton_class};
return self;
for (var i = mods.length - 1; i >= 0; i--) {
var mod = mods[i];
#{`mod`.append_features `singleton`};
#{`mod`.extended self};
}
}

self
end

def format(format, *args)
19 changes: 10 additions & 9 deletions opal/corelib/module.rb
Original file line number Diff line number Diff line change
@@ -295,21 +295,19 @@ def remove_method(name)

def include(*mods)
%x{
var i = mods.length - 1, mod;
while (i >= 0) {
mod = mods[i];
i--;
for (var i = mods.length - 1; i >= 0; i--) {
var mod = mods[i];
if (mod === #{self}) {
if (mod === self) {
continue;
}
#{ `mod`.append_features self };
#{ `mod`.included self };
#{`mod`.append_features self};
#{`mod`.included self};
}
return #{self};
}

self
end

def instance_method(name)
@@ -349,6 +347,9 @@ def instance_methods(include_super = false)
def included(mod)
end

def extended(mod)
end

def module_eval(&block)
%x{
if (block === nil) {