src/swimlane.js
function text (factory, node, cursor) {
    // Process a text node. 
    var parentNode = node.parentNode;

    // If the node is CDATA convert it to text.
    if (node.nodeType == 4) {
      var text = factory.createTextNode(node.data);
      parentNode.insertBefore(text, node);
      parentNode.removeChild(node);
      node = text;
    }

    var prev = node.previousSibling;
    if (node.nodeType == 3) {
      // Combine adjacent text nodes. You'll notice that this means that we
      // might be reaching outside the range givne to us to normalize. That is
      // if fine. The boundary is guidance to save time, not a firewall.
      if (prev != null && prev.nodeType == 3) {
        var text = factory.createTextNode(prev.data + node.data);
        if (prev == cursor.node) {
          cursor.node = text;
        }
        parentNode.insertBefore(text, prev);
        parentNode.removeChild(prev);
        parentNode.removeChild(node);
        node = text;
      }

      // Remove duplicate whitespace.
      if (/\s\s/.test(node.data)) {
        var text = factory.createTextNode(node.data.replace(/\s\s+/g, " "));
        parentNode.insertBefore(text, node);
        parentNode.removeChild(node);
        node = text;
      }
    }

    return node;
  }
function text (factory, node, cursor) {
    // Process a text node. 
    var parentNode = node.parentNode;

    // If the node is CDATA convert it to text.
    if (node.nodeType == 4) {
      var text = factory.createTextNode(node.data);
      parentNode.insertBefore(text, node);
      parentNode.removeChild(node);
      node = text;
    }

    var prev = node.previousSibling;
    if (node.nodeType == 3) {
      // Combine adjacent text nodes. You'll notice that this means that we
      // might be reaching outside the range givne to us to normalize. That is
      // if fine. The boundary is guidance to save time, not a firewall.
      if (prev != null && prev.nodeType == 3) {
        var text = factory.createTextNode(prev.data + node.data);
        if (prev == cursor.node) {
          cursor.node = text;
        }
        parentNode.insertBefore(text, prev);
        parentNode.removeChild(prev);
        parentNode.removeChild(node);
        node = text;
      }

      // Remove duplicate whitespace.
      if (/\s\s/.test(node.data)) {
        var text = factory.createTextNode(node.data.replace(/\s\s+/g, " "));
        parentNode.insertBefore(text, node);
        parentNode.removeChild(node);
        node = text;
      }
    }

    return node;
  }
function text ( factory , node , cursor ) { // Process a text node.  var parentNode = node . parentNode ; // If the node is CDATA convert it to text. if ( node . nodeType == 4 ) { var text = factory . createTextNode ( node . data ) ; parentNode . insertBefore ( text , node ) ; parentNode . removeChild ( node ) ; node = text ; } var prev = node . previousSibling ; if ( node . nodeType == 3 ) { // Combine adjacent text nodes. You'll notice that this means that we // might be reaching outside the range givne to us to normalize. That is // if fine. The boundary is guidance to save time, not a firewall. if ( prev != null && prev . nodeType == 3 ) { var text = factory . createTextNode ( prev . data + node . data ) ; if ( prev == cursor . node ) { cursor . node = text ; } parentNode . insertBefore ( text , prev ) ; parentNode . removeChild ( prev ) ; parentNode . removeChild ( node ) ; node = text ; } // Remove duplicate whitespace. if ( / \s\s / . test ( node . data ) ) { var text = factory . createTextNode ( node . data . replace ( / \s\s+ / g , " " ) ) ; parentNode . insertBefore ( text , node ) ; parentNode . removeChild ( node ) ; node = text ; } } return node ; }
Called for each node, this method will normalize the node if it is a text element, but if it is not a text element nothing is done.
Called for each node this method will normalize the node if it is a text element but if it is not a text element nothing is done .