Skip to content

Instantly share code, notes, and snippets.

@kasperpeulen
Created August 5, 2015 21:22
Show Gist options
  • Select an option

  • Save kasperpeulen/0a102e2ed79af7b419f2 to your computer and use it in GitHub Desktop.

Select an option

Save kasperpeulen/0a102e2ed79af7b419f2 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<!--material design lite-->
<link rel="stylesheet" href="https://storage.googleapis.com/code.getmdl.io/1.0.0/material.indigo-indigo.min.css">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<script type="application/dart" src="main.dart"></script>
</body>
</html>
import 'dart:html';
main() {
// href tag will be removed without nodevalidator
DivElement defaultValidator = new DivElement()
..setInnerHtml('Go to <a href="http://www.google.com">www.google.com</a>');
// nothing will be removed with the TrustedNodeValidator
DivElement trustedValidator = new DivElement()
..setInnerHtml('Go to <a href="http://www.google.com">www.google.com</a>',
validator: new TrustedNodeValidator());
document.body
..append(trustedValidator)
..append(defaultValidator);
}
/// A [NodeValidator] which allows everything.
class TrustedNodeValidator implements NodeValidator {
bool allowsElement(Element element) => true;
bool allowsAttribute(element, attributeName, value) => true;
}
body {
margin: 10px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment