Hi Didier,
the reason for this behavior is that some HTMLInputElements support
selection and some do not. The HTMLInputElements that support
selection have a couple of extra functions and attributes:
setSelectionRange, selectionStart and selectionEnd. To model this, we
have a subtype of HTMLInputElement called HTMLSelectionInputElement
which have these extra properties. Therefore, the constructor for the
input element in your example is not HTMLInputElement (it is
HTMLSelectionInputElement which you cannot access directly). However,
subtype checks using isPrototypeOf will give you the answer that you
need:
var input = document.createElement('input');
HTMLInputElement.prototype.isPrototypeOf(input); // true
Cheers, -- Mads
On Sat, Sep 13, 2008 at 7:58 AM, Didier DURAND <[EMAIL PROTECTED]> wrote:
>
> Hi there,
>
> I am adapting 1 of my javascript libraries to make it compatible with
> Chrome (working with FF & IE until now)
>
> In this library, I enforce strong type checking.
>
> I run into the following problem that you can easily reproduce through
> the 2 command lines (with $) below with the js debugger of chrome:
>
> $ print document.createElement('input').constructor
> function HTMLInputElement() { [native code] }
> $ print document.createElement('input').constructor ==
> HTMLInputElement
> false
>
> Why does the equality (==) not work?
> the constructor property should == the function that gets returned
> when checking it
> (it works for all other dom element constructors that I check
> otherwise)
>
> As an additional proof, you can run the following line in the debugger
> $ print HTMLInputElement == HTMLInputElement
> true
>
> Please, let me know if I am wrong or if there is a real problem
> regards
> didier
> >
>
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---