allowCustomElement method

void allowCustomElement(
  1. String tagName, {
  2. UriPolicy? uriPolicy,
  3. Iterable<String>? attributes,
  4. Iterable<String>? uriAttributes,
})

Allow custom elements with the specified tag name and specified attributes.

This will allow the elements as custom tags (such as ), but will not allow tag extensions. Use allowTagExtension to allow tag extensions.

Implementation

// ignore: unintended_html_in_doc_comment
/// This will allow the elements as custom tags (such as <x-foo></x-foo>),
/// but will not allow tag extensions. Use [allowTagExtension] to allow
/// tag extensions.
void allowCustomElement(
  String tagName, {
  UriPolicy? uriPolicy,
  Iterable<String>? attributes,
  Iterable<String>? uriAttributes,
}) {
  var tagNameUpper = tagName.toUpperCase();
  var attrs = attributes?.map<String>(
        (name) => '$tagNameUpper::${name.toLowerCase()}',
      ) ??
      const [];
  var uriAttrs = uriAttributes?.map<String>(
        (name) => '$tagNameUpper::${name.toLowerCase()}',
      ) ??
      const [];
  uriPolicy ??= UriPolicy();

  add(
    _CustomElementNodeValidator(
      uriPolicy,
      [tagNameUpper],
      attrs,
      uriAttrs,
      false,
      true,
    ),
  );
}