# Code coverage report for lib/components/unsafe.js

## Statements: 79.17% (19 / 24) Branches: 81.25% (13 / 16) Functions: 100% (2 / 2) Lines: 79.17% (19 / 24) Ignored: none

All files » lib/components/ » unsafe.js

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    631

    1
    7

    1

    66

    66

    66
    25

    66

    66
    5

    61

    61
    29
    29
    32

    32
    32

    61

     var BaseComponent  = require("./base");

    /**
     */

    function EscapeComponent(options) {
      BaseComponent.call(this, options);
    }

    /**
     */

    module.exports = BaseComponent.extend(EscapeComponent, {

      /**
       */

      update: function() {

        var value = this.attributes.html;

        // dirty check if is a binding
        Iif (typeof value === "object" && value.evaluate) {
          value = void 0;
        }

        // has a remove script
        if (this.currentValue && this.currentValue.remove) {
          this.currentValue.remove();
        }

        this.currentValue = value;

        if (!value) {
          return this.section.removeAll();
        }

        var node;

        if (value.render) {
          value.remove();
          node = value.render();
        } else Iif (value.nodeType != null) {
          node = value;
        } else {
          Eif (this.nodeFactory.name !== "dom") {
            node = this.nodeFactory.createTextNode(String(value));
          } else {
            var div = this.nodeFactory.createElement("div");
            div.innerHTML = String(value);
            node = this.nodeFactory.createFragment(div.childNodes);
          }
        }

        this.section.replaceChildNodes(node);
      }
    });