Skip to content

Commit

Permalink
Merge pull request #1812 from opal/elia/runtime-loaded-fix
Browse files Browse the repository at this point in the history
Opal.loaded was stopping after a known file
  • Loading branch information
elia committed Apr 30, 2018
2 parents 2c95900 + accdabf commit f11374d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion opal/corelib/runtime.js
Expand Up @@ -2226,7 +2226,7 @@
path = Opal.normalize(paths[i]);

if (Opal.require_table[path]) {
return;
continue;
}

Opal.loaded_features.push(path);
Expand Down
21 changes: 21 additions & 0 deletions spec/opal/javascript_api_spec.rb
Expand Up @@ -57,4 +57,25 @@ def preserve_original_exit_handler
end
end
end

describe 'Opal.loaded' do
before do
%w[foo bar baz].each do |module_name|
`delete Opal.require_table[#{module_name}]`
`Opal.loaded_features.splice(Opal.loaded_features.indexOf(#{module_name}))`
end
end

it 'it works with multiple paths' do
`Opal.loaded(['bar'])`
`(Opal.require_table.foo == null)`.should == true
`(Opal.require_table.bar === true)`.should == true
`(Opal.require_table.baz == null)`.should == true

`Opal.loaded(['foo', 'bar', 'baz'])`
`(Opal.require_table.foo === true)`.should == true
`(Opal.require_table.bar === true)`.should == true
`(Opal.require_table.baz === true)`.should == true
end
end
end

0 comments on commit f11374d

Please sign in to comment.