W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2014

Re: Determining what prototype should be used for an object

From: Boris Zbarsky <bzbarsky@mit.edu>
Date: Fri, 14 Nov 2014 12:41:09 -0500
Message-ID: <54663EB5.5060009@mit.edu>
To: Domenic Denicola <d@domenic.me>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On 11/14/14, 6:31 AM, Domenic Denicola wrote:
> Just to sharpen the discussion, it would help to give one example of each...


Consider this testcase:

   function isFromGlobal(obj, global) {
     return obj instanceof global.Object;
   function w(str) { document.querySelector("pre").textContent += str + 
"\n"; }

   onload = function() {
     var l = 
Document.prototype.querySelectorAll.call(frames[0].document, "x");
     w(isFromGlobal(l, frames[0]));
     w(isFromGlobal(l, window));
     var arr = Array.prototype.slice.call(new frames[0].Array);
     w(isFromGlobal(arr, frames[0]));
     w(isFromGlobal(arr, window));

The output in Firefox, Chrome, and Safari (didn't test IE, but could if 
needed) is:


Received on Friday, 14 November 2014 17:41:38 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:23 UTC