https://bugzilla.wikimedia.org/show_bug.cgi?id=48048

       Web browser: ---
            Bug ID: 48048
           Summary: Util.clone doesn't deep-clone KV objects
           Product: Parsoid
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: General
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified
   Mobile Platform: ---

Digging into why I couldn't get Util.clone([new KV("a","b")]) to actually
return a new KV object, I found that the implementation of $.extend explicitly
avoids deep copying any object which was built with a constructor (ie, an
object o in which o.__proto__ !== Object.prototype).  The quirks of how we
invoke $.extend in Util.clone mean that we get a clone of KV if we invoke
Util.clone(kv) directly, but not if KV is embedded in another object or array.

Is this problem well-known?  It seems like we should probably just replace
Util.clone with a direct implementation which recurses into objects with
prototypes.  That's a bit dangerous as well, since we're not actually copying
the prototype and its methods.  Perhaps we should have a whitelist of object
types we allow in our Util.clone() implementation, and assert() if some other
object type is encountered?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to