# Code coverage report for lib/template/vnode/text/index.js

## Statements: 100% (9 / 9) Branches: 100% (2 / 2) Functions: 100% (3 / 3) Lines: 100% (9 / 9) Ignored: none

All files » lib/template/vnode/text/ » index.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
    361

    1
    117

    1

    168
    2

    166

    1
    117

     var protoclass = require("protoclass");

    /**
     */

    function Text(value) {
      this.value = value;
    }

    /**
     */

    module.exports = protoclass(Text, {

      /**
       */

      initialize: function(template) {

        // blank text nodes are NOT allowed. Chrome has an issue rendering
        // blank text nodes - way, WAY slower if this isn't here!
        if (/^\s+$/.test(this.value)) {
          return template.nodeFactory.createTextNode("\u00A0");
        }

        return template.nodeFactory.createTextNode(this.value);
      }
    });

    /**
     */

    module.exports.create = function(value) {
      return new Text(value);
    };