Create list element.
@param {Boolean} isCollapsed
@return {HTMLElement}
540700
function createList (isCollapsed) {
    var listElement = (options.orderedList) ? 'ol' : 'ul'
    var list = document.createElement(listElement)
    var classes = options.listClass +
      SPACE_CHAR + options.extraListClasses
    if (isCollapsed) {
      classes += SPACE_CHAR + options.collapsibleClass
      classes += SPACE_CHAR + options.isCollapsedClass
    }
    list.setAttribute('class', classes)
    return list
  }
706264
function(element, options) {
    _.extend(this, Backbone.Events);

    var defaults = require('../utils/default-options')();
    // set to be an object in case
    // it's undefined
    options = options || {};

    // extend the defaults
    options = _.extend(defaults, options);

    this.options = options;

    this._currentColumns = [];

    this.container = element;

    this.innerContainer = document.createElement('div');
    this.innerContainer.classList.add('inner-container');
    this.innerContainer.classList.add('hide-overflow');

    this.el = document.createElement('table');
    this.el.classList.add('table');
    this.el.classList.add('table-striped');
    this.container.classList.add('table-sink-container');
    this.innerContainer.appendChild(this.el);
    this.container.appendChild(this.innerContainer);

    this.innerContainer.style.maxHeight = options.height + 'px';

    this.resize();

    // create some scaffolding
    this.table = d3.select(this.el);
    this.thead = this.table.append('thead');
    this.tbody = this.table.append('tbody');

    // set if we should append to the existing table data
    // and not reset on batch_end
    this._append = options._append;

    this._markdownFields = this.options.markdownFields || [];

    this._bindScrollBlocker();

    // We don't need a fully-fledged data target here,
    // so we just add functions as per feedback from @demmer
    var self = this;
    this.dataTarget = {
        _data: [],
        push: function(data) {
            // clear the table if we've done batch_end / stream_end before
            if (this._data.length === 0) {
                self.clearTable();
            }

            // limit the data to avoid crashing the browser. If limit
            // is zero, then it is ignored. If the limit has been reached,
            // we return early and don't display the new data

            // check that we aren't already over the limit
            if (this._data.length >= self.options.limit) {

                // display the message and don't do anything else
                self._sendRowLimitReachedMessage();
                return;

            // check that the new data won't make us go over the limit
            } else if ((this._data.length + data.length) > self.options.limit) {

                self._sendRowLimitReachedMessage();

                // just add from new data until we get to the limit
                var i = 0;
                while (this._data.length < self.options.limit) {
                    this._data.push(data[i++]);
                }
            }
            // we're fine.
            else {
                self._clearRowLimitReachedMessage();
                this._data = this._data.concat(data);
            }

            // if you got here, draw the table
            self.onData(this._data);

        },
        batch_end: function() {
            if (self.options.update === 'replace') {
                this._data = [];
            }
        },
        stream_end: function() {
        }
    };

}
1361795
function _list (str, isOrdered) {
  if (!str) return str;

  var $ = cheerio.load(str);
  var listEl = isOrdered ? 'ol' : 'ul';

  $(listEl).each(function (i, el) {
    var $out = cheerio.load('<p></p>');
    var $el = $(el);

    $el.find('li').each(function (j, li) {
      var tick = isOrdered ? String(j + 1) + '.' : '-';

      $out('p').append(tick + ' ' + _escapeHtml($(li).text()) + '<br />');
    });

    // avoid excess spacing coming off last element
    // (we are wrapping with a <p> anyway)
    $out('br').last().remove();

    $el.replaceWith($out.html());
  });

  return $.html();
}
954006
function handleEmptyListItem() {
          function isFirstOrLastLi(first) {
            var node = containerBlock[first ? 'firstChild' : 'lastChild'];

            // Find first/last element since there might be whitespace there
            while (node) {
              if (node.nodeType == 1) {
                break;
              }

              node = node[first ? 'nextSibling' : 'previousSibling'];
            }

            return node === parentBlock;
          }

          function getContainerBlock() {
            var containerBlockParent = containerBlock.parentNode;

            if (/^(LI|DT|DD)$/.test(containerBlockParent.nodeName)) {
              return containerBlockParent;
            }

            return containerBlock;
          }

          if (containerBlock == editor.getBody()) {
            return;
          }

          // Check if we are in an nested list
          var containerBlockParentName = containerBlock.parentNode.nodeName;
          if (/^(OL|UL|LI)$/.test(containerBlockParentName)) {
            newBlockName = 'LI';
          }

          newBlock = newBlockName ? createNewBlock(newBlockName) : dom.create('BR');

          if (isFirstOrLastLi(true) && isFirstOrLastLi()) {
            if (containerBlockParentName == 'LI') {
              // Nested list is inside a LI
              dom.insertAfter(newBlock, getContainerBlock());
            } else {
              // Is first and last list item then replace the OL/UL with a text block
              dom.replace(newBlock, containerBlock);
            }
          } else if (isFirstOrLastLi(true)) {
            if (containerBlockParentName == 'LI') {
              // List nested in an LI then move the list to a new sibling LI
              dom.insertAfter(newBlock, getContainerBlock());
              newBlock.appendChild(dom.doc.createTextNode(' ')); // Needed for IE so the caret can be placed
              newBlock.appendChild(containerBlock);
            } else {
              // First LI in list then remove LI and add text block before list
              containerBlock.parentNode.insertBefore(newBlock, containerBlock);
            }
          } else if (isFirstOrLastLi()) {
            // Last LI in list then remove LI and add text block after list
            dom.insertAfter(newBlock, getContainerBlock());
            renderBlockOnIE(newBlock);
          } else {
            // Middle LI in list the split the list and insert a text block in the middle
            // Extract after fragment and insert it after the current block
            containerBlock = getContainerBlock();
            tmpRng = rng.cloneRange();
            tmpRng.setStartAfter(parentBlock);
            tmpRng.setEndAfter(containerBlock);
            fragment = tmpRng.extractContents();

            if (newBlockName == 'LI' && fragment.firstChild.nodeName == 'LI') {
              newBlock = fragment.firstChild;
              dom.insertAfter(fragment, containerBlock);
            } else {
              dom.insertAfter(fragment, containerBlock);
              dom.insertAfter(newBlock, containerBlock);
            }
          }

          dom.remove(parentBlock);
          moveToCaretPosition(newBlock);
          undoManager.add();
        }
