Chromium Code Reviews| Index: src/apinatives.js |
| diff --git a/src/apinatives.js b/src/apinatives.js |
| index 9bb52e2b7a007c5cf21ba4f7ce23d8c81aa569e6..03b2926a2e11694b1320f3e900463c387656e68b 100644 |
| --- a/src/apinatives.js |
| +++ b/src/apinatives.js |
| @@ -30,9 +30,15 @@ function Instantiate(data, name) { |
| var Constructor = %GetTemplateField(data, kApiConstructorOffset); |
| // Note: Do not directly use a function template as a condition, our |
| // internal ToBoolean doesn't handle that! |
| - var result = typeof Constructor === 'undefined' ? |
| - {} : new (Instantiate(Constructor))(); |
| - ConfigureTemplateInstance(result, data); |
| + var result; |
| + if (typeof Constructor === 'undefined') { |
| + result = {}; |
| + ConfigureTemplateInstance(result, data); |
| + } else { |
| + // ConfigureTemplateInstance is implicitly called before calling the API |
| + // constructor in HandleApiCall. |
| + result = new (Instantiate(Constructor))(); |
| + } |
| result = %ToFastProperties(result); |
|
rossberg
2014/06/27 09:47:30
Is this actually needed in the then case?
Toon Verwaest
2014/06/27 13:16:22
I guess it's unlikely to get normalized. Moved up.
|
| return result; |
| default: |
| @@ -93,7 +99,7 @@ function ConfigureTemplateInstance(obj, data) { |
| var prop_data = properties[i + 2]; |
| var attributes = properties[i + 3]; |
| var value = Instantiate(prop_data, name); |
| - %SetProperty(obj, name, value, attributes); |
| + %DefineProperty(obj, name, value, attributes); |
| } else if (length == 4 || length == 5) { |
| // TODO(verwaest): The 5th value used to be access_control. Remove once |
| // the bindings are updated. |
| @@ -101,7 +107,7 @@ function ConfigureTemplateInstance(obj, data) { |
| var getter = properties[i + 2]; |
| var setter = properties[i + 3]; |
| var attribute = properties[i + 4]; |
| - %SetAccessorProperty(obj, name, getter, setter, attribute); |
| + %DefineAccessorProperty(obj, name, getter, setter, attribute); |
| } else { |
| throw "Bad properties array"; |
| } |