Dart - Removing disallowed attribute - killing my dropdown buttons

42 Views Asked by At

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());
0

There are 0 best solutions below