701609
function compileElement(node, scope, isRoot) {
        var tagName = node.tagName
        var inst
        switch(true) {
            /**
             *  <*-if></*-if>
             */
            case is.IfElement(tagName):
                var children = _slice(node.children)
                var exprs = [$(node).attr('is')]
                children.forEach(function(c) {
                    if (is.ElseElement(c)) {
                        exprs.push($(c).attr(conf.namespace + 'else') || '')
                    }
                })
                inst = new ElementDirective(
                        vm, 
                        scope,
                        node, 
                        elements['if'], 
                        NS + 'if', 
                        exprs
                )
                if (!isRoot) {
                    inst.$mount(node)
                }
                // save elements refs
                _directives.push(inst)
                // save bindins to scope
                _setBindings2Scope(scope, inst)
                return inst
            /**
             *  <*-repeat></*-repeat>
             */
            case is.RepeatElement(tagName):
                inst = new ElementDirective(
                        vm, 
                        scope,
                        node, 
                        elements.repeat,
                        NS + 'repeat', 
                        $(node).attr('items')
                )
                if (!isRoot) {
                    inst.$mount(node)
                }
                _directives.push(inst)
                _setBindings2Scope(scope, inst)
                return inst
        }
    }
732449
function createCanvas (element) {
  const canvas = document.createElement('canvas');

  canvas.style.display = 'block';
  canvas.classList.add(CANVAS_CSS_CLASS);
  element.appendChild(canvas);

  return canvas;
}
754655
function(markup) {

	var container = y.createElement('div');
	container.innerHTML = markup;

	return new NWTNodeInstance(container.childNodes[0]);
}
1273713
function createEnablerList () {
    var buttons = document.getElementById('buttons');

    var enablerContainer = document.createElement('div');
    enablerContainer.id = 'test-enablers-container';

    // Create header to show count of enabled/total tests
    var header = document.createElement('h3');
    header.id = 'tests-enabled';

    // Create widget to show/hide list
    var expander = document.createElement('span');
    expander.id = 'test-expander';
    expander.innerText = 'Show/hide tests to be run';
    expander.onclick = toggleEnablerVisibility;

    // Create list to contain checkboxes for each test
    var enablerList = document.createElement('div');
    enablerList.id = 'test-list';

    // Create select/deselect all buttons (in button bar)
    var checkButtonBar = document.createElement('ul');
    checkButtonBar.classList.add('topcoat-button-bar');

    function createSelectToggleButton (title, selected) {
        var barItem = document.createElement('li');
        barItem.classList.add('topcoat-button-bar__item');

        var link = document.createElement('a');
        link.classList.add('topcoat-button-bar__button');
        link.innerText = title;
        link.href = null;
        link.onclick = function (e) {
            e.preventDefault();
            toggleSelected(enablerList.id, selected);
            return false;
        };

        barItem.appendChild(link);
        checkButtonBar.appendChild(barItem);
    }
    createSelectToggleButton('Check all', true);
    createSelectToggleButton('Uncheck all', false);
    enablerList.appendChild(checkButtonBar);

    enablerContainer.appendChild(header);
    enablerContainer.appendChild(expander);
    enablerContainer.appendChild(enablerList);

    buttons.appendChild(enablerContainer);

    return enablerList;
}
1195471
function(li,maxLevel) {
      this.expandElement(li);
      var sub = Dom.getChildrenBy(li, function(c) {return c.tagName == "UL";})[0].childNodes;
      for(var j = 0 ; j < sub.length ; j++) {
         var s = sub[j];
         if(Dom.hasClass(s,"collapsed") && maxLevel != 0) {
            this.expandBranch(s,maxLevel-1);
         }
      }
   }
