mirror of
https://github.com/rubyjs/therubyrhino
synced 2023-03-27 23:21:34 -04:00
"int" property resolution for JS objects
This commit is contained in:
parent
d3d6928a46
commit
69b239cbf9
1 changed files with 10 additions and 1 deletions
|
@ -100,7 +100,16 @@ class Java::OrgMozillaJavascript::NativeObject
|
|||
|
||||
import "org.mozilla.javascript"
|
||||
|
||||
# re-implement Map#put
|
||||
def [](name)
|
||||
value = Rhino.to_ruby(ScriptableObject.getProperty(self, s_name = name.to_s))
|
||||
# handle { '5': 5 }.keys() ... [ 5 ] not [ '5' ] !
|
||||
if value.nil? && (i_name = s_name.to_i) != 0
|
||||
value = Rhino.to_ruby(ScriptableObject.getProperty(self, i_name))
|
||||
end
|
||||
value
|
||||
end
|
||||
|
||||
# re-implement unsupported Map#put
|
||||
def []=(key, value)
|
||||
scope = self
|
||||
ScriptableObject.putProperty(self, key.to_s, Rhino.to_javascript(value, scope))
|
||||
|
|
Loading…
Reference in a new issue