commit | 1cf5dbf4228dd0b9f7569b0f6bad45b2ef730868 | [log] [tgz] |
---|---|---|
author | utatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Tue Aug 11 18:18:39 2015 +0000 |
committer | utatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Tue Aug 11 18:18:39 2015 +0000 |
tree | 992085ed341eebe1282502b1ea884ed29d2903a2 | |
parent | 6f1797765466517aaccec4d978da09068e47028d [diff] [blame] |
[ES6] Implement Reflect.has https://bugs.webkit.org/show_bug.cgi?id=147875 Reviewed by Sam Weinig. This patch implements Reflect.has[1]. Since the semantics is the same to the `in` operator in the JS[2], we can implement it in builtin JS code. [1]: http://www.ecma-international.org/ecma-262/6.0/#sec-reflect.has [2]: http://www.ecma-international.org/ecma-262/6.0/#sec-relational-operators-runtime-semantics-evaluation * builtins/ReflectObject.js: (has): * runtime/ReflectObject.cpp: * tests/stress/reflect-has.js: Added. (shouldBe): (shouldThrow): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@188264 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/builtins/ReflectObject.js b/Source/JavaScriptCore/builtins/ReflectObject.js index 166af07..804c1e6 100644 --- a/Source/JavaScriptCore/builtins/ReflectObject.js +++ b/Source/JavaScriptCore/builtins/ReflectObject.js
@@ -47,3 +47,12 @@ return delete target[propertyKey]; } +function has(target, propertyKey) +{ + "use strict"; + + if (!@isObject(target)) + throw new @TypeError("Reflect.has requires the first argument be an object"); + + return propertyKey in target; +}