671858
function(elements) {

        // first elment is in the first group
        // @TODO maybe i dont need this?
        var groups = [[elements[0]]];

        for(var i = 1; i < elements.length; i++) {
            var elementNew = elements[i];
            var addedToGroup = false;
            for(var j = 0; j < groups.length; j++) {
                var group = groups[j];
                var elementGroup = group[0];
                if(this.checkSimilarElements(elementNew, elementGroup)) {
                    group.push(elementNew);
                    addedToGroup = true;
                    break;
                }
            }

            // add new group
            if(!addedToGroup) {
                groups.push([elementNew]);
            }
        }

        return groups;
    }
107692
function createElement(tagName) {
  return function (...args) {
    const element  = document.createElement(tagName);
    const attrs    = isObject(args[0]) ? args[0] : {};
    const children = args.length === 2 ? args[1] : args[0];

    Object
      .keys(attrs)
      .forEach(name => element.setAttribute(name, attrs[name]));

    if (Array.isArray(children)) {
      children.forEach(node => append(element, node));
    }

    if (isString(children) && !isVoidElement(tagName.toLowerCase())) {
      append(element, children);
    }

    return element;
  };
}
729894
function (collection, settings, isInitialization, event) {
            var elementsParent = $(settings.elements_parent_selector);
            var init = elementsParent.find('.' + settings.prefix + '-tmp').length === 0;
            var elements = collection.find(settings.elements_selector);

            // add a rescue button that will appear only if collection is emptied
            if (settings.allow_add) {
                if (init) {
                    elementsParent.append('<span class="' + settings.prefix + '-tmp"></span>');
                    if (settings.add) {
                        elementsParent.append(
                            $(settings.add)
                                .addClass(settings.prefix + '-action ' + settings.prefix + '-rescue-add')
                                .data('collection', collection.attr('id'))
                        );
                    }
                }
            }

            // initializes the collection with a minimal number of elements
            if (isInitialization) {
                collection.data('collection-offset', elements.length);

                var container = $(settings.container);
                var button = collection.find('.' + settings.prefix + '-add, .' + settings.prefix + '-rescue-add, .' + settings.prefix + '-duplicate').first();
                var secure = 0;
                while (elements.length < settings.init_with_n_elements) {
                    secure++;
                    var element = elements.length > 0 ? elements.last() : undefined;
                    var index = elements.length - 1;
                    elements = doAdd(container, button, collection, settings, elements, element, index, false);
                    if (secure > settings.init_with_n_elements) {
                        console.error('Infinite loop, element selector (' + settings.elements_selector + ') not found !');
                        break;
                    }
                }

                collection.data('collection-offset', elements.length);
            }

            // make buttons appear/disappear in each elements of the collection according to options
            // (enabled, min/max...) and logic (for example, do not put a move up button on the first
            // element of the collection)
            elements.each(function (index) {
                var element = $(this);

                if (isInitialization) {
                    element.data('index', index);
                }

                var actions = element.find('.' + settings.prefix + '-actions').addBack().filter('.' + settings.prefix + '-actions');
                if (actions.length === 0) {
                    actions = $('<' + settings.action_container_tag + ' class="' + settings.prefix + '-actions"></' + settings.action_container_tag + '>');

                    element.append(actions);
                }

                var delta = 0;
                if (event === 'remove' && settings.fade_out) {
                    delta = 1;
                }

                var buttons = [
                    {
                        'enabled': settings.allow_remove,
                        'selector': settings.prefix + '-remove',
                        'html': settings.remove,
                        'condition': elements.length - delta > settings.min
                    }, {
                        'enabled': settings.allow_up,
                        'selector': settings.prefix + '-up',
                        'html': settings.up,
                        'condition': elements.length - delta > 1 && elements.index(element) - delta > 0
                    }, {
                        'enabled': settings.allow_down,
                        'selector': settings.prefix + '-down',
                        'html': settings.down,
                        'condition': elements.length - delta > 1 && elements.index(element) !== elements.length - 1
                    }, {
                        'enabled': settings.allow_add && !settings.add_at_the_end && !settings.custom_add_location,
                        'selector': settings.prefix + '-add',
                        'html': settings.add,
                        'condition': elements.length - delta < settings.max
                    }, {
                        'enabled': settings.allow_duplicate,
                        'selector': settings.prefix + '-duplicate',
                        'html': settings.duplicate,
                        'condition': elements.length - delta < settings.max
                    }
                ];

                $.each(buttons, function (i, button) {
                    if (button.enabled) {
                        var action = element.find('.' + button.selector);
                        if (action.length === 0 && button.html) {
                            action = $(button.html)
                                .appendTo(actions)
                                .addClass(button.selector);
                        }
                        if (button.condition) {
                            action.removeClass(settings.prefix + '-action-disabled');
                            if (settings.hide_useless_buttons) {
                                action.css('display', '');
                            }
                        } else {
                            action.addClass(settings.prefix + '-action-disabled');
                            if (settings.hide_useless_buttons) {
                                action.css('display', 'none');
                            }
                        }
                        action
                            .addClass(settings.prefix + '-action')
                            .data('collection', collection.attr('id'))
                            .data('element', getOrCreateId(collection.attr('id') + '_' + index, element));
                    } else {
                        element.find('.' + button.selector).css('display', 'none');
                    }
                });

            }); // elements.each

            // make the rescue button appear / disappear according to options (add_at_the_end) and
            // logic (no more elements on the collection)
            if (settings.allow_add) {

                var delta = 0;
                if (event === 'remove' && settings.fade_out) {
                    delta = 1;
                }

                var rescueAdd = collection.find('.' + settings.prefix + '-rescue-add').css('display', '').removeClass(settings.prefix + '-action-disabled');
                var adds = collection.find('.' + settings.prefix + '-add');
                if (!settings.add_at_the_end && adds.length > delta || settings.custom_add_location) {
                    rescueAdd.css('display', 'none');
                } else if (event === 'remove' && settings.fade_out) {
                    rescueAdd.css('display', 'none');
                    rescueAdd.fadeIn('fast');
                }
                if (elements.length - delta >= settings.max) {
                    rescueAdd.addClass(settings.prefix + '-action-disabled');
                    if (settings.hide_useless_buttons) {
                        collection.find('.' + settings.prefix + '-add, .' + settings.prefix + '-rescue-add, .' + settings.prefix + '-duplicate').css('display', 'none');
                    }
                }
            }

        }
