firefoxfirefox-osb2g

Things that defined by WebIDL


After reading this post, http://mcc.id.au/2013/lca-webidl/

I have some questions in the page 20,

  1. What happens when you pass too many/few arguments.

  2. What happens when you grab a Function corresponding to an IDL operation and apply it to some other type of object.

  3. How interface inheritance corresponds to a prototype chain.

  4. How DOM objects are stringified.

Can anyone give a specific explanation or example to these points.

Thanks


Solution

    1. If you pass too many arguments the extra ones are ignored. Try document.getElementsByTagName("a", "b"). If you pass too few, you get an exception: document.getElementsByTagName().
    2. If you apply a WebIDL operation to the wrong type of object, you get an exception. See http://heycam.github.io/webidl/#es-operations step 4 under "Try running the following steps". document.getElementsByTagName.call(document.body, "div") for example.
    3. Interface inheritance corresponds to a prototype chain as described at http://heycam.github.io/webidl/#interface-prototype-object but in brief if you have interface Foo : Bar { }; then Object.getPrototypeOf(Foo.prototype) === Bar.prototype. So for example, the prototype of HTMLElement.prototype is Element.prototype.
    4. DOM objects with a stringifier defined (e.g. HTMLAnchorElement) are stringified however the relevant specification defines them to be. All other objects become "[object MostDerivedInterfaceName]".