[gjs] Lang: fix copyProperties regression



commit 391aec6e82e0798659d96d1972f976354341689c
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Fri Jan 18 21:02:48 2013 +0100

    Lang: fix copyProperties regression
    
    We need to recurse through the prototype while fetching property
    descriptors.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=692025

 modules/lang.js |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/modules/lang.js b/modules/lang.js
index 9c8d45e..b88fe3c 100644
--- a/modules/lang.js
+++ b/modules/lang.js
@@ -31,9 +31,15 @@ function countProperties(obj) {
     return count;
 }
 
+function getPropertyDescriptor(obj, property) {
+    if (obj.hasOwnProperty(property))
+        return Object.getOwnPropertyDescriptor(obj, property);
+    return getPropertyDescriptor(Object.getPrototypeOf(obj), property);
+}
+
 function _copyProperty(source, dest, property) {
-    let desc = Object.getOwnPropertyDescriptor(source, property);
-    Object.defineProperty(dest, property, desc);
+    let descriptor = getPropertyDescriptor(source, property);
+    Object.defineProperty(dest, property, descriptor);
 }
 
 function copyProperties(source, dest) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]