85892
function createElement (
  context,
  tag,
  data,
  children,
  normalizationType,
  alwaysNormalize
) {
  if (Array.isArray(data) || isPrimitive(data)) {
    normalizationType = children;
    children = data;
    data = undefined;
  }
  if (alwaysNormalize) { normalizationType = ALWAYS_NORMALIZE; }
  return _createElement(context, tag, data, children, normalizationType)
}
582787
function createWrappedComponent() {

        // Create a picker wrapper holder
        return PickerConstructor._.node( 'div',

            // Create a picker wrapper node
            PickerConstructor._.node( 'div',

                // Create a picker frame
                PickerConstructor._.node( 'div',

                    // Create a picker box node
                    PickerConstructor._.node( 'div',

                        // Create the components nodes.
                        P.component.nodes( STATE.open ),

                        // The picker box class
                        CLASSES.box
                    ),

                    // Picker wrap class
                    CLASSES.wrap
                ),

                // Picker frame class
                CLASSES.frame
            ),

            // Picker holder class
            CLASSES.holder
        ) //endreturn
    }
220284
function createWrapperFunction(wrapperEl, range) {
    var startNode = range.startContainer
      , endNode = range.endContainer
      , startOffset = range.startOffset
      , endOffset = range.endOffset

  return function wrapNode(node) {
    var currentRange = document.createRange()
      , currentWrapper = wrapperEl.cloneNode()

    currentRange.selectNodeContents(node)

    if (node === startNode && startNode.nodeType === 3) {
      currentRange.setStart(node, startOffset)
      startNode = currentWrapper
      startOffset = 0
    }
    if (node === endNode && endNode.nodeType === 3) {
      currentRange.setEnd(node, endOffset)
      endNode = currentWrapper
      endOffset = 1
    }

    currentRange.surroundContents(currentWrapper)
    return currentWrapper
  }
}
797818
function updateCollapse(range) {
        range.collapsed =
            range.startContainer && range.endContainer &&
                range.startContainer === range.endContainer &&
                range.startOffset == range.endOffset;
    }
937721
function render (selector, data) {
    var collapsed = false
    var container = createList(collapsed)

    data.forEach(function (d) {
      createEl(d, container)
    })

    var parent = document.querySelector(selector)

    // Return if no parent is found.
    if (parent === null) {
      return
    }

    // Remove existing child if it exists.
    if (parent.firstChild) {
      parent.removeChild(parent.firstChild)
    }

    // Just return the parent and don't append the list if no links are found.
    if (data.length === 0) {
      return parent
    }

    // Append the Elements that have been created
    return parent.appendChild(container)
  }