From 0f592ad0c5441f69c2ec121917de52a47fae6e82 Mon Sep 17 00:00:00 2001 From: Cedric Michaux Date: Fri, 1 Jul 2016 10:48:57 +0200 Subject: [PATCH 1/9] Added Prepublish hook Moved from browserify and grunt to webpack Use babel with react preset Npm based build --- .babelrc | 3 + .gitignore | 2 + Gruntfile.js | 2 +- example/App.jsx | 8 +- example/bundle.js | 21105 ++++++++++++++++++++++++-------------------- index.js | 9 +- package.json | 24 +- src/TreeMenu.jsx | 4 +- src/TreeNode.jsx | 2 +- src/index.js | 7 + webpack.config.js | 44 + 11 files changed, 11431 insertions(+), 9779 deletions(-) create mode 100644 .babelrc create mode 100644 src/index.js create mode 100644 webpack.config.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..12d195e --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["react"] +} diff --git a/.gitignore b/.gitignore index 38100f0..4456796 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ .idea node_modules/ node_modules +lib/ +npm-debug.log diff --git a/Gruntfile.js b/Gruntfile.js index d71806b..9f5f64f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -14,7 +14,7 @@ module.exports = function(grunt) { src: ['example/boot.jsx'], dest: 'example/bundle.js', options: { - transform: ['reactify'] + transform: ['babelify'] } } } diff --git a/example/App.jsx b/example/App.jsx index 89d0e38..d815df6 100644 --- a/example/App.jsx +++ b/example/App.jsx @@ -1,7 +1,7 @@ var React = require('react'), - TreeMenu = require('../index'), - TreeNode = require('../index').TreeNode, - TreeMenuUtils = require('../index').Utils, + TreeMenu = require('../src/index'), + TreeNode = require('../src/index').TreeNode, + TreeMenuUtils = require('../src/index').Utils, Immutable = require('immutable'), _ = require('lodash'); @@ -587,4 +587,4 @@ var App = React.createClass({ }); -module.exports = App; \ No newline at end of file +module.exports = App; diff --git a/example/bundle.js b/example/bundle.js index 6f9b5f3..b6da028 100644 --- a/example/bundle.js +++ b/example/bundle.js @@ -235,13 +235,15 @@ var App = React.createClass({displayName: "App", React.createElement("div", {className: "col-lg-3"}, React.createElement("h2", null, "Label Filter"), React.createElement("ul", null, - React.createElement("li", null, "This menu has a labelFilter prop that truncates the displayed label") + React.createElement("li", null, "This menu has a labelFilter prop that truncates the displayed label"), + React.createElement("li", null, "NOTE: no event handlers attached for this example") ) ), React.createElement("div", {className: "col-lg-3"}, React.createElement("h2", null, "Renderers"), React.createElement("ul", null, - React.createElement("li", null, "Using renderer (node factory) methods as arguments") + React.createElement("li", null, "Using renderer (node factory) methods as arguments"), + React.createElement("li", null, "NOTE: no event handlers attached for this example") ) ) @@ -589,7 +591,7 @@ var App = React.createClass({displayName: "App", module.exports = App; -},{"../index":3,"immutable":5,"lodash":9,"react":240,"react-addons-css-transition-group":78}],2:[function(require,module,exports){ +},{"../index":3,"immutable":32,"lodash":38,"react":254,"react-addons-css-transition-group":119}],2:[function(require,module,exports){ var React = require('react'); var ReactDOM = require('react-dom'); var App = require('./App.jsx'); @@ -598,7 +600,7 @@ var App = require('./App.jsx'); ReactDOM.render(React.createElement(App, null), document.getElementById('appContainer')); -},{"./App.jsx":1,"react":240,"react-dom":79}],3:[function(require,module,exports){ +},{"./App.jsx":1,"react":254,"react-dom":120}],3:[function(require,module,exports){ var api = require('./src/TreeMenu.jsx'); api.TreeMenu = require('./src/TreeMenu.jsx'); @@ -608,2173 +610,2794 @@ api.Utils = require('./src/TreeMenuUtils'); module.exports = api; -},{"./src/TreeMenu.jsx":241,"./src/TreeMenuUtils":242,"./src/TreeNode.jsx":243}],4:[function(require,module,exports){ -// shim for using process in browser - -var process = module.exports = {}; -var queue = []; -var draining = false; - -function drainQueue() { - if (draining) { - return; - } - draining = true; - var currentQueue; - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - var i = -1; - while (++i < len) { - currentQueue[i](); - } - len = queue.length; - } - draining = false; -} -process.nextTick = function (fun) { - queue.push(fun); - if (!draining) { - setTimeout(drainQueue, 0); - } -}; - -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -// TODO(shtylman) -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}],5:[function(require,module,exports){ +},{"./src/TreeMenu.jsx":255,"./src/TreeMenuUtils":256,"./src/TreeNode.jsx":257}],4:[function(require,module,exports){ +(function (process){ /** - * Copyright (c) 2014, Facebook, Inc. - * All rights reserved. + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule CSSCore + * @typechecks */ -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - global.Immutable = factory() -}(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice; - - function createClass(ctor, superClass) { - if (superClass) { - ctor.prototype = Object.create(superClass.prototype); - } - ctor.prototype.constructor = ctor; - } - - // Used for setting prototype methods that IE8 chokes on. - var DELETE = 'delete'; - - // Constants describing the size of trie nodes. - var SHIFT = 5; // Resulted in best performance after ______? - var SIZE = 1 << SHIFT; - var MASK = SIZE - 1; - // A consistent shared value representing "not set" which equals nothing other - // than itself, and nothing that could be provided externally. - var NOT_SET = {}; +'use strict'; - // Boolean references, Rough equivalent of `bool &`. - var CHANGE_LENGTH = { value: false }; - var DID_ALTER = { value: false }; +var invariant = require('./invariant'); - function MakeRef(ref) { - ref.value = false; - return ref; - } +/** + * The CSSCore module specifies the API (and implements most of the methods) + * that should be used when dealing with the display of elements (via their + * CSS classes and visibility on screen. It is an API focused on mutating the + * display and not reading it as no logical state should be encoded in the + * display of elements. + */ - function SetRef(ref) { - ref && (ref.value = true); - } +var CSSCore = { - // A function which returns a value representing an "owner" for transient writes - // to tries. The return value will only ever equal itself, and will not equal - // the return of any subsequent call of this function. - function OwnerID() {} + /** + * Adds the class passed in to the element if it doesn't already have it. + * + * @param {DOMElement} element the element to set the class on + * @param {string} className the CSS className + * @return {DOMElement} the element passed in + */ + addClass: function (element, className) { + !!/\s/.test(className) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'CSSCore.addClass takes only a single class name. "%s" contains ' + 'multiple classes.', className) : invariant(false) : undefined; - // http://jsperf.com/copy-array-inline - function arrCopy(arr, offset) { - offset = offset || 0; - var len = Math.max(0, arr.length - offset); - var newArr = new Array(len); - for (var ii = 0; ii < len; ii++) { - newArr[ii] = arr[ii + offset]; + if (className) { + if (element.classList) { + element.classList.add(className); + } else if (!CSSCore.hasClass(element, className)) { + element.className = element.className + ' ' + className; + } } - return newArr; - } + return element; + }, - function ensureSize(iter) { - if (iter.size === undefined) { - iter.size = iter.__iterate(returnTrue); + /** + * Removes the class passed in from the element + * + * @param {DOMElement} element the element to set the class on + * @param {string} className the CSS className + * @return {DOMElement} the element passed in + */ + removeClass: function (element, className) { + !!/\s/.test(className) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'CSSCore.removeClass takes only a single class name. "%s" contains ' + 'multiple classes.', className) : invariant(false) : undefined; + + if (className) { + if (element.classList) { + element.classList.remove(className); + } else if (CSSCore.hasClass(element, className)) { + element.className = element.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)', 'g'), '$1').replace(/\s+/g, ' ') // multiple spaces to one + .replace(/^\s*|\s*$/g, ''); // trim the ends + } } - return iter.size; - } + return element; + }, - function wrapIndex(iter, index) { - return index >= 0 ? (+index) : ensureSize(iter) + (+index); - } + /** + * Helper to add or remove a class from an element based on a condition. + * + * @param {DOMElement} element the element to set the class on + * @param {string} className the CSS className + * @param {*} bool condition to whether to add or remove the class + * @return {DOMElement} the element passed in + */ + conditionClass: function (element, className, bool) { + return (bool ? CSSCore.addClass : CSSCore.removeClass)(element, className); + }, - function returnTrue() { - return true; + /** + * Tests whether the element has the class specified. + * + * @param {DOMNode|DOMWindow} element the element to set the class on + * @param {string} className the CSS className + * @return {boolean} true if the element has the class, false if not + */ + hasClass: function (element, className) { + !!/\s/.test(className) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'CSS.hasClass takes only a single class name.') : invariant(false) : undefined; + if (element.classList) { + return !!className && element.classList.contains(className); + } + return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1; } - function wholeSlice(begin, end, size) { - return (begin === 0 || (size !== undefined && begin <= -size)) && - (end === undefined || (size !== undefined && end >= size)); - } +}; - function resolveBegin(begin, size) { - return resolveIndex(begin, size, 0); - } +module.exports = CSSCore; +}).call(this,require('_process')) +},{"./invariant":20,"_process":118}],5:[function(require,module,exports){ +(function (process){ +/** + * Copyright 2013-2015, Facebook, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @providesModule EventListener + * @typechecks + */ - function resolveEnd(end, size) { - return resolveIndex(end, size, size); - } +'use strict'; - function resolveIndex(index, size, defaultIndex) { - return index === undefined ? - defaultIndex : - index < 0 ? - Math.max(0, size + index) : - size === undefined ? - index : - Math.min(size, index); - } +var emptyFunction = require('./emptyFunction'); - function Iterable(value) { - return isIterable(value) ? value : Seq(value); +/** + * Upstream version of event listener. Does not take into account specific + * nature of platform. + */ +var EventListener = { + /** + * Listen to DOM events during the bubble phase. + * + * @param {DOMEventTarget} target DOM element to register listener on. + * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. + * @param {function} callback Callback function. + * @return {object} Object with a `remove` method. + */ + listen: function (target, eventType, callback) { + if (target.addEventListener) { + target.addEventListener(eventType, callback, false); + return { + remove: function () { + target.removeEventListener(eventType, callback, false); + } + }; + } else if (target.attachEvent) { + target.attachEvent('on' + eventType, callback); + return { + remove: function () { + target.detachEvent('on' + eventType, callback); + } + }; } + }, - - createClass(KeyedIterable, Iterable); - function KeyedIterable(value) { - return isKeyed(value) ? value : KeyedSeq(value); + /** + * Listen to DOM events during the capture phase. + * + * @param {DOMEventTarget} target DOM element to register listener on. + * @param {string} eventType Event type, e.g. 'click' or 'mouseover'. + * @param {function} callback Callback function. + * @return {object} Object with a `remove` method. + */ + capture: function (target, eventType, callback) { + if (target.addEventListener) { + target.addEventListener(eventType, callback, true); + return { + remove: function () { + target.removeEventListener(eventType, callback, true); + } + }; + } else { + if (process.env.NODE_ENV !== 'production') { + console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.'); + } + return { + remove: emptyFunction + }; } + }, + registerDefault: function () {} +}; - createClass(IndexedIterable, Iterable); - function IndexedIterable(value) { - return isIndexed(value) ? value : IndexedSeq(value); - } +module.exports = EventListener; +}).call(this,require('_process')) +},{"./emptyFunction":12,"_process":118}],6:[function(require,module,exports){ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule ExecutionEnvironment + */ +'use strict'; - createClass(SetIterable, Iterable); - function SetIterable(value) { - return isIterable(value) && !isAssociative(value) ? value : SetSeq(value); - } +var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement); +/** + * Simple, lightweight module assisting with the detection and context of + * Worker. Helps avoid circular dependencies and allows code to reason about + * whether or not they are in a Worker, even if they never include the main + * `ReactWorker` dependency. + */ +var ExecutionEnvironment = { + canUseDOM: canUseDOM, - function isIterable(maybeIterable) { - return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]); - } + canUseWorkers: typeof Worker !== 'undefined', - function isKeyed(maybeKeyed) { - return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]); - } + canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent), - function isIndexed(maybeIndexed) { - return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]); - } + canUseViewport: canUseDOM && !!window.screen, - function isAssociative(maybeAssociative) { - return isKeyed(maybeAssociative) || isIndexed(maybeAssociative); - } + isInWorker: !canUseDOM // For now, this is true - might change in the future. - function isOrdered(maybeOrdered) { - return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]); - } +}; - Iterable.isIterable = isIterable; - Iterable.isKeyed = isKeyed; - Iterable.isIndexed = isIndexed; - Iterable.isAssociative = isAssociative; - Iterable.isOrdered = isOrdered; +module.exports = ExecutionEnvironment; +},{}],7:[function(require,module,exports){ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule camelize + * @typechecks + */ - Iterable.Keyed = KeyedIterable; - Iterable.Indexed = IndexedIterable; - Iterable.Set = SetIterable; +"use strict"; +var _hyphenPattern = /-(.)/g; - var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'; - var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@'; - var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@'; - var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@'; +/** + * Camelcases a hyphenated string, for example: + * + * > camelize('background-color') + * < "backgroundColor" + * + * @param {string} string + * @return {string} + */ +function camelize(string) { + return string.replace(_hyphenPattern, function (_, character) { + return character.toUpperCase(); + }); +} - /* global Symbol */ +module.exports = camelize; +},{}],8:[function(require,module,exports){ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule camelizeStyleName + * @typechecks + */ - var ITERATE_KEYS = 0; - var ITERATE_VALUES = 1; - var ITERATE_ENTRIES = 2; +'use strict'; - var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = '@@iterator'; +var camelize = require('./camelize'); - var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL; +var msPattern = /^-ms-/; +/** + * Camelcases a hyphenated CSS property name, for example: + * + * > camelizeStyleName('background-color') + * < "backgroundColor" + * > camelizeStyleName('-moz-transition') + * < "MozTransition" + * > camelizeStyleName('-ms-transition') + * < "msTransition" + * + * As Andi Smith suggests + * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix + * is converted to lowercase `ms`. + * + * @param {string} string + * @return {string} + */ +function camelizeStyleName(string) { + return camelize(string.replace(msPattern, 'ms-')); +} - function Iterator(next) { - this.next = next; - } +module.exports = camelizeStyleName; +},{"./camelize":7}],9:[function(require,module,exports){ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule containsNode + * @typechecks + */ - Iterator.prototype.toString = function() { - return '[Iterator]'; - }; +'use strict'; +var isTextNode = require('./isTextNode'); - Iterator.KEYS = ITERATE_KEYS; - Iterator.VALUES = ITERATE_VALUES; - Iterator.ENTRIES = ITERATE_ENTRIES; +/*eslint-disable no-bitwise */ - Iterator.prototype.inspect = - Iterator.prototype.toSource = function () { return this.toString(); } - Iterator.prototype[ITERATOR_SYMBOL] = function () { - return this; - }; +/** + * Checks if a given DOM node contains or is another DOM node. + * + * @param {?DOMNode} outerNode Outer DOM node. + * @param {?DOMNode} innerNode Inner DOM node. + * @return {boolean} True if `outerNode` contains or is `innerNode`. + */ +function containsNode(_x, _x2) { + var _again = true; + _function: while (_again) { + var outerNode = _x, + innerNode = _x2; + _again = false; - function iteratorValue(type, k, v, iteratorResult) { - var value = type === 0 ? k : type === 1 ? v : [k, v]; - iteratorResult ? (iteratorResult.value = value) : (iteratorResult = { - value: value, done: false - }); - return iteratorResult; + if (!outerNode || !innerNode) { + return false; + } else if (outerNode === innerNode) { + return true; + } else if (isTextNode(outerNode)) { + return false; + } else if (isTextNode(innerNode)) { + _x = outerNode; + _x2 = innerNode.parentNode; + _again = true; + continue _function; + } else if (outerNode.contains) { + return outerNode.contains(innerNode); + } else if (outerNode.compareDocumentPosition) { + return !!(outerNode.compareDocumentPosition(innerNode) & 16); + } else { + return false; + } } +} - function iteratorDone() { - return { value: undefined, done: true }; - } +module.exports = containsNode; +},{"./isTextNode":22}],10:[function(require,module,exports){ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule createArrayFromMixed + * @typechecks + */ - function hasIterator(maybeIterable) { - return !!getIteratorFn(maybeIterable); - } +'use strict'; - function isIterator(maybeIterator) { - return maybeIterator && typeof maybeIterator.next === 'function'; - } - - function getIterator(iterable) { - var iteratorFn = getIteratorFn(iterable); - return iteratorFn && iteratorFn.call(iterable); - } +var toArray = require('./toArray'); - function getIteratorFn(iterable) { - var iteratorFn = iterable && ( - (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) || - iterable[FAUX_ITERATOR_SYMBOL] - ); - if (typeof iteratorFn === 'function') { - return iteratorFn; - } - } +/** + * Perform a heuristic test to determine if an object is "array-like". + * + * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?" + * Joshu replied: "Mu." + * + * This function determines if its argument has "array nature": it returns + * true if the argument is an actual array, an `arguments' object, or an + * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()). + * + * It will return false for other array-like objects like Filelist. + * + * @param {*} obj + * @return {boolean} + */ +function hasArrayNature(obj) { + return( + // not null/false + !!obj && ( + // arrays are objects, NodeLists are functions in Safari + typeof obj == 'object' || typeof obj == 'function') && + // quacks like an array + 'length' in obj && + // not window + !('setInterval' in obj) && + // no DOM node should be considered an array-like + // a 'select' element has 'length' and 'item' properties on IE8 + typeof obj.nodeType != 'number' && ( + // a real array + Array.isArray(obj) || + // arguments + 'callee' in obj || + // HTMLCollection/NodeList + 'item' in obj) + ); +} - function isArrayLike(value) { - return value && typeof value.length === 'number'; +/** + * Ensure that the argument is an array by wrapping it in an array if it is not. + * Creates a copy of the argument if it is already an array. + * + * This is mostly useful idiomatically: + * + * var createArrayFromMixed = require('createArrayFromMixed'); + * + * function takesOneOrMoreThings(things) { + * things = createArrayFromMixed(things); + * ... + * } + * + * This allows you to treat `things' as an array, but accept scalars in the API. + * + * If you need to convert an array-like object, like `arguments`, into an array + * use toArray instead. + * + * @param {*} obj + * @return {array} + */ +function createArrayFromMixed(obj) { + if (!hasArrayNature(obj)) { + return [obj]; + } else if (Array.isArray(obj)) { + return obj.slice(); + } else { + return toArray(obj); } +} - createClass(Seq, Iterable); - function Seq(value) { - return value === null || value === undefined ? emptySequence() : - isIterable(value) ? value.toSeq() : seqFromValue(value); - } - - Seq.of = function(/*...values*/) { - return Seq(arguments); - }; +module.exports = createArrayFromMixed; +},{"./toArray":30}],11:[function(require,module,exports){ +(function (process){ +/** + * Copyright 2013-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule createNodesFromMarkup + * @typechecks + */ - Seq.prototype.toSeq = function() { - return this; - }; +/*eslint-disable fb-www/unsafe-html*/ - Seq.prototype.toString = function() { - return this.__toString('Seq {', '}'); - }; +'use strict'; - Seq.prototype.cacheResult = function() { - if (!this._cache && this.__iterateUncached) { - this._cache = this.entrySeq().toArray(); - this.size = this._cache.length; - } - return this; - }; +var ExecutionEnvironment = require('./ExecutionEnvironment'); - // abstract __iterateUncached(fn, reverse) +var createArrayFromMixed = require('./createArrayFromMixed'); +var getMarkupWrap = require('./getMarkupWrap'); +var invariant = require('./invariant'); - Seq.prototype.__iterate = function(fn, reverse) { - return seqIterate(this, fn, reverse, true); - }; +/** + * Dummy container used to render all markup. + */ +var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null; - // abstract __iteratorUncached(type, reverse) +/** + * Pattern used by `getNodeName`. + */ +var nodeNamePattern = /^\s*<(\w+)/; - Seq.prototype.__iterator = function(type, reverse) { - return seqIterator(this, type, reverse, true); - }; +/** + * Extracts the `nodeName` of the first element in a string of markup. + * + * @param {string} markup String of markup. + * @return {?string} Node name of the supplied markup. + */ +function getNodeName(markup) { + var nodeNameMatch = markup.match(nodeNamePattern); + return nodeNameMatch && nodeNameMatch[1].toLowerCase(); +} +/** + * Creates an array containing the nodes rendered from the supplied markup. The + * optionally supplied `handleScript` function will be invoked once for each + *