Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Element innerHtml to Dart SDK 0.7.1

I am using dart-message https://github.com/mkozhukh/dart-message. It has function ...

MessageBox(String text, String header, String css){
    _box = new DivElement();
    ...
    _box.onClick.listen(_clickHandler);

    if (header != null)
      html.write("<div class='dhtmlx_popup_title'>$header</div>");
    html.write("<div class='dhtmlx_popup_text'><span>$text</span></div>");
    html.write("<div class='dhtmlx_popup_controls'>");
  }

String addButton(String text, String result){
    if (html != null){
      html.write("<div class='dhtmlx_popup_button' result='$result' ><div>$text</div></div>");
    } else
      throw new Exception(".addButton must be used before .show"); 
  }

 _clickHandler(Event event){
    String result = event.target.attributes["result"];
    if (result == null)
      result = event.target.parent.attributes["result"];
    hide(result); //<=== ERROR result alway return null
  }

And

Future<String> show(){
    if (html != null){
      //finalize html initialization
      html.write("</div>");
      _box.innerHtml = html.toString();  //<===== ERROR after line : Removing disallowed attribute <DIV result="ok">
      html = null;
    }
...
}

...

How to change this code to SDK 0.7.1. Thanks you very much.

like image 817
Tuan Hoang Anh Avatar asked Mar 22 '23 12:03

Tuan Hoang Anh


1 Answers

I changed code

_box.innerHtml = html.toString();

==>

_box.setInnerHtml(html.toString(), treeSanitizer : new NullTreeSanitizer());

and it work.

like image 62
Tuan Hoang Anh Avatar answered Apr 01 '23 04:04

Tuan Hoang Anh