flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com>
Subject Re: [FlexJS] Extending builtin HTML elements
Date Thu, 07 Jan 2016 04:54:34 GMT
On 1/6/16, 6:35 PM, "Andy Dufilie" <andy.dufilie@gmail.com> wrote:

>button is null because document.createElement("button") is not an instance
>of MyButton.

Andy is right.  We have not tried to extend the type system into the
built-in classes.  Not sure we could guarantee that would work.  More

>Is this supposed to work?
>package {
>public class MyButton extends HTMLButtonElement {
>public function MyButton() {
>this.addEventListener("click", button_clickListener, false);
>private function button_clickListener(event : MouseEvent) : void {
>alert("Hello World");
>package {
>public class WebProject1 {

Add the following as the ASDoc for the WebProject1() method, then it
should work:

 * @flexjsignorecoercion MyButton
>public function WebProject1() {
>var button : MyButton = document.createElement("button") as MyButton;
>button.innerHTML = "Press Me";

I've pondered other ways to tell the compiler to not actually generate the
type-checking code since it doesn't actually get used at runtime by the
runtime.  Lots of options here:

1) Extend the type system by adding FLEXJS_CLASS_INFO to existing classes
2) Use @flexjsignorecoercion
3) Automatically suppress type-checking code for all external definitions
4) Compiler options to suppress type-checking


View raw message