Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: tools/dom/src/NodeValidatorBuilder.dart

Issue 23793004: Adding an easy way to allow inline style attributes through sanitization (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/node_validator_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/NodeValidatorBuilder.dart
diff --git a/tools/dom/src/NodeValidatorBuilder.dart b/tools/dom/src/NodeValidatorBuilder.dart
index c5f0c80542a90835393044215c1d36965ea7bdbf..41cab67cf9b140830fe4f3f189ecf9f6af5b1e85 100644
--- a/tools/dom/src/NodeValidatorBuilder.dart
+++ b/tools/dom/src/NodeValidatorBuilder.dart
@@ -110,6 +110,21 @@ class NodeValidatorBuilder implements NodeValidator {
}
/**
+ * Allow inline styles on elements.
+ *
+ * If [tagName] is not specified then this allows inline styles on all
+ * elements. Otherwise tagName limits the styles to the specified elements.
+ */
+ void allowInlineStyles({String tagName}) {
+ if (tagName == null) {
+ tagName = '*';
+ } else {
+ tagName = tagName.toUpperCase();
+ }
+ add(new _SimpleNodeValidator(null, allowedAttributes: ['$tagName::style']));
+ }
+
+ /**
* Allow common safe HTML5 elements and attributes.
*
* This list is based off of the Caja whitelists at:
« no previous file with comments | « tests/html/node_validator_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698