2

Any idea what this is?

enter image description here

After upgrading Dart to 1.11.1, I get these when loading HTML via Dart

void loadHtml(String component, String div, function) {

    // get today's date to be used for cache busting
    DateTime today = new DateTime.now();
    String cachebuster = today.year.toString() + today.month.toString() + today.day.toString() + today.hour.toString();

    // load html into page
    HttpRequest.getString("html/" + component + ".html?" + cachebuster).then((html) {
        querySelector(div).children.clear();
        querySelector(div).appendHtml(html);

        function();
    }).catchError((exception) {
        showErrorMessage("Error Loading HTML: " + exception.toString());
    }).whenComplete(() {
        // wire calendar elements
        for (Element elem in $('[class~="calendar"]')) {
            Calendar.wire(elem);
        }

    });

}

This split button works 100% when I put it onto my index.html, it used to work if it was in an html file which I loaded with the above code.

<div class="btn-group">
    <button type="button" class="btn btn-danger">Action</button>
    <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
            aria-expanded="false">
        <span class="caret"></span>
        <span class="sr-only">Toggle Dropdown</span>
    </button>
    <ul class="dropdown-menu">
        <li><a href="#">Action</a></li>
        <li><a href="#">Another action</a></li>
        <li><a href="#">Something else here</a></li>
        <li role="separator" class="divider"></li>
        <li><a href="#">Separated link</a></li>
    </ul>
</div>

Now it seems certain attributes are being stripped out which I require to make my bootstrap elements work.

Any idea on how to fix this?

Update: Thanks Gunter, it was indeed the sanitizer killing my tags. This fixed it for me:

class MySanitizer implements NodeTreeSanitizer {
    void sanitizeTree(Node node) {}
}

...

querySelector(div).appendHtml(html, treeSanitizer: new MySanitizer());
Jan Vladimir Mostert
  • 12,380
  • 15
  • 80
  • 137
  • @Günter, I don't think this should be closed, If we keep it as `Marked as Duplicate`, that's fine. It's kind of difficult to find what you're looking for if you weren't aware of the sanitiser now sitting in appendHtml as well. – Jan Vladimir Mostert Jul 19 '15 at 08:08
  • This question stays visible and is listed in search results. I think this is what you asked for. – Günter Zöchbauer Jul 19 '15 at 08:35
  • 1
    Perfect! This should save somebody else from freaking out - pushed this into production last night only realising at 1am that the all the button dropdowns are completely broken without knowing which commit over the last two weeks could be breaking it, what change has caused the problem, did dart 1.11.1 break it, did the latest html library break it, did bootjack break it, did dquery break it, etc. Relieved that it's a simple fix. – Jan Vladimir Mostert Jul 19 '15 at 09:55
  • 1
    It was supposed to work this way from the beginning, but there was an oversight that `appenedHtml()` didn't sanitize like the other methods that allowed to add HTML. This was fixed recently in dart:html. – Günter Zöchbauer Jul 19 '15 at 09:59

0 Answers0