Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #32185

Re: custom event in IE

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: custom event in IE
Date 2017-01-16 12:54 +0100
Organization PointedEars Software (PES)
Message-ID <7254284.T7Z3S40VBb@PointedEars.de> (permalink)
References (5 earlier) <1747068.usQuhbGJ8B@PointedEars.de> <o5eal0$4ib$1@dont-email.me> <9a709fc2-325b-4280-98b8-1c0d5cb790cd@googlegroups.com> <o5gvqr$cvm$1@dont-email.me> <3d25c9c9-8daf-4a66-a2e6-e5f517dbb32f@googlegroups.com>

Show all headers | View raw


Michael Haufe (TNO) wrote:

> Scott Sauyet wrote:
>> But my question was about more fundamental language issues.  Can we tell
>> at all [whether an object can be reasonably called as a constructor]?  I 
>> don't see a way, but was wondering if I'm missing something that might be
>> useful.
> 
> I *think* it *will* be possible by testing for the existence of one of the
> standard symbols.

How?

> The current browser support seems pretty flaky so I
> haven't discovered any useful results:
> 
> 
<https://github.com/lukehoban/es6features/blob/master/README.md#subclassable-built-ins>

While an interesting summary, I do not see anything relevant to this problem 
there.

> <http://www.ecma-international.org/ecma-262/7.0/#sec-well-known-symbols>

I see a relevant symbol to tell whether an object implements [[Construct]], 
but none that could tell if it makes sense to call it as a constructor. 
“Symbol.hasInstance” is not it (tested in Chromium 53¹):

| > ({})[Symbol.hasInstance]
| undefined
|
| > (function () {})[Symbol.hasInstance]
| [Symbol.hasInstance]() { [native code] }
|
| > var f = function () {};
| > delete f[Symbol.hasInstance];
| > f[Symbol.hasInstance]
| [Symbol.hasInstance]() { [native code] }

Also:

| > HTMLLIElement[Symbol.hasInstance]
| [Symbol.hasInstance]() { [native code] }

(it has to, for HTMLLIElement.prototype)

But:

| > new HTMLLIElement
| Uncaught TypeError: Illegal constructor(…)

See also

,-<http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype-@@hasinstance>
| 
| Function.prototype [ @@hasInstance ] ( V )#
| 
| When the @@hasInstance method of an object F is called with value V, the $
| following steps are taken:
| 
| 1. Let F be the this value.
| 2. Return ? OrdinaryHasInstance(F, V).
| 
| The value of the name property of this function is "[Symbol.hasInstance]".
| 
| This property has the attributes { [[Writable]]: false,
| [[Enumerable]]: false, [[Configurable]]: false }.
| 
| NOTE
| This is the default implementation of @@hasInstance that most functions 
| inherit. @@hasInstance is called by the instanceof operator to determine 
| whether a value is an instance of a specific constructor. An expression 
| such as
| 
|   v instanceof F
|           
| evaluates as
| 
|   F[@@hasInstance](v)
| 
| A constructor function can control which objects are recognized as its 
| instances by instanceof by exposing a different @@hasInstance method on 
| the function.

> This may be worth raising in es-discuss

Yes.

___________
¹  navigator.userAgent === "Mozilla/5.0 (X11; Linux x86_64) 
   AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143
   Safari/537.36"
-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

custom event in IE Andrew Poulos <ap_prog@hotmail.com> - 2017-01-10 12:08 +1100
  Re: custom event in IE Andrew Poulos <ap_prog@hotmail.com> - 2017-01-10 12:20 +1100
    Re: custom event in IE Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-10 02:45 +0100
      Re: custom event in IE Andrew Poulos <ap_prog@hotmail.com> - 2017-01-10 15:32 +1100
        Re: custom event in IE Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-10 12:53 +0100
          Re: custom event in IE Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-11 08:25 +0100
        Re: custom event in IE James Kirk <noneya.invalid@gmail.com> - 2017-01-10 21:52 -0500
          Re: custom event in IE Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-11 04:09 +0100
            Re: custom event in IE James Kirk <noneya.invalid@gmail.com> - 2017-01-11 21:31 -0500
              Re: custom event in IE Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-12 14:22 +0100
            Re: custom event in IE Scott Sauyet <scott@sauyet.com> - 2017-01-14 23:01 +0000
              Re: custom event in IE "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-15 09:51 -0800
                Re: custom event in IE Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-15 22:37 +0100
                Can we recognize Constructor Functions (was: custom event in IE) Scott Sauyet <scott@sauyet.com> - 2017-01-15 23:39 +0000
                Re: custom event in IE Scott Sauyet <scott@sauyet.com> - 2017-01-15 23:15 +0000
                Re: custom event in IE "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-15 22:36 -0800
                Re: custom event in IE Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-16 12:54 +0100
                Re: custom event in IE "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-01-16 14:18 -0800
                Re: custom event in IE Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-01-17 00:24 +0100

csiph-web