aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/vendor/react
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2014-11-27 01:37:36 +0100
committerMaximilian Hils <git@maximilianhils.com>2014-11-27 01:37:36 +0100
commit021e209ce0fbfa5fa993ad43e8167a29a759d120 (patch)
treee0afdac43998757fea5ef2dd29de38968f2b4cce /web/src/vendor/react
parented8249023fb7c0d429b9278c63b51ac071700987 (diff)
downloadmitmproxy-021e209ce0fbfa5fa993ad43e8167a29a759d120.tar.gz
mitmproxy-021e209ce0fbfa5fa993ad43e8167a29a759d120.tar.bz2
mitmproxy-021e209ce0fbfa5fa993ad43e8167a29a759d120.zip
web: update dependencies
Diffstat (limited to 'web/src/vendor/react')
-rw-r--r--web/src/vendor/react/JSXTransformer.js4575
-rw-r--r--web/src/vendor/react/react-with-addons.js6462
2 files changed, 6170 insertions, 4867 deletions
diff --git a/web/src/vendor/react/JSXTransformer.js b/web/src/vendor/react/JSXTransformer.js
index 9a7bf5f0..be1cae1f 100644
--- a/web/src/vendor/react/JSXTransformer.js
+++ b/web/src/vendor/react/JSXTransformer.js
@@ -1,7 +1,348 @@
/**
- * JSXTransformer v0.11.1
+ * JSXTransformer v0.12.1
*/
-!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.JSXTransformer=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.JSXTransformer=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
+/**
+ * Copyright 2013-2014, 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.
+ */
+/* jshint browser: true */
+/* jslint evil: true */
+
+'use strict';
+
+var buffer = _dereq_('buffer');
+var transform = _dereq_('jstransform').transform;
+var typesSyntax = _dereq_('jstransform/visitors/type-syntax');
+var visitors = _dereq_('./fbtransform/visitors');
+
+var headEl;
+var dummyAnchor;
+var inlineScriptCount = 0;
+
+// The source-map library relies on Object.defineProperty, but IE8 doesn't
+// support it fully even with es5-sham. Indeed, es5-sham's defineProperty
+// throws when Object.prototype.__defineGetter__ is missing, so we skip building
+// the source map in that case.
+var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
+
+/**
+ * Run provided code through jstransform.
+ *
+ * @param {string} source Original source code
+ * @param {object?} options Options to pass to jstransform
+ * @return {object} object as returned from jstransform
+ */
+function transformReact(source, options) {
+ // TODO: just use react-tools
+ options = options || {};
+ var visitorList;
+ if (options.harmony) {
+ visitorList = visitors.getAllVisitors();
+ } else {
+ visitorList = visitors.transformVisitors.react;
+ }
+
+ if (options.stripTypes) {
+ // Stripping types needs to happen before the other transforms
+ // unfortunately, due to bad interactions. For example,
+ // es6-rest-param-visitors conflict with stripping rest param type
+ // annotation
+ source = transform(typesSyntax.visitorList, source, options).code;
+ }
+
+ return transform(visitorList, source, {
+ sourceMap: supportsAccessors && options.sourceMap
+ });
+}
+
+/**
+ * Eval provided source after transforming it.
+ *
+ * @param {string} source Original source code
+ * @param {object?} options Options to pass to jstransform
+ */
+function exec(source, options) {
+ return eval(transformReact(source, options).code);
+}
+
+/**
+ * This method returns a nicely formated line of code pointing to the exact
+ * location of the error `e`. The line is limited in size so big lines of code
+ * are also shown in a readable way.
+ *
+ * Example:
+ * ... x', overflow:'scroll'}} id={} onScroll={this.scroll} class=" ...
+ * ^
+ *
+ * @param {string} code The full string of code
+ * @param {Error} e The error being thrown
+ * @return {string} formatted message
+ * @internal
+ */
+function createSourceCodeErrorMessage(code, e) {
+ var sourceLines = code.split('\n');
+ var erroneousLine = sourceLines[e.lineNumber - 1];
+
+ // Removes any leading indenting spaces and gets the number of
+ // chars indenting the `erroneousLine`
+ var indentation = 0;
+ erroneousLine = erroneousLine.replace(/^\s+/, function(leadingSpaces) {
+ indentation = leadingSpaces.length;
+ return '';
+ });
+
+ // Defines the number of characters that are going to show
+ // before and after the erroneous code
+ var LIMIT = 30;
+ var errorColumn = e.column - indentation;
+
+ if (errorColumn > LIMIT) {
+ erroneousLine = '... ' + erroneousLine.slice(errorColumn - LIMIT);
+ errorColumn = 4 + LIMIT;
+ }
+ if (erroneousLine.length - errorColumn > LIMIT) {
+ erroneousLine = erroneousLine.slice(0, errorColumn + LIMIT) + ' ...';
+ }
+ var message = '\n\n' + erroneousLine + '\n';
+ message += new Array(errorColumn - 1).join(' ') + '^';
+ return message;
+}
+
+/**
+ * Actually transform the code.
+ *
+ * @param {string} code
+ * @param {string?} url
+ * @param {object?} options
+ * @return {string} The transformed code.
+ * @internal
+ */
+function transformCode(code, url, options) {
+ try {
+ var transformed = transformReact(code, options);
+ } catch(e) {
+ e.message += '\n at ';
+ if (url) {
+ if ('fileName' in e) {
+ // We set `fileName` if it's supported by this error object and
+ // a `url` was provided.
+ // The error will correctly point to `url` in Firefox.
+ e.fileName = url;
+ }
+ e.message += url + ':' + e.lineNumber + ':' + e.column;
+ } else {
+ e.message += location.href;
+ }
+ e.message += createSourceCodeErrorMessage(code, e);
+ throw e;
+ }
+
+ if (!transformed.sourceMap) {
+ return transformed.code;
+ }
+
+ var map = transformed.sourceMap.toJSON();
+ var source;
+ if (url == null) {
+ source = "Inline JSX script";
+ inlineScriptCount++;
+ if (inlineScriptCount > 1) {
+ source += ' (' + inlineScriptCount + ')';
+ }
+ } else if (dummyAnchor) {
+ // Firefox has problems when the sourcemap source is a proper URL with a
+ // protocol and hostname, so use the pathname. We could use just the
+ // filename, but hopefully using the full path will prevent potential
+ // issues where the same filename exists in multiple directories.
+ dummyAnchor.href = url;
+ source = dummyAnchor.pathname.substr(1);
+ }
+ map.sources = [source];
+ map.sourcesContent = [code];
+
+ return (
+ transformed.code +
+ '\n//# sourceMappingURL=data:application/json;base64,' +
+ buffer.Buffer(JSON.stringify(map)).toString('base64')
+ );
+}
+
+
+/**
+ * Appends a script element at the end of the <head> with the content of code,
+ * after transforming it.
+ *
+ * @param {string} code The original source code
+ * @param {string?} url Where the code came from. null if inline
+ * @param {object?} options Options to pass to jstransform
+ * @internal
+ */
+function run(code, url, options) {
+ var scriptEl = document.createElement('script');
+ scriptEl.text = transformCode(code, url, options);
+ headEl.appendChild(scriptEl);
+}
+
+/**
+ * Load script from the provided url and pass the content to the callback.
+ *
+ * @param {string} url The location of the script src
+ * @param {function} callback Function to call with the content of url
+ * @internal
+ */
+function load(url, successCallback, errorCallback) {
+ var xhr;
+ xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP')
+ : new XMLHttpRequest();
+
+ // async, however scripts will be executed in the order they are in the
+ // DOM to mirror normal script loading.
+ xhr.open('GET', url, true);
+ if ('overrideMimeType' in xhr) {
+ xhr.overrideMimeType('text/plain');
+ }
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === 4) {
+ if (xhr.status === 0 || xhr.status === 200) {
+ successCallback(xhr.responseText);
+ } else {
+ errorCallback();
+ throw new Error("Could not load " + url);
+ }
+ }
+ };
+ return xhr.send(null);
+}
+
+/**
+ * Loop over provided script tags and get the content, via innerHTML if an
+ * inline script, or by using XHR. Transforms are applied if needed. The scripts
+ * are executed in the order they are found on the page.
+ *
+ * @param {array} scripts The <script> elements to load and run.
+ * @internal
+ */
+function loadScripts(scripts) {
+ var result = [];
+ var count = scripts.length;
+
+ function check() {
+ var script, i;
+
+ for (i = 0; i < count; i++) {
+ script = result[i];
+
+ if (script.loaded && !script.executed) {
+ script.executed = true;
+ run(script.content, script.url, script.options);
+ } else if (!script.loaded && !script.error && !script.async) {
+ break;
+ }
+ }
+ }
+
+ scripts.forEach(function(script, i) {
+ var options = {
+ sourceMap: true
+ };
+ if (/;harmony=true(;|$)/.test(script.type)) {
+ options.harmony = true
+ }
+ if (/;stripTypes=true(;|$)/.test(script.type)) {
+ options.stripTypes = true;
+ }
+
+ // script.async is always true for non-javascript script tags
+ var async = script.hasAttribute('async');
+
+ if (script.src) {
+ result[i] = {
+ async: async,
+ error: false,
+ executed: false,
+ content: null,
+ loaded: false,
+ url: script.src,
+ options: options
+ };
+
+ load(script.src, function(content) {
+ result[i].loaded = true;
+ result[i].content = content;
+ check();
+ }, function() {
+ result[i].error = true;
+ check();
+ });
+ } else {
+ result[i] = {
+ async: async,
+ error: false,
+ executed: false,
+ content: script.innerHTML,
+ loaded: true,
+ url: null,
+ options: options
+ };
+ }
+ });
+
+ check();
+}
+
+/**
+ * Find and run all script tags with type="text/jsx".
+ *
+ * @internal
+ */
+function runScripts() {
+ var scripts = document.getElementsByTagName('script');
+
+ // Array.prototype.slice cannot be used on NodeList on IE8
+ var jsxScripts = [];
+ for (var i = 0; i < scripts.length; i++) {
+ if (/^text\/jsx(;|$)/.test(scripts.item(i).type)) {
+ jsxScripts.push(scripts.item(i));
+ }
+ }
+
+ if (jsxScripts.length < 1) {
+ return;
+ }
+
+ console.warn(
+ 'You are using the in-browser JSX transformer. Be sure to precompile ' +
+ 'your JSX for production - ' +
+ 'http://facebook.github.io/react/docs/tooling-integration.html#jsx'
+ );
+
+ loadScripts(jsxScripts);
+}
+
+// Listen for load event if we're in a browser and then kick off finding and
+// running of scripts.
+if (typeof window !== "undefined" && window !== null) {
+ headEl = document.getElementsByTagName('head')[0];
+ dummyAnchor = document.createElement('a');
+
+ if (window.addEventListener) {
+ window.addEventListener('DOMContentLoaded', runScripts, false);
+ } else {
+ window.attachEvent('onload', runScripts);
+ }
+}
+
+module.exports = {
+ transform: transformReact,
+ exec: exec
+};
+
+},{"./fbtransform/visitors":37,"buffer":2,"jstransform":21,"jstransform/visitors/type-syntax":33}],2:[function(_dereq_,module,exports){
/*!
* The buffer module from node.js, for the browser.
*
@@ -11,29 +352,45 @@
var base64 = _dereq_('base64-js')
var ieee754 = _dereq_('ieee754')
+var isArray = _dereq_('is-array')
exports.Buffer = Buffer
exports.SlowBuffer = Buffer
exports.INSPECT_MAX_BYTES = 50
-Buffer.poolSize = 8192
+Buffer.poolSize = 8192 // not used by this implementation
+
+var kMaxLength = 0x3fffffff
/**
- * If `Buffer._useTypedArrays`:
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
* === true Use Uint8Array implementation (fastest)
- * === false Use Object implementation (compatible down to IE6)
+ * === false Use Object implementation (most compatible, even IE6)
+ *
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
+ * Opera 11.6+, iOS 4.2+.
+ *
+ * Note:
+ *
+ * - Implementation must support adding new properties to `Uint8Array` instances.
+ * Firefox 4-29 lacked support, fixed in Firefox 30+.
+ * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
+ *
+ * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
+ *
+ * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
+ * incorrect length in some situations.
+ *
+ * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will
+ * get the Object implementation, which is slower but will work correctly.
*/
-Buffer._useTypedArrays = (function () {
- // Detect if browser supports Typed Arrays. Supported browsers are IE 10+, Firefox 4+,
- // Chrome 7+, Safari 5.1+, Opera 11.6+, iOS 4.2+. If the browser does not support adding
- // properties to `Uint8Array` instances, then that's the same as no `Uint8Array` support
- // because we need to be able to add all the node Buffer API methods. This is an issue
- // in Firefox 4-29. Now fixed: https://bugzilla.mozilla.org/show_bug.cgi?id=695438
+Buffer.TYPED_ARRAY_SUPPORT = (function () {
try {
var buf = new ArrayBuffer(0)
var arr = new Uint8Array(buf)
arr.foo = function () { return 42 }
- return 42 === arr.foo() &&
- typeof arr.subarray === 'function' // Chrome 9-10 lack `subarray`
+ return 42 === arr.foo() && // typed array instances can be augmented
+ typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
+ new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
} catch (e) {
return false
}
@@ -66,14 +423,18 @@ function Buffer (subject, encoding, noZero) {
subject = base64clean(subject)
length = Buffer.byteLength(subject, encoding)
} else if (type === 'object' && subject !== null) { // assume object is array-like
- if (subject.type === 'Buffer' && Array.isArray(subject.data))
+ if (subject.type === 'Buffer' && isArray(subject.data))
subject = subject.data
length = +subject.length > 0 ? Math.floor(+subject.length) : 0
} else
- throw new Error('First argument needs to be a number, array or string.')
+ throw new TypeError('must start with number, buffer, array or string')
+
+ if (this.length > kMaxLength)
+ throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
+ 'size: 0x' + kMaxLength.toString(16) + ' bytes')
var buf
- if (Buffer._useTypedArrays) {
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
// Preferred: Return an augmented `Uint8Array` instance for best performance
buf = Buffer._augment(new Uint8Array(length))
} else {
@@ -84,7 +445,7 @@ function Buffer (subject, encoding, noZero) {
}
var i
- if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
+ if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') {
// Speed optimization -- use set if we're copying from a typed array
buf._set(subject)
} else if (isArrayish(subject)) {
@@ -98,7 +459,7 @@ function Buffer (subject, encoding, noZero) {
}
} else if (type === 'string') {
buf.write(subject, 0, encoding)
- } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
+ } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) {
for (i = 0; i < length; i++) {
buf[i] = 0
}
@@ -107,8 +468,25 @@ function Buffer (subject, encoding, noZero) {
return buf
}
-// STATIC METHODS
-// ==============
+Buffer.isBuffer = function (b) {
+ return !!(b != null && b._isBuffer)
+}
+
+Buffer.compare = function (a, b) {
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b))
+ throw new TypeError('Arguments must be Buffers')
+
+ var x = a.length
+ var y = b.length
+ for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
+ if (i !== len) {
+ x = a[i]
+ y = b[i]
+ }
+ if (x < y) return -1
+ if (y < x) return 1
+ return 0
+}
Buffer.isEncoding = function (encoding) {
switch (String(encoding).toLowerCase()) {
@@ -129,43 +507,8 @@ Buffer.isEncoding = function (encoding) {
}
}
-Buffer.isBuffer = function (b) {
- return !!(b != null && b._isBuffer)
-}
-
-Buffer.byteLength = function (str, encoding) {
- var ret
- str = str.toString()
- switch (encoding || 'utf8') {
- case 'hex':
- ret = str.length / 2
- break
- case 'utf8':
- case 'utf-8':
- ret = utf8ToBytes(str).length
- break
- case 'ascii':
- case 'binary':
- case 'raw':
- ret = str.length
- break
- case 'base64':
- ret = base64ToBytes(str).length
- break
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- ret = str.length * 2
- break
- default:
- throw new Error('Unknown encoding')
- }
- return ret
-}
-
Buffer.concat = function (list, totalLength) {
- assert(isArray(list), 'Usage: Buffer.concat(list[, length])')
+ if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])')
if (list.length === 0) {
return new Buffer(0)
@@ -191,26 +534,118 @@ Buffer.concat = function (list, totalLength) {
return buf
}
-Buffer.compare = function (a, b) {
- assert(Buffer.isBuffer(a) && Buffer.isBuffer(b), 'Arguments must be Buffers')
- var x = a.length
- var y = b.length
- for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {}
- if (i !== len) {
- x = a[i]
- y = b[i]
+Buffer.byteLength = function (str, encoding) {
+ var ret
+ str = str + ''
+ switch (encoding || 'utf8') {
+ case 'ascii':
+ case 'binary':
+ case 'raw':
+ ret = str.length
+ break
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ ret = str.length * 2
+ break
+ case 'hex':
+ ret = str.length >>> 1
+ break
+ case 'utf8':
+ case 'utf-8':
+ ret = utf8ToBytes(str).length
+ break
+ case 'base64':
+ ret = base64ToBytes(str).length
+ break
+ default:
+ ret = str.length
}
- if (x < y) {
- return -1
+ return ret
+}
+
+// pre-set for values that may exist in the future
+Buffer.prototype.length = undefined
+Buffer.prototype.parent = undefined
+
+// toString(encoding, start=0, end=buffer.length)
+Buffer.prototype.toString = function (encoding, start, end) {
+ var loweredCase = false
+
+ start = start >>> 0
+ end = end === undefined || end === Infinity ? this.length : end >>> 0
+
+ if (!encoding) encoding = 'utf8'
+ if (start < 0) start = 0
+ if (end > this.length) end = this.length
+ if (end <= start) return ''
+
+ while (true) {
+ switch (encoding) {
+ case 'hex':
+ return hexSlice(this, start, end)
+
+ case 'utf8':
+ case 'utf-8':
+ return utf8Slice(this, start, end)
+
+ case 'ascii':
+ return asciiSlice(this, start, end)
+
+ case 'binary':
+ return binarySlice(this, start, end)
+
+ case 'base64':
+ return base64Slice(this, start, end)
+
+ case 'ucs2':
+ case 'ucs-2':
+ case 'utf16le':
+ case 'utf-16le':
+ return utf16leSlice(this, start, end)
+
+ default:
+ if (loweredCase)
+ throw new TypeError('Unknown encoding: ' + encoding)
+ encoding = (encoding + '').toLowerCase()
+ loweredCase = true
+ }
}
- if (y < x) {
- return 1
+}
+
+Buffer.prototype.equals = function (b) {
+ if(!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
+ return Buffer.compare(this, b) === 0
+}
+
+Buffer.prototype.inspect = function () {
+ var str = ''
+ var max = exports.INSPECT_MAX_BYTES
+ if (this.length > 0) {
+ str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
+ if (this.length > max)
+ str += ' ... '
}
- return 0
+ return '<Buffer ' + str + '>'
+}
+
+Buffer.prototype.compare = function (b) {
+ if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
+ return Buffer.compare(this, b)
+}
+
+// `get` will be removed in Node 0.13+
+Buffer.prototype.get = function (offset) {
+ console.log('.get() is deprecated. Access using array indexes instead.')
+ return this.readUInt8(offset)
}
-// BUFFER INSTANCE METHODS
-// =======================
+// `set` will be removed in Node 0.13+
+Buffer.prototype.set = function (v, offset) {
+ console.log('.set() is deprecated. Access using array indexes instead.')
+ return this.writeUInt8(v, offset)
+}
function hexWrite (buf, string, offset, length) {
offset = Number(offset) || 0
@@ -226,14 +661,14 @@ function hexWrite (buf, string, offset, length) {
// must be an even number of digits
var strLen = string.length
- assert(strLen % 2 === 0, 'Invalid hex string')
+ if (strLen % 2 !== 0) throw new Error('Invalid hex string')
if (length > strLen / 2) {
length = strLen / 2
}
for (var i = 0; i < length; i++) {
var byte = parseInt(string.substr(i * 2, 2), 16)
- assert(!isNaN(byte), 'Invalid hex string')
+ if (isNaN(byte)) throw new Error('Invalid hex string')
buf[offset + i] = byte
}
return i
@@ -315,48 +750,7 @@ Buffer.prototype.write = function (string, offset, length, encoding) {
ret = utf16leWrite(this, string, offset, length)
break
default:
- throw new Error('Unknown encoding')
- }
- return ret
-}
-
-Buffer.prototype.toString = function (encoding, start, end) {
- var self = this
-
- encoding = String(encoding || 'utf8').toLowerCase()
- start = Number(start) || 0
- end = (end === undefined) ? self.length : Number(end)
-
- // Fastpath empty strings
- if (end === start)
- return ''
-
- var ret
- switch (encoding) {
- case 'hex':
- ret = hexSlice(self, start, end)
- break
- case 'utf8':
- case 'utf-8':
- ret = utf8Slice(self, start, end)
- break
- case 'ascii':
- ret = asciiSlice(self, start, end)
- break
- case 'binary':
- ret = binarySlice(self, start, end)
- break
- case 'base64':
- ret = base64Slice(self, start, end)
- break
- case 'ucs2':
- case 'ucs-2':
- case 'utf16le':
- case 'utf-16le':
- ret = utf16leSlice(self, start, end)
- break
- default:
- throw new Error('Unknown encoding')
+ throw new TypeError('Unknown encoding: ' + encoding)
}
return ret
}
@@ -368,52 +762,6 @@ Buffer.prototype.toJSON = function () {
}
}
-Buffer.prototype.equals = function (b) {
- assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
- return Buffer.compare(this, b) === 0
-}
-
-Buffer.prototype.compare = function (b) {
- assert(Buffer.isBuffer(b), 'Argument must be a Buffer')
- return Buffer.compare(this, b)
-}
-
-// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
-Buffer.prototype.copy = function (target, target_start, start, end) {
- var source = this
-
- if (!start) start = 0
- if (!end && end !== 0) end = this.length
- if (!target_start) target_start = 0
-
- // Copy 0 bytes; we're done
- if (end === start) return
- if (target.length === 0 || source.length === 0) return
-
- // Fatal error conditions
- assert(end >= start, 'sourceEnd < sourceStart')
- assert(target_start >= 0 && target_start < target.length,
- 'targetStart out of bounds')
- assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
- assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
-
- // Are we oob?
- if (end > this.length)
- end = this.length
- if (target.length - target_start < end - start)
- end = target.length - target_start + start
-
- var len = end - start
-
- if (len < 100 || !Buffer._useTypedArrays) {
- for (var i = 0; i < len; i++) {
- target[i + target_start] = this[i + start]
- }
- } else {
- target._set(this.subarray(start, start + len), target_start)
- }
-}
-
function base64Slice (buf, start, end) {
if (start === 0 && end === buf.length) {
return base64.fromByteArray(buf)
@@ -499,7 +847,7 @@ Buffer.prototype.slice = function (start, end) {
if (end < start)
end = start
- if (Buffer._useTypedArrays) {
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
return Buffer._augment(this.subarray(start, end))
} else {
var sliceLen = end - start
@@ -511,365 +859,275 @@ Buffer.prototype.slice = function (start, end) {
}
}
-// `get` will be removed in Node 0.13+
-Buffer.prototype.get = function (offset) {
- console.log('.get() is deprecated. Access using array indexes instead.')
- return this.readUInt8(offset)
-}
-
-// `set` will be removed in Node 0.13+
-Buffer.prototype.set = function (v, offset) {
- console.log('.set() is deprecated. Access using array indexes instead.')
- return this.writeUInt8(v, offset)
+/*
+ * Need to make sure that buffer isn't trying to write out of bounds.
+ */
+function checkOffset (offset, ext, length) {
+ if ((offset % 1) !== 0 || offset < 0)
+ throw new RangeError('offset is not uint')
+ if (offset + ext > length)
+ throw new RangeError('Trying to access beyond buffer length')
}
Buffer.prototype.readUInt8 = function (offset, noAssert) {
- if (!noAssert) {
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset < this.length, 'Trying to read beyond buffer length')
- }
-
- if (offset >= this.length)
- return
-
+ if (!noAssert)
+ checkOffset(offset, 1, this.length)
return this[offset]
}
-function readUInt16 (buf, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
- }
-
- var len = buf.length
- if (offset >= len)
- return
-
- var val
- if (littleEndian) {
- val = buf[offset]
- if (offset + 1 < len)
- val |= buf[offset + 1] << 8
- } else {
- val = buf[offset] << 8
- if (offset + 1 < len)
- val |= buf[offset + 1]
- }
- return val
-}
-
Buffer.prototype.readUInt16LE = function (offset, noAssert) {
- return readUInt16(this, offset, true, noAssert)
+ if (!noAssert)
+ checkOffset(offset, 2, this.length)
+ return this[offset] | (this[offset + 1] << 8)
}
Buffer.prototype.readUInt16BE = function (offset, noAssert) {
- return readUInt16(this, offset, false, noAssert)
-}
-
-function readUInt32 (buf, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
- }
-
- var len = buf.length
- if (offset >= len)
- return
-
- var val
- if (littleEndian) {
- if (offset + 2 < len)
- val = buf[offset + 2] << 16
- if (offset + 1 < len)
- val |= buf[offset + 1] << 8
- val |= buf[offset]
- if (offset + 3 < len)
- val = val + (buf[offset + 3] << 24 >>> 0)
- } else {
- if (offset + 1 < len)
- val = buf[offset + 1] << 16
- if (offset + 2 < len)
- val |= buf[offset + 2] << 8
- if (offset + 3 < len)
- val |= buf[offset + 3]
- val = val + (buf[offset] << 24 >>> 0)
- }
- return val
+ if (!noAssert)
+ checkOffset(offset, 2, this.length)
+ return (this[offset] << 8) | this[offset + 1]
}
Buffer.prototype.readUInt32LE = function (offset, noAssert) {
- return readUInt32(this, offset, true, noAssert)
-}
+ if (!noAssert)
+ checkOffset(offset, 4, this.length)
-Buffer.prototype.readUInt32BE = function (offset, noAssert) {
- return readUInt32(this, offset, false, noAssert)
+ return ((this[offset]) |
+ (this[offset + 1] << 8) |
+ (this[offset + 2] << 16)) +
+ (this[offset + 3] * 0x1000000)
}
-Buffer.prototype.readInt8 = function (offset, noAssert) {
- if (!noAssert) {
- assert(offset !== undefined && offset !== null,
- 'missing offset')
- assert(offset < this.length, 'Trying to read beyond buffer length')
- }
-
- if (offset >= this.length)
- return
+Buffer.prototype.readUInt32BE = function (offset, noAssert) {
+ if (!noAssert)
+ checkOffset(offset, 4, this.length)
- var neg = this[offset] & 0x80
- if (neg)
- return (0xff - this[offset] + 1) * -1
- else
- return this[offset]
+ return (this[offset] * 0x1000000) +
+ ((this[offset + 1] << 16) |
+ (this[offset + 2] << 8) |
+ this[offset + 3])
}
-function readInt16 (buf, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
- }
-
- var len = buf.length
- if (offset >= len)
- return
-
- var val = readUInt16(buf, offset, littleEndian, true)
- var neg = val & 0x8000
- if (neg)
- return (0xffff - val + 1) * -1
- else
- return val
+Buffer.prototype.readInt8 = function (offset, noAssert) {
+ if (!noAssert)
+ checkOffset(offset, 1, this.length)
+ if (!(this[offset] & 0x80))
+ return (this[offset])
+ return ((0xff - this[offset] + 1) * -1)
}
Buffer.prototype.readInt16LE = function (offset, noAssert) {
- return readInt16(this, offset, true, noAssert)
+ if (!noAssert)
+ checkOffset(offset, 2, this.length)
+ var val = this[offset] | (this[offset + 1] << 8)
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
}
Buffer.prototype.readInt16BE = function (offset, noAssert) {
- return readInt16(this, offset, false, noAssert)
-}
-
-function readInt32 (buf, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
- }
-
- var len = buf.length
- if (offset >= len)
- return
-
- var val = readUInt32(buf, offset, littleEndian, true)
- var neg = val & 0x80000000
- if (neg)
- return (0xffffffff - val + 1) * -1
- else
- return val
+ if (!noAssert)
+ checkOffset(offset, 2, this.length)
+ var val = this[offset + 1] | (this[offset] << 8)
+ return (val & 0x8000) ? val | 0xFFFF0000 : val
}
Buffer.prototype.readInt32LE = function (offset, noAssert) {
- return readInt32(this, offset, true, noAssert)
-}
+ if (!noAssert)
+ checkOffset(offset, 4, this.length)
-Buffer.prototype.readInt32BE = function (offset, noAssert) {
- return readInt32(this, offset, false, noAssert)
+ return (this[offset]) |
+ (this[offset + 1] << 8) |
+ (this[offset + 2] << 16) |
+ (this[offset + 3] << 24)
}
-function readFloat (buf, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
- }
+Buffer.prototype.readInt32BE = function (offset, noAssert) {
+ if (!noAssert)
+ checkOffset(offset, 4, this.length)
- return ieee754.read(buf, offset, littleEndian, 23, 4)
+ return (this[offset] << 24) |
+ (this[offset + 1] << 16) |
+ (this[offset + 2] << 8) |
+ (this[offset + 3])
}
Buffer.prototype.readFloatLE = function (offset, noAssert) {
- return readFloat(this, offset, true, noAssert)
+ if (!noAssert)
+ checkOffset(offset, 4, this.length)
+ return ieee754.read(this, offset, true, 23, 4)
}
Buffer.prototype.readFloatBE = function (offset, noAssert) {
- return readFloat(this, offset, false, noAssert)
-}
-
-function readDouble (buf, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
- }
-
- return ieee754.read(buf, offset, littleEndian, 52, 8)
+ if (!noAssert)
+ checkOffset(offset, 4, this.length)
+ return ieee754.read(this, offset, false, 23, 4)
}
Buffer.prototype.readDoubleLE = function (offset, noAssert) {
- return readDouble(this, offset, true, noAssert)
+ if (!noAssert)
+ checkOffset(offset, 8, this.length)
+ return ieee754.read(this, offset, true, 52, 8)
}
Buffer.prototype.readDoubleBE = function (offset, noAssert) {
- return readDouble(this, offset, false, noAssert)
+ if (!noAssert)
+ checkOffset(offset, 8, this.length)
+ return ieee754.read(this, offset, false, 52, 8)
}
-Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
- if (!noAssert) {
- assert(value !== undefined && value !== null, 'missing value')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset < this.length, 'trying to write beyond buffer length')
- verifuint(value, 0xff)
- }
-
- if (offset >= this.length) return
+function checkInt (buf, value, offset, ext, max, min) {
+ if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance')
+ if (value > max || value < min) throw new TypeError('value is out of bounds')
+ if (offset + ext > buf.length) throw new TypeError('index out of range')
+}
+Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert)
+ checkInt(this, value, offset, 1, 0xff, 0)
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
this[offset] = value
return offset + 1
}
-function writeUInt16 (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(value !== undefined && value !== null, 'missing value')
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
- verifuint(value, 0xffff)
- }
-
- var len = buf.length
- if (offset >= len)
- return
-
- for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
- buf[offset + i] =
- (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
- (littleEndian ? i : 1 - i) * 8
+function objectWriteUInt16 (buf, value, offset, littleEndian) {
+ if (value < 0) value = 0xffff + value + 1
+ for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) {
+ buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
+ (littleEndian ? i : 1 - i) * 8
}
- return offset + 2
}
Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
- return writeUInt16(this, value, offset, true, noAssert)
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert)
+ checkInt(this, value, offset, 2, 0xffff, 0)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = value
+ this[offset + 1] = (value >>> 8)
+ } else objectWriteUInt16(this, value, offset, true)
+ return offset + 2
}
Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
- return writeUInt16(this, value, offset, false, noAssert)
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert)
+ checkInt(this, value, offset, 2, 0xffff, 0)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = (value >>> 8)
+ this[offset + 1] = value
+ } else objectWriteUInt16(this, value, offset, false)
+ return offset + 2
}
-function writeUInt32 (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(value !== undefined && value !== null, 'missing value')
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
- verifuint(value, 0xffffffff)
- }
-
- var len = buf.length
- if (offset >= len)
- return
-
- for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
- buf[offset + i] =
- (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
+function objectWriteUInt32 (buf, value, offset, littleEndian) {
+ if (value < 0) value = 0xffffffff + value + 1
+ for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) {
+ buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
}
- return offset + 4
}
Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
- return writeUInt32(this, value, offset, true, noAssert)
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert)
+ checkInt(this, value, offset, 4, 0xffffffff, 0)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset + 3] = (value >>> 24)
+ this[offset + 2] = (value >>> 16)
+ this[offset + 1] = (value >>> 8)
+ this[offset] = value
+ } else objectWriteUInt32(this, value, offset, true)
+ return offset + 4
}
Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
- return writeUInt32(this, value, offset, false, noAssert)
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert)
+ checkInt(this, value, offset, 4, 0xffffffff, 0)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = (value >>> 24)
+ this[offset + 1] = (value >>> 16)
+ this[offset + 2] = (value >>> 8)
+ this[offset + 3] = value
+ } else objectWriteUInt32(this, value, offset, false)
+ return offset + 4
}
Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
- if (!noAssert) {
- assert(value !== undefined && value !== null, 'missing value')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset < this.length, 'Trying to write beyond buffer length')
- verifsint(value, 0x7f, -0x80)
- }
-
- if (offset >= this.length)
- return
-
- if (value >= 0)
- this.writeUInt8(value, offset, noAssert)
- else
- this.writeUInt8(0xff + value + 1, offset, noAssert)
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert)
+ checkInt(this, value, offset, 1, 0x7f, -0x80)
+ if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
+ if (value < 0) value = 0xff + value + 1
+ this[offset] = value
return offset + 1
}
-function writeInt16 (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(value !== undefined && value !== null, 'missing value')
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
- verifsint(value, 0x7fff, -0x8000)
- }
-
- var len = buf.length
- if (offset >= len)
- return
-
- if (value >= 0)
- writeUInt16(buf, value, offset, littleEndian, noAssert)
- else
- writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
- return offset + 2
-}
-
Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
- return writeInt16(this, value, offset, true, noAssert)
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert)
+ checkInt(this, value, offset, 2, 0x7fff, -0x8000)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = value
+ this[offset + 1] = (value >>> 8)
+ } else objectWriteUInt16(this, value, offset, true)
+ return offset + 2
}
Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
- return writeInt16(this, value, offset, false, noAssert)
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert)
+ checkInt(this, value, offset, 2, 0x7fff, -0x8000)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = (value >>> 8)
+ this[offset + 1] = value
+ } else objectWriteUInt16(this, value, offset, false)
+ return offset + 2
}
-function writeInt32 (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(value !== undefined && value !== null, 'missing value')
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
- verifsint(value, 0x7fffffff, -0x80000000)
- }
-
- var len = buf.length
- if (offset >= len)
- return
-
- if (value >= 0)
- writeUInt32(buf, value, offset, littleEndian, noAssert)
- else
- writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
+Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert)
+ checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = value
+ this[offset + 1] = (value >>> 8)
+ this[offset + 2] = (value >>> 16)
+ this[offset + 3] = (value >>> 24)
+ } else objectWriteUInt32(this, value, offset, true)
return offset + 4
}
-Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
- return writeInt32(this, value, offset, true, noAssert)
+Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
+ value = +value
+ offset = offset >>> 0
+ if (!noAssert)
+ checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
+ if (value < 0) value = 0xffffffff + value + 1
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
+ this[offset] = (value >>> 24)
+ this[offset + 1] = (value >>> 16)
+ this[offset + 2] = (value >>> 8)
+ this[offset + 3] = value
+ } else objectWriteUInt32(this, value, offset, false)
+ return offset + 4
}
-Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
- return writeInt32(this, value, offset, false, noAssert)
+function checkIEEE754 (buf, value, offset, ext, max, min) {
+ if (value > max || value < min) throw new TypeError('value is out of bounds')
+ if (offset + ext > buf.length) throw new TypeError('index out of range')
}
function writeFloat (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(value !== undefined && value !== null, 'missing value')
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
- verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
- }
-
- var len = buf.length
- if (offset >= len)
- return
-
+ if (!noAssert)
+ checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
ieee754.write(buf, value, offset, littleEndian, 23, 4)
return offset + 4
}
@@ -883,19 +1141,8 @@ Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
}
function writeDouble (buf, value, offset, littleEndian, noAssert) {
- if (!noAssert) {
- assert(value !== undefined && value !== null, 'missing value')
- assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
- assert(offset !== undefined && offset !== null, 'missing offset')
- assert(offset + 7 < buf.length,
- 'Trying to write beyond buffer length')
- verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
- }
-
- var len = buf.length
- if (offset >= len)
- return
-
+ if (!noAssert)
+ checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
ieee754.write(buf, value, offset, littleEndian, 52, 8)
return offset + 8
}
@@ -908,20 +1155,56 @@ Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
return writeDouble(this, value, offset, false, noAssert)
}
+// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
+Buffer.prototype.copy = function (target, target_start, start, end) {
+ var source = this
+
+ if (!start) start = 0
+ if (!end && end !== 0) end = this.length
+ if (!target_start) target_start = 0
+
+ // Copy 0 bytes; we're done
+ if (end === start) return
+ if (target.length === 0 || source.length === 0) return
+
+ // Fatal error conditions
+ if (end < start) throw new TypeError('sourceEnd < sourceStart')
+ if (target_start < 0 || target_start >= target.length)
+ throw new TypeError('targetStart out of bounds')
+ if (start < 0 || start >= source.length) throw new TypeError('sourceStart out of bounds')
+ if (end < 0 || end > source.length) throw new TypeError('sourceEnd out of bounds')
+
+ // Are we oob?
+ if (end > this.length)
+ end = this.length
+ if (target.length - target_start < end - start)
+ end = target.length - target_start + start
+
+ var len = end - start
+
+ if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
+ for (var i = 0; i < len; i++) {
+ target[i + target_start] = this[i + start]
+ }
+ } else {
+ target._set(this.subarray(start, start + len), target_start)
+ }
+}
+
// fill(value, start=0, end=buffer.length)
Buffer.prototype.fill = function (value, start, end) {
if (!value) value = 0
if (!start) start = 0
if (!end) end = this.length
- assert(end >= start, 'end < start')
+ if (end < start) throw new TypeError('end < start')
// Fill 0 bytes; we're done
if (end === start) return
if (this.length === 0) return
- assert(start >= 0 && start < this.length, 'start out of bounds')
- assert(end >= 0 && end <= this.length, 'end out of bounds')
+ if (start < 0 || start >= this.length) throw new TypeError('start out of bounds')
+ if (end < 0 || end > this.length) throw new TypeError('end out of bounds')
var i
if (typeof value === 'number') {
@@ -939,26 +1222,13 @@ Buffer.prototype.fill = function (value, start, end) {
return this
}
-Buffer.prototype.inspect = function () {
- var out = []
- var len = this.length
- for (var i = 0; i < len; i++) {
- out[i] = toHex(this[i])
- if (i === exports.INSPECT_MAX_BYTES) {
- out[i + 1] = '...'
- break
- }
- }
- return '<Buffer ' + out.join(' ') + '>'
-}
-
/**
* Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance.
* Added in Node 0.12. Only available in browsers that support ArrayBuffer.
*/
Buffer.prototype.toArrayBuffer = function () {
if (typeof Uint8Array !== 'undefined') {
- if (Buffer._useTypedArrays) {
+ if (Buffer.TYPED_ARRAY_SUPPORT) {
return (new Buffer(this)).buffer
} else {
var buf = new Uint8Array(this.length)
@@ -968,7 +1238,7 @@ Buffer.prototype.toArrayBuffer = function () {
return buf.buffer
}
} else {
- throw new Error('Buffer.toArrayBuffer not supported in this browser')
+ throw new TypeError('Buffer.toArrayBuffer not supported in this browser')
}
}
@@ -981,6 +1251,7 @@ var BP = Buffer.prototype
* Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods
*/
Buffer._augment = function (arr) {
+ arr.constructor = Buffer
arr._isBuffer = true
// save reference to original Uint8Array get/set methods before overwriting
@@ -1051,12 +1322,6 @@ function stringtrim (str) {
return str.replace(/^\s+|\s+$/g, '')
}
-function isArray (subject) {
- return (Array.isArray || function (subject) {
- return Object.prototype.toString.call(subject) === '[object Array]'
- })(subject)
-}
-
function isArrayish (subject) {
return isArray(subject) || Buffer.isBuffer(subject) ||
subject && typeof subject === 'object' &&
@@ -1130,36 +1395,7 @@ function decodeUtf8Char (str) {
}
}
-/*
- * We have to make sure that the value is a valid integer. This means that it
- * is non-negative. It has no fractional component and that it does not
- * exceed the maximum allowed value.
- */
-function verifuint (value, max) {
- assert(typeof value === 'number', 'cannot write a non-number as a number')
- assert(value >= 0, 'specified a negative value for writing an unsigned value')
- assert(value <= max, 'value is larger than maximum value for type')
- assert(Math.floor(value) === value, 'value has a fractional component')
-}
-
-function verifsint (value, max, min) {
- assert(typeof value === 'number', 'cannot write a non-number as a number')
- assert(value <= max, 'value larger than maximum allowed value')
- assert(value >= min, 'value smaller than minimum allowed value')
- assert(Math.floor(value) === value, 'value has a fractional component')
-}
-
-function verifIEEE754 (value, max, min) {
- assert(typeof value === 'number', 'cannot write a non-number as a number')
- assert(value <= max, 'value larger than maximum allowed value')
- assert(value >= min, 'value smaller than minimum allowed value')
-}
-
-function assert (test, message) {
- if (!test) throw new Error(message || 'Failed assertion')
-}
-
-},{"base64-js":2,"ieee754":3}],2:[function(_dereq_,module,exports){
+},{"base64-js":3,"ieee754":4,"is-array":5}],3:[function(_dereq_,module,exports){
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
;(function (exports) {
@@ -1281,7 +1517,7 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
exports.fromByteArray = uint8ToBase64
}(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
-},{}],3:[function(_dereq_,module,exports){
+},{}],4:[function(_dereq_,module,exports){
exports.read = function(buffer, offset, isLE, mLen, nBytes) {
var e, m,
eLen = nBytes * 8 - mLen - 1,
@@ -1367,7 +1603,42 @@ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
buffer[offset + i - d] |= s * 128;
};
-},{}],4:[function(_dereq_,module,exports){
+},{}],5:[function(_dereq_,module,exports){
+
+/**
+ * isArray
+ */
+
+var isArray = Array.isArray;
+
+/**
+ * toString
+ */
+
+var str = Object.prototype.toString;
+
+/**
+ * Whether or not the given `val`
+ * is an array.
+ *
+ * example:
+ *
+ * isArray([]);
+ * // > true
+ * isArray(arguments);
+ * // > false
+ * isArray('');
+ * // > false
+ *
+ * @param {mixed} val
+ * @return {bool}
+ */
+
+module.exports = isArray || function (val) {
+ return !! val && '[object Array]' == str.call(val);
+};
+
+},{}],6:[function(_dereq_,module,exports){
(function (process){
// Copyright Joyent, Inc. and other Node contributors.
//
@@ -1594,8 +1865,8 @@ var substr = 'ab'.substr(-1) === 'b'
}
;
-}).call(this,_dereq_("FWaASH"))
-},{"FWaASH":5}],5:[function(_dereq_,module,exports){
+}).call(this,_dereq_('_process'))
+},{"_process":7}],7:[function(_dereq_,module,exports){
// shim for using process in browser
var process = module.exports = {};
@@ -1603,6 +1874,8 @@ var process = module.exports = {};
process.nextTick = (function () {
var canSetImmediate = typeof window !== 'undefined'
&& window.setImmediate;
+ var canMutationObserver = typeof window !== 'undefined'
+ && window.MutationObserver;
var canPost = typeof window !== 'undefined'
&& window.postMessage && window.addEventListener
;
@@ -1611,8 +1884,29 @@ process.nextTick = (function () {
return function (f) { return window.setImmediate(f) };
}
+ var queue = [];
+
+ if (canMutationObserver) {
+ var hiddenDiv = document.createElement("div");
+ var observer = new MutationObserver(function () {
+ var queueList = queue.slice();
+ queue.length = 0;
+ queueList.forEach(function (fn) {
+ fn();
+ });
+ });
+
+ observer.observe(hiddenDiv, { attributes: true });
+
+ return function nextTick(fn) {
+ if (!queue.length) {
+ hiddenDiv.setAttribute('yes', 'no');
+ }
+ queue.push(fn);
+ };
+ }
+
if (canPost) {
- var queue = [];
window.addEventListener('message', function (ev) {
var source = ev.source;
if ((source === window || source === null) && ev.data === 'process-tick') {
@@ -1652,7 +1946,7 @@ process.emit = noop;
process.binding = function (name) {
throw new Error('process.binding is not supported');
-}
+};
// TODO(shtylman)
process.cwd = function () { return '/' };
@@ -1660,7 +1954,35 @@ process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
-},{}],6:[function(_dereq_,module,exports){
+},{}],8:[function(_dereq_,module,exports){
+var Base62 = (function (my) {
+ my.chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
+
+ my.encode = function(i){
+ if (i === 0) {return '0'}
+ var s = ''
+ while (i > 0) {
+ s = this.chars[i % 62] + s
+ i = Math.floor(i/62)
+ }
+ return s
+ };
+ my.decode = function(a,b,c,d){
+ for (
+ b = c = (
+ a === (/\W|_|^$/.test(a += "") || a)
+ ) - 1;
+ d = a.charCodeAt(c++);
+ )
+ b = b * 62 + d - [, 48, 29, 87][d >> 5];
+ return b
+ };
+
+ return my;
+}({}));
+
+module.exports = Base62
+},{}],9:[function(_dereq_,module,exports){
/*
Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
@@ -1698,18 +2020,23 @@ process.chdir = function (dir) {
throwError: true, generateStatement: true, peek: true,
parseAssignmentExpression: true, parseBlock: true,
parseClassExpression: true, parseClassDeclaration: true, parseExpression: true,
+parseDeclareClass: true, parseDeclareFunction: true,
+parseDeclareModule: true, parseDeclareVariable: true,
parseForStatement: true,
parseFunctionDeclaration: true, parseFunctionExpression: true,
parseFunctionSourceElements: true, parseVariableIdentifier: true,
-parseImportSpecifier: true,
+parseImportSpecifier: true, parseInterface: true,
parseLeftHandSideExpression: true, parseParams: true, validateParam: true,
parseSpreadOrAssignmentExpression: true,
-parseStatement: true, parseSourceElement: true, parseModuleBlock: true, parseConciseBody: true,
+parseStatement: true, parseSourceElement: true, parseConciseBody: true,
advanceXJSChild: true, isXJSIdentifierStart: true, isXJSIdentifierPart: true,
scanXJSStringLiteral: true, scanXJSIdentifier: true,
parseXJSAttributeValue: true, parseXJSChild: true, parseXJSElement: true, parseXJSExpressionContainer: true, parseXJSEmptyExpression: true,
-parseTypeAnnotation: true, parseTypeAnnotatableIdentifier: true,
-parseYieldExpression: true
+parseFunctionTypeParam: true,
+parsePrimaryType: true,
+parseTypeAlias: true,
+parseType: true, parseTypeAnnotatableIdentifier: true, parseTypeAnnotation: true,
+parseYieldExpression: true, parseAwaitExpression: true
*/
(function (root, factory) {
@@ -1788,24 +2115,32 @@ parseYieldExpression: true
'<=', '<', '>', '!=', '!=='];
Syntax = {
+ AnyTypeAnnotation: 'AnyTypeAnnotation',
ArrayExpression: 'ArrayExpression',
ArrayPattern: 'ArrayPattern',
+ ArrayTypeAnnotation: 'ArrayTypeAnnotation',
ArrowFunctionExpression: 'ArrowFunctionExpression',
AssignmentExpression: 'AssignmentExpression',
BinaryExpression: 'BinaryExpression',
BlockStatement: 'BlockStatement',
+ BooleanTypeAnnotation: 'BooleanTypeAnnotation',
BreakStatement: 'BreakStatement',
CallExpression: 'CallExpression',
CatchClause: 'CatchClause',
ClassBody: 'ClassBody',
ClassDeclaration: 'ClassDeclaration',
ClassExpression: 'ClassExpression',
+ ClassImplements: 'ClassImplements',
ClassProperty: 'ClassProperty',
ComprehensionBlock: 'ComprehensionBlock',
ComprehensionExpression: 'ComprehensionExpression',
ConditionalExpression: 'ConditionalExpression',
ContinueStatement: 'ContinueStatement',
DebuggerStatement: 'DebuggerStatement',
+ DeclareClass: 'DeclareClass',
+ DeclareFunction: 'DeclareFunction',
+ DeclareModule: 'DeclareModule',
+ DeclareVariable: 'DeclareVariable',
DoWhileStatement: 'DoWhileStatement',
EmptyStatement: 'EmptyStatement',
ExportDeclaration: 'ExportDeclaration',
@@ -1817,29 +2152,42 @@ parseYieldExpression: true
ForStatement: 'ForStatement',
FunctionDeclaration: 'FunctionDeclaration',
FunctionExpression: 'FunctionExpression',
+ FunctionTypeAnnotation: 'FunctionTypeAnnotation',
+ FunctionTypeParam: 'FunctionTypeParam',
+ GenericTypeAnnotation: 'GenericTypeAnnotation',
Identifier: 'Identifier',
IfStatement: 'IfStatement',
ImportDeclaration: 'ImportDeclaration',
+ ImportDefaultSpecifier: 'ImportDefaultSpecifier',
+ ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
ImportSpecifier: 'ImportSpecifier',
+ InterfaceDeclaration: 'InterfaceDeclaration',
+ InterfaceExtends: 'InterfaceExtends',
+ IntersectionTypeAnnotation: 'IntersectionTypeAnnotation',
LabeledStatement: 'LabeledStatement',
Literal: 'Literal',
LogicalExpression: 'LogicalExpression',
MemberExpression: 'MemberExpression',
MethodDefinition: 'MethodDefinition',
- ModuleDeclaration: 'ModuleDeclaration',
+ ModuleSpecifier: 'ModuleSpecifier',
NewExpression: 'NewExpression',
+ NullableTypeAnnotation: 'NullableTypeAnnotation',
+ NumberTypeAnnotation: 'NumberTypeAnnotation',
ObjectExpression: 'ObjectExpression',
ObjectPattern: 'ObjectPattern',
ObjectTypeAnnotation: 'ObjectTypeAnnotation',
- OptionalParameter: 'OptionalParameter',
- ParametricTypeAnnotation: 'ParametricTypeAnnotation',
- ParametricallyTypedIdentifier: 'ParametricallyTypedIdentifier',
+ ObjectTypeCallProperty: 'ObjectTypeCallProperty',
+ ObjectTypeIndexer: 'ObjectTypeIndexer',
+ ObjectTypeProperty: 'ObjectTypeProperty',
Program: 'Program',
Property: 'Property',
+ QualifiedTypeIdentifier: 'QualifiedTypeIdentifier',
ReturnStatement: 'ReturnStatement',
SequenceExpression: 'SequenceExpression',
SpreadElement: 'SpreadElement',
SpreadProperty: 'SpreadProperty',
+ StringLiteralTypeAnnotation: 'StringLiteralTypeAnnotation',
+ StringTypeAnnotation: 'StringTypeAnnotation',
SwitchCase: 'SwitchCase',
SwitchStatement: 'SwitchStatement',
TaggedTemplateExpression: 'TaggedTemplateExpression',
@@ -1847,10 +2195,15 @@ parseYieldExpression: true
TemplateLiteral: 'TemplateLiteral',
ThisExpression: 'ThisExpression',
ThrowStatement: 'ThrowStatement',
+ TupleTypeAnnotation: 'TupleTypeAnnotation',
TryStatement: 'TryStatement',
- TypeAnnotatedIdentifier: 'TypeAnnotatedIdentifier',
+ TypeAlias: 'TypeAlias',
TypeAnnotation: 'TypeAnnotation',
+ TypeofTypeAnnotation: 'TypeofTypeAnnotation',
+ TypeParameterDeclaration: 'TypeParameterDeclaration',
+ TypeParameterInstantiation: 'TypeParameterInstantiation',
UnaryExpression: 'UnaryExpression',
+ UnionTypeAnnotation: 'UnionTypeAnnotation',
UpdateExpression: 'UpdateExpression',
VariableDeclaration: 'VariableDeclaration',
VariableDeclarator: 'VariableDeclarator',
@@ -1868,7 +2221,8 @@ parseYieldExpression: true
XJSAttribute: 'XJSAttribute',
XJSSpreadAttribute: 'XJSSpreadAttribute',
XJSText: 'XJSText',
- YieldExpression: 'YieldExpression'
+ YieldExpression: 'YieldExpression',
+ AwaitExpression: 'AwaitExpression'
};
PropertyKind = {
@@ -1905,7 +2259,6 @@ parseYieldExpression: true
IllegalBreak: 'Illegal break statement',
IllegalDuplicateClassProperty: 'Illegal duplicate property in class definition',
IllegalReturn: 'Illegal return statement',
- IllegalYield: 'Illegal yield expression',
IllegalSpread: 'Illegal spread element',
StrictModeWith: 'Strict mode code may not include a with statement',
StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
@@ -1928,23 +2281,29 @@ parseYieldExpression: true
StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
StrictReservedWord: 'Use of future reserved word in strict mode',
- NewlineAfterModule: 'Illegal newline after module',
- NoFromAfterImport: 'Missing from after import',
+ MissingFromClause: 'Missing from clause',
+ NoAsAfterImportNamespace: 'Missing as after import *',
InvalidModuleSpecifier: 'Invalid module specifier',
- NestedModule: 'Module declaration can not be nested',
NoUnintializedConst: 'Const must be initialized',
ComprehensionRequiresBlock: 'Comprehension must have at least one block',
ComprehensionError: 'Comprehension Error',
EachNotAllowed: 'Each is not supported',
InvalidXJSAttributeValue: 'XJS value should be either an expression or a quoted XJS text',
ExpectedXJSClosingTag: 'Expected corresponding XJS closing tag for %0',
- AdjacentXJSElements: 'Adjacent XJS elements must be wrapped in an enclosing tag'
+ AdjacentXJSElements: 'Adjacent XJS elements must be wrapped in an enclosing tag',
+ ConfusedAboutFunctionType: 'Unexpected token =>. It looks like ' +
+ 'you are trying to write a function type, but you ended up ' +
+ 'writing a grouped type followed by an =>, which is a syntax ' +
+ 'error. Remember, function type parameters are named so function ' +
+ 'types look like (name1: type1, name2: type2) => returnType. You ' +
+ 'probably wrote (type1) => returnType'
};
// See also tools/generate-unicode-regex.py.
Regex = {
NonAsciiIdentifierStart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58\u0c59\u0c60\u0c61\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d60\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191c\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19c1-\u19c7\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua697\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa80-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
- NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]')
+ NonAsciiIdentifierPart: new RegExp('[\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0300-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u0483-\u0487\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u05d0-\u05ea\u05f0-\u05f2\u0610-\u061a\u0620-\u0669\u066e-\u06d3\u06d5-\u06dc\u06df-\u06e8\u06ea-\u06fc\u06ff\u0710-\u074a\u074d-\u07b1\u07c0-\u07f5\u07fa\u0800-\u082d\u0840-\u085b\u08a0\u08a2-\u08ac\u08e4-\u08fe\u0900-\u0963\u0966-\u096f\u0971-\u0977\u0979-\u097f\u0981-\u0983\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bc-\u09c4\u09c7\u09c8\u09cb-\u09ce\u09d7\u09dc\u09dd\u09df-\u09e3\u09e6-\u09f1\u0a01-\u0a03\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a59-\u0a5c\u0a5e\u0a66-\u0a75\u0a81-\u0a83\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abc-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ad0\u0ae0-\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3c-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b5c\u0b5d\u0b5f-\u0b63\u0b66-\u0b6f\u0b71\u0b82\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd0\u0bd7\u0be6-\u0bef\u0c01-\u0c03\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c58\u0c59\u0c60-\u0c63\u0c66-\u0c6f\u0c82\u0c83\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbc-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0cde\u0ce0-\u0ce3\u0ce6-\u0cef\u0cf1\u0cf2\u0d02\u0d03\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d-\u0d44\u0d46-\u0d48\u0d4a-\u0d4e\u0d57\u0d60-\u0d63\u0d66-\u0d6f\u0d7a-\u0d7f\u0d82\u0d83\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0df2\u0df3\u0e01-\u0e3a\u0e40-\u0e4e\u0e50-\u0e59\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb9\u0ebb-\u0ebd\u0ec0-\u0ec4\u0ec6\u0ec8-\u0ecd\u0ed0-\u0ed9\u0edc-\u0edf\u0f00\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e-\u0f47\u0f49-\u0f6c\u0f71-\u0f84\u0f86-\u0f97\u0f99-\u0fbc\u0fc6\u1000-\u1049\u1050-\u109d\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u135d-\u135f\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f0\u1700-\u170c\u170e-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176c\u176e-\u1770\u1772\u1773\u1780-\u17d3\u17d7\u17dc\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u1820-\u1877\u1880-\u18aa\u18b0-\u18f5\u1900-\u191c\u1920-\u192b\u1930-\u193b\u1946-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u19d0-\u19d9\u1a00-\u1a1b\u1a20-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1aa7\u1b00-\u1b4b\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1bf3\u1c00-\u1c37\u1c40-\u1c49\u1c4d-\u1c7d\u1cd0-\u1cd2\u1cd4-\u1cf6\u1d00-\u1de6\u1dfc-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u200c\u200d\u203f\u2040\u2054\u2071\u207f\u2090-\u209c\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d7f-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2de0-\u2dff\u2e2f\u3005-\u3007\u3021-\u302f\u3031-\u3035\u3038-\u303c\u3041-\u3096\u3099\u309a\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fcc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua62b\ua640-\ua66f\ua674-\ua67d\ua67f-\ua697\ua69f-\ua6f1\ua717-\ua71f\ua722-\ua788\ua78b-\ua78e\ua790-\ua793\ua7a0-\ua7aa\ua7f8-\ua827\ua840-\ua873\ua880-\ua8c4\ua8d0-\ua8d9\ua8e0-\ua8f7\ua8fb\ua900-\ua92d\ua930-\ua953\ua960-\ua97c\ua980-\ua9c0\ua9cf-\ua9d9\uaa00-\uaa36\uaa40-\uaa4d\uaa50-\uaa59\uaa60-\uaa76\uaa7a\uaa7b\uaa80-\uaac2\uaadb-\uaadd\uaae0-\uaaef\uaaf2-\uaaf6\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uabc0-\uabea\uabec\uabed\uabf0-\uabf9\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe00-\ufe0f\ufe20-\ufe26\ufe33\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]'),
+ LeadingZeros: new RegExp('^0+(?!$)')
};
// Ensure the condition is true, otherwise throw an error.
@@ -2106,14 +2465,16 @@ parseYieldExpression: true
}
} else if (blockComment) {
if (isLineTerminator(ch)) {
- if (ch === 13 && source.charCodeAt(index + 1) === 10) {
+ if (ch === 13) {
++index;
}
- ++lineNumber;
- ++index;
- lineStart = index;
- if (index >= length) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
+ if (ch !== 13 || source.charCodeAt(index) === 10) {
+ ++lineNumber;
+ ++index;
+ lineStart = index;
+ if (index >= length) {
+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
+ }
}
} else {
ch = source.charCodeAt(index++);
@@ -2461,7 +2822,9 @@ parseYieldExpression: true
// Other 2-character punctuators: ++ -- << >> && ||
- if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0)) {
+ // Don't match these tokens if we're in a type, since they never can
+ // occur and can mess up types like Map<string, Array<string>>
+ if (ch1 === ch2 && ('+-<>&|'.indexOf(ch1) >= 0) && !state.inType) {
index += 2;
return {
type: Token.Punctuator,
@@ -2769,6 +3132,7 @@ parseYieldExpression: true
if (ch === '\r' && source[index] === '\n') {
++index;
}
+ lineStart = index;
}
} else if (isLineTerminator(ch.charCodeAt(0))) {
break;
@@ -2884,12 +3248,14 @@ parseYieldExpression: true
if (ch === '\r' && source[index] === '\n') {
++index;
}
+ lineStart = index;
}
} else if (isLineTerminator(ch.charCodeAt(0))) {
++lineNumber;
if (ch === '\r' && source[index] === '\n') {
++index;
}
+ lineStart = index;
cooked += '\n';
} else {
cooked += ch;
@@ -2934,7 +3300,7 @@ parseYieldExpression: true
}
function scanRegExp() {
- var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false;
+ var str, ch, start, pattern, flags, value, classMarker = false, restore, terminated = false, tmp;
lookahead = null;
skipComment();
@@ -3010,19 +3376,43 @@ parseYieldExpression: true
}
}
+ tmp = pattern;
+ if (flags.indexOf('u') >= 0) {
+ // Replace each astral symbol and every Unicode code point
+ // escape sequence that represents such a symbol with a single
+ // ASCII symbol to avoid throwing on regular expressions that
+ // are only valid in combination with the `/u` flag.
+ tmp = tmp
+ .replace(/\\u\{([0-9a-fA-F]{5,6})\}/g, 'x')
+ .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, 'x');
+ }
+
+ // First, detect invalid regular expressions.
try {
- value = new RegExp(pattern, flags);
+ value = new RegExp(tmp);
} catch (e) {
throwError({}, Messages.InvalidRegExp);
}
- peek();
+ // Return a regular expression object for this pattern-flag pair, or
+ // `null` in case the current environment doesn't support the flags it
+ // uses.
+ try {
+ value = new RegExp(pattern, flags);
+ } catch (exception) {
+ value = null;
+ }
+ peek();
if (extra.tokenize) {
return {
type: Token.RegularExpression,
value: value,
+ regex: {
+ pattern: pattern,
+ flags: flags
+ },
lineNumber: lineNumber,
lineStart: lineStart,
range: [start, index]
@@ -3031,6 +3421,10 @@ parseYieldExpression: true
return {
literal: str,
value: value,
+ regex: {
+ pattern: pattern,
+ flags: flags
+ },
range: [start, index]
};
}
@@ -3225,6 +3619,13 @@ parseYieldExpression: true
return result;
}
+ function rewind(token) {
+ index = token.range[0];
+ lineNumber = token.lineNumber;
+ lineStart = token.lineStart;
+ lookahead = token;
+ }
+
function markerCreate() {
if (!extra.loc && !extra.range) {
return undefined;
@@ -3240,6 +3641,57 @@ parseYieldExpression: true
return {offset: index, line: lineNumber, col: index - lineStart};
}
+ function processComment(node) {
+ var lastChild,
+ trailingComments,
+ bottomRight = extra.bottomRightStack,
+ last = bottomRight[bottomRight.length - 1];
+
+ if (node.type === Syntax.Program) {
+ if (node.body.length > 0) {
+ return;
+ }
+ }
+
+ if (extra.trailingComments.length > 0) {
+ if (extra.trailingComments[0].range[0] >= node.range[1]) {
+ trailingComments = extra.trailingComments;
+ extra.trailingComments = [];
+ } else {
+ extra.trailingComments.length = 0;
+ }
+ } else {
+ if (last && last.trailingComments && last.trailingComments[0].range[0] >= node.range[1]) {
+ trailingComments = last.trailingComments;
+ delete last.trailingComments;
+ }
+ }
+
+ // Eating the stack.
+ if (last) {
+ while (last && last.range[0] >= node.range[0]) {
+ lastChild = last;
+ last = bottomRight.pop();
+ }
+ }
+
+ if (lastChild) {
+ if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) {
+ node.leadingComments = lastChild.leadingComments;
+ delete lastChild.leadingComments;
+ }
+ } else if (extra.leadingComments.length > 0 && extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) {
+ node.leadingComments = extra.leadingComments;
+ extra.leadingComments = [];
+ }
+
+ if (trailingComments) {
+ node.trailingComments = trailingComments;
+ }
+
+ bottomRight.push(node);
+ }
+
function markerApply(marker, node) {
if (extra.range) {
node.range = [marker.offset, index];
@@ -3257,6 +3709,9 @@ parseYieldExpression: true
};
node = delegate.postProcess(node);
}
+ if (extra.attachComment) {
+ processComment(node);
+ }
return node;
}
@@ -3398,8 +3853,8 @@ parseYieldExpression: true
},
createFunctionDeclaration: function (id, params, defaults, body, rest, generator, expression,
- returnType, parametricType) {
- return {
+ isAsync, returnType, typeParameters) {
+ var funDecl = {
type: Syntax.FunctionDeclaration,
id: id,
params: params,
@@ -3409,13 +3864,19 @@ parseYieldExpression: true
generator: generator,
expression: expression,
returnType: returnType,
- parametricType: parametricType
+ typeParameters: typeParameters
};
+
+ if (isAsync) {
+ funDecl.async = true;
+ }
+
+ return funDecl;
},
createFunctionExpression: function (id, params, defaults, body, rest, generator, expression,
- returnType, parametricType) {
- return {
+ isAsync, returnType, typeParameters) {
+ var funExpr = {
type: Syntax.FunctionExpression,
id: id,
params: params,
@@ -3425,8 +3886,14 @@ parseYieldExpression: true
generator: generator,
expression: expression,
returnType: returnType,
- parametricType: parametricType
+ typeParameters: typeParameters
};
+
+ if (isAsync) {
+ funExpr.async = true;
+ }
+
+ return funExpr;
},
createIdentifier: function (name) {
@@ -3438,25 +3905,110 @@ parseYieldExpression: true
// are added later (like 'loc' and 'range'). This just helps
// keep the shape of Identifier nodes consistent with everything
// else.
- typeAnnotation: undefined
+ typeAnnotation: undefined,
+ optional: undefined
};
},
- createTypeAnnotation: function (typeIdentifier, parametricType, params, returnType, nullable) {
+ createTypeAnnotation: function (typeAnnotation) {
return {
type: Syntax.TypeAnnotation,
- id: typeIdentifier,
- parametricType: parametricType,
+ typeAnnotation: typeAnnotation
+ };
+ },
+
+ createFunctionTypeAnnotation: function (params, returnType, rest, typeParameters) {
+ return {
+ type: Syntax.FunctionTypeAnnotation,
params: params,
returnType: returnType,
- nullable: nullable
+ rest: rest,
+ typeParameters: typeParameters
+ };
+ },
+
+ createFunctionTypeParam: function (name, typeAnnotation, optional) {
+ return {
+ type: Syntax.FunctionTypeParam,
+ name: name,
+ typeAnnotation: typeAnnotation,
+ optional: optional
+ };
+ },
+
+ createNullableTypeAnnotation: function (typeAnnotation) {
+ return {
+ type: Syntax.NullableTypeAnnotation,
+ typeAnnotation: typeAnnotation
+ };
+ },
+
+ createArrayTypeAnnotation: function (elementType) {
+ return {
+ type: Syntax.ArrayTypeAnnotation,
+ elementType: elementType
+ };
+ },
+
+ createGenericTypeAnnotation: function (id, typeParameters) {
+ return {
+ type: Syntax.GenericTypeAnnotation,
+ id: id,
+ typeParameters: typeParameters
+ };
+ },
+
+ createQualifiedTypeIdentifier: function (qualification, id) {
+ return {
+ type: Syntax.QualifiedTypeIdentifier,
+ qualification: qualification,
+ id: id
};
},
- createParametricTypeAnnotation: function (parametricTypes) {
+ createTypeParameterDeclaration: function (params) {
return {
- type: Syntax.ParametricTypeAnnotation,
- params: parametricTypes
+ type: Syntax.TypeParameterDeclaration,
+ params: params
+ };
+ },
+
+ createTypeParameterInstantiation: function (params) {
+ return {
+ type: Syntax.TypeParameterInstantiation,
+ params: params
+ };
+ },
+
+ createAnyTypeAnnotation: function () {
+ return {
+ type: Syntax.AnyTypeAnnotation
+ };
+ },
+
+ createBooleanTypeAnnotation: function () {
+ return {
+ type: Syntax.BooleanTypeAnnotation
+ };
+ },
+
+ createNumberTypeAnnotation: function () {
+ return {
+ type: Syntax.NumberTypeAnnotation
+ };
+ },
+
+ createStringTypeAnnotation: function () {
+ return {
+ type: Syntax.StringTypeAnnotation
+ };
+ },
+
+ createStringLiteralTypeAnnotation: function (token) {
+ return {
+ type: Syntax.StringLiteralTypeAnnotation,
+ value: token.value,
+ raw: source.slice(token.range[0], token.range[1])
};
},
@@ -3466,25 +4018,117 @@ parseYieldExpression: true
};
},
- createObjectTypeAnnotation: function (properties) {
+ createTypeofTypeAnnotation: function (argument) {
+ return {
+ type: Syntax.TypeofTypeAnnotation,
+ argument: argument
+ };
+ },
+
+ createTupleTypeAnnotation: function (types) {
+ return {
+ type: Syntax.TupleTypeAnnotation,
+ types: types
+ };
+ },
+
+ createObjectTypeAnnotation: function (properties, indexers, callProperties) {
return {
type: Syntax.ObjectTypeAnnotation,
- properties: properties
+ properties: properties,
+ indexers: indexers,
+ callProperties: callProperties
+ };
+ },
+
+ createObjectTypeIndexer: function (id, key, value, isStatic) {
+ return {
+ type: Syntax.ObjectTypeIndexer,
+ id: id,
+ key: key,
+ value: value,
+ "static": isStatic
};
},
- createTypeAnnotatedIdentifier: function (identifier, annotation, isOptionalParam) {
+ createObjectTypeCallProperty: function (value, isStatic) {
return {
- type: Syntax.TypeAnnotatedIdentifier,
- id: identifier,
- annotation: annotation
+ type: Syntax.ObjectTypeCallProperty,
+ value: value,
+ "static": isStatic
};
},
- createOptionalParameter: function (identifier) {
+ createObjectTypeProperty: function (key, value, optional, isStatic) {
return {
- type: Syntax.OptionalParameter,
- id: identifier
+ type: Syntax.ObjectTypeProperty,
+ key: key,
+ value: value,
+ optional: optional,
+ "static": isStatic
+ };
+ },
+
+ createUnionTypeAnnotation: function (types) {
+ return {
+ type: Syntax.UnionTypeAnnotation,
+ types: types
+ };
+ },
+
+ createIntersectionTypeAnnotation: function (types) {
+ return {
+ type: Syntax.IntersectionTypeAnnotation,
+ types: types
+ };
+ },
+
+ createTypeAlias: function (id, typeParameters, right) {
+ return {
+ type: Syntax.TypeAlias,
+ id: id,
+ typeParameters: typeParameters,
+ right: right
+ };
+ },
+
+ createInterface: function (id, typeParameters, body, extended) {
+ return {
+ type: Syntax.InterfaceDeclaration,
+ id: id,
+ typeParameters: typeParameters,
+ body: body,
+ "extends": extended
+ };
+ },
+
+ createInterfaceExtends: function (id, typeParameters) {
+ return {
+ type: Syntax.InterfaceExtends,
+ id: id,
+ typeParameters: typeParameters
+ };
+ },
+
+ createDeclareFunction: function (id) {
+ return {
+ type: Syntax.DeclareFunction,
+ id: id
+ };
+ },
+
+ createDeclareVariable: function (id) {
+ return {
+ type: Syntax.DeclareVariable,
+ id: id
+ };
+ },
+
+ createDeclareModule: function (id, body) {
+ return {
+ type: Syntax.DeclareModule,
+ id: id,
+ body: body
};
},
@@ -3492,7 +4136,7 @@ parseYieldExpression: true
return {
type: Syntax.XJSAttribute,
name: name,
- value: value
+ value: value || null
};
},
@@ -3582,11 +4226,15 @@ parseYieldExpression: true
},
createLiteral: function (token) {
- return {
+ var object = {
type: Syntax.Literal,
value: token.value,
raw: source.slice(token.range[0], token.range[1])
};
+ if (token.regex) {
+ object.regex = token.regex;
+ }
+ return object;
},
createMemberExpression: function (accessor, object, property) {
@@ -3781,8 +4429,8 @@ parseYieldExpression: true
};
},
- createArrowFunctionExpression: function (params, defaults, body, rest, expression) {
- return {
+ createArrowFunctionExpression: function (params, defaults, body, rest, expression, isAsync) {
+ var arrowExpr = {
type: Syntax.ArrowFunctionExpression,
id: null,
params: params,
@@ -3792,6 +4440,12 @@ parseYieldExpression: true
generator: false,
expression: expression
};
+
+ if (isAsync) {
+ arrowExpr.async = true;
+ }
+
+ return arrowExpr;
},
createMethodDefinition: function (propertyType, kind, key, value) {
@@ -3804,10 +4458,13 @@ parseYieldExpression: true
};
},
- createClassProperty: function (propertyIdentifier) {
+ createClassProperty: function (key, typeAnnotation, computed, isStatic) {
return {
type: Syntax.ClassProperty,
- id: propertyIdentifier
+ key: key,
+ typeAnnotation: typeAnnotation,
+ computed: computed,
+ "static": isStatic
};
},
@@ -3818,24 +4475,43 @@ parseYieldExpression: true
};
},
- createClassExpression: function (id, superClass, body, parametricType) {
+ createClassImplements: function (id, typeParameters) {
+ return {
+ type: Syntax.ClassImplements,
+ id: id,
+ typeParameters: typeParameters
+ };
+ },
+
+ createClassExpression: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
return {
type: Syntax.ClassExpression,
id: id,
superClass: superClass,
body: body,
- parametricType: parametricType
+ typeParameters: typeParameters,
+ superTypeParameters: superTypeParameters,
+ "implements": implemented
};
},
- createClassDeclaration: function (id, superClass, body, parametricType, superParametricType) {
+ createClassDeclaration: function (id, superClass, body, typeParameters, superTypeParameters, implemented) {
return {
type: Syntax.ClassDeclaration,
id: id,
superClass: superClass,
body: body,
- parametricType: parametricType,
- superParametricType: superParametricType
+ typeParameters: typeParameters,
+ superTypeParameters: superTypeParameters,
+ "implements": implemented
+ };
+ },
+
+ createModuleSpecifier: function (token) {
+ return {
+ type: Syntax.ModuleSpecifier,
+ value: token.value,
+ raw: source.slice(token.range[0], token.range[1])
};
},
@@ -3853,9 +4529,24 @@ parseYieldExpression: true
};
},
- createExportDeclaration: function (declaration, specifiers, source) {
+ createImportDefaultSpecifier: function (id) {
+ return {
+ type: Syntax.ImportDefaultSpecifier,
+ id: id
+ };
+ },
+
+ createImportNamespaceSpecifier: function (id) {
+ return {
+ type: Syntax.ImportNamespaceSpecifier,
+ id: id
+ };
+ },
+
+ createExportDeclaration: function (isDefault, declaration, specifiers, source) {
return {
type: Syntax.ExportDeclaration,
+ 'default': !!isDefault,
declaration: declaration,
specifiers: specifiers,
source: source
@@ -3870,11 +4561,10 @@ parseYieldExpression: true
};
},
- createImportDeclaration: function (specifiers, kind, source) {
+ createImportDeclaration: function (specifiers, source) {
return {
type: Syntax.ImportDeclaration,
specifiers: specifiers,
- kind: kind,
source: source
};
},
@@ -3887,12 +4577,10 @@ parseYieldExpression: true
};
},
- createModuleDeclaration: function (id, source, body) {
+ createAwaitExpression: function (argument) {
return {
- type: Syntax.ModuleDeclaration,
- id: id,
- source: source,
- body: body
+ type: Syntax.AwaitExpression,
+ argument: argument
};
},
@@ -4016,13 +4704,21 @@ parseYieldExpression: true
// Expect the next token to match the specified keyword.
// If not, an exception will be thrown.
- function expectKeyword(keyword) {
+ function expectKeyword(keyword, contextual) {
var token = lex();
- if (token.type !== Token.Keyword || token.value !== keyword) {
+ if (token.type !== (contextual ? Token.Identifier : Token.Keyword) ||
+ token.value !== keyword) {
throwUnexpected(token);
}
}
+ // Expect the next token to match the specified contextual keyword.
+ // If not, an exception will be thrown.
+
+ function expectContextualKeyword(keyword) {
+ return expectKeyword(keyword, true);
+ }
+
// Return true if the next token matches the specified punctuator.
function match(value) {
@@ -4031,15 +4727,15 @@ parseYieldExpression: true
// Return true if the next token matches the specified keyword
- function matchKeyword(keyword) {
- return lookahead.type === Token.Keyword && lookahead.value === keyword;
+ function matchKeyword(keyword, contextual) {
+ var expectedType = contextual ? Token.Identifier : Token.Keyword;
+ return lookahead.type === expectedType && lookahead.value === keyword;
}
-
// Return true if the next token matches the specified contextual keyword
function matchContextualKeyword(keyword) {
- return lookahead.type === Token.Identifier && lookahead.value === keyword;
+ return matchKeyword(keyword, true);
}
// Return true if the next token is an assignment operator
@@ -4065,8 +4761,33 @@ parseYieldExpression: true
op === '|=';
}
+ // Note that 'yield' is treated as a keyword in strict mode, but a
+ // contextual keyword (identifier) in non-strict mode, so we need to
+ // use matchKeyword('yield', false) and matchKeyword('yield', true)
+ // (i.e. matchContextualKeyword) appropriately.
+ function matchYield() {
+ return state.yieldAllowed && matchKeyword('yield', !strict);
+ }
+
+ function matchAsync() {
+ var backtrackToken = lookahead, matches = false;
+
+ if (matchContextualKeyword('async')) {
+ lex(); // Make sure peekLineTerminator() starts after 'async'.
+ matches = !peekLineTerminator();
+ rewind(backtrackToken); // Revert the lex().
+ }
+
+ return matches;
+ }
+
+ function matchAwait() {
+ return state.awaitAllowed && matchContextualKeyword('await');
+ }
+
function consumeSemicolon() {
- var line;
+ var line, oldIndex = index, oldLineNumber = lineNumber,
+ oldLineStart = lineStart, oldLookahead = lookahead;
// Catch the very common case first: immediately a semicolon (char #59).
if (source.charCodeAt(index) === 59) {
@@ -4077,6 +4798,10 @@ parseYieldExpression: true
line = lineNumber;
skipComment();
if (lineNumber !== line) {
+ index = oldIndex;
+ lineNumber = oldLineNumber;
+ lineStart = oldLineStart;
+ lookahead = oldLookahead;
return;
}
@@ -4167,12 +4892,14 @@ parseYieldExpression: true
// 11.1.5 Object Initialiser
function parsePropertyFunction(options) {
- var previousStrict, previousYieldAllowed, params, defaults, body,
- marker = markerCreate();
+ var previousStrict, previousYieldAllowed, previousAwaitAllowed,
+ params, defaults, body, marker = markerCreate();
previousStrict = strict;
previousYieldAllowed = state.yieldAllowed;
state.yieldAllowed = options.generator;
+ previousAwaitAllowed = state.awaitAllowed;
+ state.awaitAllowed = options.async;
params = options.params || [];
defaults = options.defaults || [];
@@ -4182,6 +4909,7 @@ parseYieldExpression: true
}
strict = previousStrict;
state.yieldAllowed = previousYieldAllowed;
+ state.awaitAllowed = previousAwaitAllowed;
return markerApply(marker, delegate.createFunctionExpression(
null,
@@ -4191,8 +4919,9 @@ parseYieldExpression: true
options.rest || null,
options.generator,
body.type !== Syntax.BlockStatement,
+ options.async,
options.returnType,
- options.parametricType
+ options.typeParameters
));
}
@@ -4209,14 +4938,14 @@ parseYieldExpression: true
throwErrorTolerant(tmp.stricted, tmp.message);
}
-
method = parsePropertyFunction({
params: tmp.params,
defaults: tmp.defaults,
rest: tmp.rest,
generator: options.generator,
+ async: options.async,
returnType: tmp.returnType,
- parametricType: options.parametricType
+ typeParameters: options.typeParameters
});
strict = previousStrict;
@@ -4256,46 +4985,138 @@ parseYieldExpression: true
function parseObjectProperty() {
var token, key, id, value, param, expr, computed,
- marker = markerCreate();
+ marker = markerCreate(), returnType;
token = lookahead;
computed = (token.value === '[');
- if (token.type === Token.Identifier || computed) {
-
+ if (token.type === Token.Identifier || computed || matchAsync()) {
id = parseObjectPropertyKey();
+ if (match(':')) {
+ lex();
+
+ return markerApply(
+ marker,
+ delegate.createProperty(
+ 'init',
+ id,
+ parseAssignmentExpression(),
+ false,
+ false,
+ computed
+ )
+ );
+ }
+
+ if (match('(')) {
+ return markerApply(
+ marker,
+ delegate.createProperty(
+ 'init',
+ id,
+ parsePropertyMethodFunction({
+ generator: false,
+ async: false
+ }),
+ true,
+ false,
+ computed
+ )
+ );
+ }
+
// Property Assignment: Getter and Setter.
- if (token.value === 'get' && !(match(':') || match('('))) {
+ if (token.value === 'get') {
computed = (lookahead.value === '[');
key = parseObjectPropertyKey();
+
expect('(');
expect(')');
- return markerApply(marker, delegate.createProperty('get', key, parsePropertyFunction({ generator: false }), false, false, computed));
+ if (match(':')) {
+ returnType = parseTypeAnnotation();
+ }
+
+ return markerApply(
+ marker,
+ delegate.createProperty(
+ 'get',
+ key,
+ parsePropertyFunction({
+ generator: false,
+ async: false,
+ returnType: returnType
+ }),
+ false,
+ false,
+ computed
+ )
+ );
}
- if (token.value === 'set' && !(match(':') || match('('))) {
+
+ if (token.value === 'set') {
computed = (lookahead.value === '[');
key = parseObjectPropertyKey();
+
expect('(');
token = lookahead;
param = [ parseTypeAnnotatableIdentifier() ];
expect(')');
- return markerApply(marker, delegate.createProperty('set', key, parsePropertyFunction({ params: param, generator: false, name: token }), false, false, computed));
- }
- if (match(':')) {
- lex();
- return markerApply(marker, delegate.createProperty('init', id, parseAssignmentExpression(), false, false, computed));
+ if (match(':')) {
+ returnType = parseTypeAnnotation();
+ }
+
+ return markerApply(
+ marker,
+ delegate.createProperty(
+ 'set',
+ key,
+ parsePropertyFunction({
+ params: param,
+ generator: false,
+ async: false,
+ name: token,
+ returnType: returnType
+ }),
+ false,
+ false,
+ computed
+ )
+ );
}
- if (match('(')) {
- return markerApply(marker, delegate.createProperty('init', id, parsePropertyMethodFunction({ generator: false }), true, false, computed));
+
+ if (token.value === 'async') {
+ computed = (lookahead.value === '[');
+ key = parseObjectPropertyKey();
+
+ return markerApply(
+ marker,
+ delegate.createProperty(
+ 'init',
+ key,
+ parsePropertyMethodFunction({
+ generator: false,
+ async: true
+ }),
+ true,
+ false,
+ computed
+ )
+ );
}
+
if (computed) {
// Computed properties can only be used with full notation.
throwUnexpected(lookahead);
}
- return markerApply(marker, delegate.createProperty('init', id, id, false, true, false));
+
+ return markerApply(
+ marker,
+ delegate.createProperty('init', id, id, false, true, false)
+ );
}
+
if (token.type === Token.EOF || token.type === Token.Punctuator) {
if (!match('*')) {
throwUnexpected(token);
@@ -4422,6 +5243,18 @@ parseYieldExpression: true
return expr;
}
+ function matchAsyncFuncExprOrDecl() {
+ var token;
+
+ if (matchAsync()) {
+ token = lookahead2();
+ if (token.type === Token.Keyword && token.value === 'function') {
+ return true;
+ }
+ }
+
+ return false;
+ }
// 11.1 Primary Expressions
@@ -4998,13 +5831,15 @@ parseYieldExpression: true
}
function parseArrowFunctionExpression(options, marker) {
- var previousStrict, previousYieldAllowed, body;
+ var previousStrict, previousYieldAllowed, previousAwaitAllowed, body;
expect('=>');
previousStrict = strict;
previousYieldAllowed = state.yieldAllowed;
state.yieldAllowed = false;
+ previousAwaitAllowed = state.awaitAllowed;
+ state.awaitAllowed = !!options.async;
body = parseConciseBody();
if (strict && options.firstRestricted) {
@@ -5016,30 +5851,47 @@ parseYieldExpression: true
strict = previousStrict;
state.yieldAllowed = previousYieldAllowed;
+ state.awaitAllowed = previousAwaitAllowed;
return markerApply(marker, delegate.createArrowFunctionExpression(
options.params,
options.defaults,
body,
options.rest,
- body.type !== Syntax.BlockStatement
+ body.type !== Syntax.BlockStatement,
+ !!options.async
));
}
function parseAssignmentExpression() {
- var marker, expr, token, params, oldParenthesizedCount;
+ var marker, expr, token, params, oldParenthesizedCount,
+ backtrackToken = lookahead, possiblyAsync = false;
- // Note that 'yield' is treated as a keyword in strict mode, but a
- // contextual keyword (identifier) in non-strict mode, so we need
- // to use matchKeyword and matchContextualKeyword appropriately.
- if ((state.yieldAllowed && matchContextualKeyword('yield')) || (strict && matchKeyword('yield'))) {
+ if (matchYield()) {
return parseYieldExpression();
}
+ if (matchAwait()) {
+ return parseAwaitExpression();
+ }
+
oldParenthesizedCount = state.parenthesizedCount;
marker = markerCreate();
+ if (matchAsyncFuncExprOrDecl()) {
+ return parseFunctionExpression();
+ }
+
+ if (matchAsync()) {
+ // We can't be completely sure that this 'async' token is
+ // actually a contextual keyword modifying a function
+ // expression, so we might have to un-lex() it later by
+ // calling rewind(backtrackToken).
+ possiblyAsync = true;
+ lex();
+ }
+
if (match('(')) {
token = lookahead2();
if ((token.type === Token.Punctuator && token.value === ')') || token.value === '...') {
@@ -5047,11 +5899,21 @@ parseYieldExpression: true
if (!match('=>')) {
throwUnexpected(lex());
}
+ params.async = possiblyAsync;
return parseArrowFunctionExpression(params, marker);
}
}
token = lookahead;
+
+ // If the 'async' keyword is not followed by a '(' character or an
+ // identifier, then it can't be an arrow function modifier, and we
+ // should interpret it as a normal identifer.
+ if (possiblyAsync && !match('(') && token.type !== Token.Identifier) {
+ possiblyAsync = false;
+ rewind(backtrackToken);
+ }
+
expr = parseConditionalExpression();
if (match('=>') &&
@@ -5063,10 +5925,20 @@ parseYieldExpression: true
params = reinterpretAsCoverFormalsList(expr.expressions);
}
if (params) {
+ params.async = possiblyAsync;
return parseArrowFunctionExpression(params, marker);
}
}
+ // If we haven't returned by now, then the 'async' keyword was not
+ // a function modifier, and we should rewind and interpret it as a
+ // normal identifier.
+ if (possiblyAsync) {
+ possiblyAsync = false;
+ rewind(backtrackToken);
+ expr = parseConditionalExpression();
+ }
+
if (matchAssign()) {
// 11.13.1
if (strict && expr.type === Syntax.Identifier && isRestrictedWord(expr.name)) {
@@ -5172,118 +6044,446 @@ parseYieldExpression: true
// 12.2 Variable Statement
- function parseObjectTypeAnnotation() {
- var isMethod, marker, properties = [], property, propertyKey,
- propertyTypeAnnotation;
+ function parseTypeParameterDeclaration() {
+ var marker = markerCreate(), paramTypes = [];
+
+ expect('<');
+ while (!match('>')) {
+ paramTypes.push(parseVariableIdentifier());
+ if (!match('>')) {
+ expect(',');
+ }
+ }
+ expect('>');
+
+ return markerApply(marker, delegate.createTypeParameterDeclaration(
+ paramTypes
+ ));
+ }
+
+ function parseTypeParameterInstantiation() {
+ var marker = markerCreate(), oldInType = state.inType, paramTypes = [];
+
+ state.inType = true;
+
+ expect('<');
+ while (!match('>')) {
+ paramTypes.push(parseType());
+ if (!match('>')) {
+ expect(',');
+ }
+ }
+ expect('>');
+
+ state.inType = oldInType;
+
+ return markerApply(marker, delegate.createTypeParameterInstantiation(
+ paramTypes
+ ));
+ }
+
+ function parseObjectTypeIndexer(marker, isStatic) {
+ var id, key, value;
+
+ expect('[');
+ id = parseObjectPropertyKey();
+ expect(':');
+ key = parseType();
+ expect(']');
+ expect(':');
+ value = parseType();
+
+ return markerApply(marker, delegate.createObjectTypeIndexer(
+ id,
+ key,
+ value,
+ isStatic
+ ));
+ }
+
+ function parseObjectTypeMethodish(marker) {
+ var params = [], rest = null, returnType, typeParameters = null;
+ if (match('<')) {
+ typeParameters = parseTypeParameterDeclaration();
+ }
+
+ expect('(');
+ while (lookahead.type === Token.Identifier) {
+ params.push(parseFunctionTypeParam());
+ if (!match(')')) {
+ expect(',');
+ }
+ }
+
+ if (match('...')) {
+ lex();
+ rest = parseFunctionTypeParam();
+ }
+ expect(')');
+ expect(':');
+ returnType = parseType();
+
+ return markerApply(marker, delegate.createFunctionTypeAnnotation(
+ params,
+ returnType,
+ rest,
+ typeParameters
+ ));
+ }
+
+ function parseObjectTypeMethod(marker, isStatic, key) {
+ var optional = false, value;
+ value = parseObjectTypeMethodish(marker);
+
+ return markerApply(marker, delegate.createObjectTypeProperty(
+ key,
+ value,
+ optional,
+ isStatic
+ ));
+ }
+
+ function parseObjectTypeCallProperty(marker, isStatic) {
+ var valueMarker = markerCreate();
+ return markerApply(marker, delegate.createObjectTypeCallProperty(
+ parseObjectTypeMethodish(valueMarker),
+ isStatic
+ ));
+ }
+
+ function parseObjectType(allowStatic) {
+ var callProperties = [], indexers = [], marker, optional = false,
+ properties = [], property, propertyKey, propertyTypeAnnotation,
+ token, isStatic;
expect('{');
while (!match('}')) {
marker = markerCreate();
- propertyKey = parseObjectPropertyKey();
- isMethod = match('(');
- propertyTypeAnnotation = parseTypeAnnotation();
- properties.push(markerApply(marker, delegate.createProperty(
- 'init',
- propertyKey,
- propertyTypeAnnotation,
- isMethod,
- false
- )));
+ if (allowStatic && matchContextualKeyword('static')) {
+ token = lex();
+ isStatic = true;
+ }
- if (!match('}')) {
- if (match(',') || match(';')) {
- lex();
+ if (match('[')) {
+ indexers.push(parseObjectTypeIndexer(marker, isStatic));
+ } else if (match('(') || match('<')) {
+ callProperties.push(parseObjectTypeCallProperty(marker, allowStatic));
+ } else {
+ if (isStatic && match(':')) {
+ propertyKey = markerApply(marker, delegate.createIdentifier(token));
+ throwErrorTolerant(token, Messages.StrictReservedWord);
} else {
- throwUnexpected(lookahead);
+ propertyKey = parseObjectPropertyKey();
}
+ if (match('<') || match('(')) {
+ // This is a method property
+ properties.push(parseObjectTypeMethod(marker, isStatic, propertyKey));
+ } else {
+ if (match('?')) {
+ lex();
+ optional = true;
+ }
+ expect(':');
+ propertyTypeAnnotation = parseType();
+ properties.push(markerApply(marker, delegate.createObjectTypeProperty(
+ propertyKey,
+ propertyTypeAnnotation,
+ optional,
+ isStatic
+ )));
+ }
+ }
+
+ if (match(';')) {
+ lex();
+ } else if (!match('}')) {
+ throwUnexpected(lookahead);
}
}
expect('}');
- return delegate.createObjectTypeAnnotation(properties);
+ return delegate.createObjectTypeAnnotation(
+ properties,
+ indexers,
+ callProperties
+ );
+ }
+
+ function parseGenericType() {
+ var marker = markerCreate(), returnType = null,
+ typeParameters = null, typeIdentifier,
+ typeIdentifierMarker = markerCreate;
+
+ typeIdentifier = parseVariableIdentifier();
+
+ while (match('.')) {
+ expect('.');
+ typeIdentifier = markerApply(marker, delegate.createQualifiedTypeIdentifier(
+ typeIdentifier,
+ parseVariableIdentifier()
+ ));
+ }
+
+ if (match('<')) {
+ typeParameters = parseTypeParameterInstantiation();
+ }
+
+ return markerApply(marker, delegate.createGenericTypeAnnotation(
+ typeIdentifier,
+ typeParameters
+ ));
}
- function parseVoidTypeAnnotation() {
+ function parseVoidType() {
var marker = markerCreate();
expectKeyword('void');
return markerApply(marker, delegate.createVoidTypeAnnotation());
}
- function parseParametricTypeAnnotation() {
- var marker = markerCreate(), typeIdentifier, paramTypes = [];
+ function parseTypeofType() {
+ var argument, marker = markerCreate();
+ expectKeyword('typeof');
+ argument = parsePrimaryType();
+ return markerApply(marker, delegate.createTypeofTypeAnnotation(
+ argument
+ ));
+ }
- expect('<');
- while (!match('>')) {
- paramTypes.push(parseVariableIdentifier());
- if (!match('>')) {
- expect(',');
+ function parseTupleType() {
+ var marker = markerCreate(), types = [];
+ expect('[');
+ // We allow trailing commas
+ while (index < length && !match(']')) {
+ types.push(parseType());
+ if (match(']')) {
+ break;
}
+ expect(',');
}
- expect('>');
+ expect(']');
+ return markerApply(marker, delegate.createTupleTypeAnnotation(
+ types
+ ));
+ }
- return markerApply(marker, delegate.createParametricTypeAnnotation(
- paramTypes
+ function parseFunctionTypeParam() {
+ var marker = markerCreate(), name, optional = false, typeAnnotation;
+ name = parseVariableIdentifier();
+ if (match('?')) {
+ lex();
+ optional = true;
+ }
+ expect(':');
+ typeAnnotation = parseType();
+ return markerApply(marker, delegate.createFunctionTypeParam(
+ name,
+ typeAnnotation,
+ optional
));
}
- function parseTypeAnnotation(dontExpectColon) {
+ function parseFunctionTypeParams() {
+ var ret = { params: [], rest: null };
+ while (lookahead.type === Token.Identifier) {
+ ret.params.push(parseFunctionTypeParam());
+ if (!match(')')) {
+ expect(',');
+ }
+ }
+
+ if (match('...')) {
+ lex();
+ ret.rest = parseFunctionTypeParam();
+ }
+ return ret;
+ }
+
+ // The parsing of types roughly parallels the parsing of expressions, and
+ // primary types are kind of like primary expressions...they're the
+ // primitives with which other types are constructed.
+ function parsePrimaryType() {
var typeIdentifier = null, params = null, returnType = null,
- nullable = false, marker = markerCreate(), returnTypeMarker = null,
- parametricType, annotation;
+ marker = markerCreate(), rest = null, tmp,
+ typeParameters, token, type, isGroupedType = false;
- if (!dontExpectColon) {
- expect(':');
+ switch (lookahead.type) {
+ case Token.Identifier:
+ switch (lookahead.value) {
+ case 'any':
+ lex();
+ return markerApply(marker, delegate.createAnyTypeAnnotation());
+ case 'bool': // fallthrough
+ case 'boolean':
+ lex();
+ return markerApply(marker, delegate.createBooleanTypeAnnotation());
+ case 'number':
+ lex();
+ return markerApply(marker, delegate.createNumberTypeAnnotation());
+ case 'string':
+ lex();
+ return markerApply(marker, delegate.createStringTypeAnnotation());
+ }
+ return markerApply(marker, parseGenericType());
+ case Token.Punctuator:
+ switch (lookahead.value) {
+ case '{':
+ return markerApply(marker, parseObjectType());
+ case '[':
+ return parseTupleType();
+ case '<':
+ typeParameters = parseTypeParameterDeclaration();
+ expect('(');
+ tmp = parseFunctionTypeParams();
+ params = tmp.params;
+ rest = tmp.rest;
+ expect(')');
+
+ expect('=>');
+
+ returnType = parseType();
+
+ return markerApply(marker, delegate.createFunctionTypeAnnotation(
+ params,
+ returnType,
+ rest,
+ typeParameters
+ ));
+ case '(':
+ lex();
+ // Check to see if this is actually a grouped type
+ if (!match(')') && !match('...')) {
+ if (lookahead.type === Token.Identifier) {
+ token = lookahead2();
+ isGroupedType = token.value !== '?' && token.value !== ':';
+ } else {
+ isGroupedType = true;
+ }
+ }
+
+ if (isGroupedType) {
+ type = parseType();
+ expect(')');
+
+ // If we see a => next then someone was probably confused about
+ // function types, so we can provide a better error message
+ if (match('=>')) {
+ throwError({}, Messages.ConfusedAboutFunctionType);
+ }
+
+ return type;
+ }
+
+ tmp = parseFunctionTypeParams();
+ params = tmp.params;
+ rest = tmp.rest;
+
+ expect(')');
+
+ expect('=>');
+
+ returnType = parseType();
+
+ return markerApply(marker, delegate.createFunctionTypeAnnotation(
+ params,
+ returnType,
+ rest,
+ null /* typeParameters */
+ ));
+ }
+ break;
+ case Token.Keyword:
+ switch (lookahead.value) {
+ case 'void':
+ return markerApply(marker, parseVoidType());
+ case 'typeof':
+ return markerApply(marker, parseTypeofType());
+ }
+ break;
+ case Token.StringLiteral:
+ token = lex();
+ if (token.octal) {
+ throwError(token, Messages.StrictOctalLiteral);
+ }
+ return markerApply(marker, delegate.createStringLiteralTypeAnnotation(
+ token
+ ));
}
- if (match('{')) {
- return markerApply(marker, parseObjectTypeAnnotation());
+ throwUnexpected(lookahead);
+ }
+
+ function parsePostfixType() {
+ var marker = markerCreate(), t = parsePrimaryType();
+ if (match('[')) {
+ expect('[');
+ expect(']');
+ return markerApply(marker, delegate.createArrayTypeAnnotation(t));
}
+ return t;
+ }
+ function parsePrefixType() {
+ var marker = markerCreate();
if (match('?')) {
lex();
- nullable = true;
+ return markerApply(marker, delegate.createNullableTypeAnnotation(
+ parsePrefixType()
+ ));
}
+ return parsePostfixType();
+ }
- if (lookahead.type === Token.Identifier) {
- typeIdentifier = parseVariableIdentifier();
- if (match('<')) {
- parametricType = parseParametricTypeAnnotation();
- }
- } else if (match('(')) {
+
+ function parseIntersectionType() {
+ var marker = markerCreate(), type, types;
+ type = parsePrefixType();
+ types = [type];
+ while (match('&')) {
lex();
- params = [];
- while (lookahead.type === Token.Identifier || match('?')) {
- params.push(parseTypeAnnotatableIdentifier(
- true, /* requireTypeAnnotation */
- true /* canBeOptionalParam */
- ));
- if (!match(')')) {
- expect(',');
- }
- }
- expect(')');
+ types.push(parsePrefixType());
+ }
- returnTypeMarker = markerCreate();
- expect('=>');
+ return types.length === 1 ?
+ type :
+ markerApply(marker, delegate.createIntersectionTypeAnnotation(
+ types
+ ));
+ }
- returnType = parseTypeAnnotation(true);
- } else {
- if (!matchKeyword('void')) {
- throwUnexpected(lookahead);
- } else {
- return parseVoidTypeAnnotation();
- }
+ function parseUnionType() {
+ var marker = markerCreate(), type, types;
+ type = parseIntersectionType();
+ types = [type];
+ while (match('|')) {
+ lex();
+ types.push(parseIntersectionType());
}
+ return types.length === 1 ?
+ type :
+ markerApply(marker, delegate.createUnionTypeAnnotation(
+ types
+ ));
+ }
- return markerApply(marker, delegate.createTypeAnnotation(
- typeIdentifier,
- parametricType,
- params,
- returnType,
- nullable
- ));
+ function parseType() {
+ var oldInType = state.inType, type;
+ state.inType = true;
+
+ type = parseUnionType();
+
+ state.inType = oldInType;
+ return type;
+ }
+
+ function parseTypeAnnotation() {
+ var marker = markerCreate(), type;
+
+ expect(':');
+ type = parseType();
+
+ return markerApply(marker, delegate.createTypeAnnotation(type));
}
function parseVariableIdentifier() {
@@ -5308,14 +6508,13 @@ parseYieldExpression: true
}
if (requireTypeAnnotation || match(':')) {
- ident = markerApply(marker, delegate.createTypeAnnotatedIdentifier(
- ident,
- parseTypeAnnotation()
- ));
+ ident.typeAnnotation = parseTypeAnnotation();
+ ident = markerApply(marker, ident);
}
if (isOptionalParam) {
- ident = markerApply(marker, delegate.createOptionalParameter(ident));
+ ident.optional = true;
+ ident = markerApply(marker, ident);
}
return ident;
@@ -5324,13 +6523,22 @@ parseYieldExpression: true
function parseVariableDeclaration(kind) {
var id,
marker = markerCreate(),
- init = null;
+ init = null,
+ typeAnnotationMarker = markerCreate();
if (match('{')) {
id = parseObjectInitialiser();
reinterpretAsAssignmentBindingPattern(id);
+ if (match(':')) {
+ id.typeAnnotation = parseTypeAnnotation();
+ markerApply(typeAnnotationMarker, id);
+ }
} else if (match('[')) {
id = parseArrayInitialiser();
reinterpretAsAssignmentBindingPattern(id);
+ if (match(':')) {
+ id.typeAnnotation = parseTypeAnnotation();
+ markerApply(typeAnnotationMarker, id);
+ }
} else {
id = state.allowKeyword ? parseNonComputedProperty() : parseTypeAnnotatableIdentifier();
// 12.2.1
@@ -5395,41 +6603,18 @@ parseYieldExpression: true
return markerApply(marker, delegate.createVariableDeclaration(declarations, kind));
}
- // http://wiki.ecmascript.org/doku.php?id=harmony:modules
-
- function parseModuleDeclaration() {
- var id, src, body, marker = markerCreate();
-
- lex(); // 'module'
-
- if (peekLineTerminator()) {
- throwError({}, Messages.NewlineAfterModule);
- }
-
- switch (lookahead.type) {
+ // people.mozilla.org/~jorendorff/es6-draft.html
- case Token.StringLiteral:
- id = parsePrimaryExpression();
- body = parseModuleBlock();
- src = null;
- break;
+ function parseModuleSpecifier() {
+ var marker = markerCreate(),
+ specifier;
- case Token.Identifier:
- id = parseVariableIdentifier();
- body = null;
- if (!matchContextualKeyword('from')) {
- throwUnexpected(lex());
- }
- lex();
- src = parsePrimaryExpression();
- if (src.type !== Syntax.Literal) {
- throwError({}, Messages.InvalidModuleSpecifier);
- }
- break;
+ if (lookahead.type !== Token.StringLiteral) {
+ throwError({}, Messages.InvalidModuleSpecifier);
}
-
- consumeSemicolon();
- return markerApply(marker, delegate.createModuleDeclaration(id, src, body));
+ specifier = delegate.createModuleSpecifier(lookahead);
+ lex();
+ return markerApply(marker, specifier);
}
function parseExportBatchSpecifier() {
@@ -5439,9 +6624,14 @@ parseYieldExpression: true
}
function parseExportSpecifier() {
- var id, name = null, marker = markerCreate();
-
- id = parseVariableIdentifier();
+ var id, name = null, marker = markerCreate(), from;
+ if (matchKeyword('default')) {
+ lex();
+ id = markerApply(marker, delegate.createIdentifier('default'));
+ // export {default} from "something";
+ } else {
+ id = parseVariableIdentifier();
+ }
if (matchContextualKeyword('as')) {
lex();
name = parseNonComputedProperty();
@@ -5451,104 +6641,207 @@ parseYieldExpression: true
}
function parseExportDeclaration() {
- var previousAllowKeyword, decl, def, src, specifiers,
+ var backtrackToken, id, previousAllowKeyword, declaration = null,
+ isExportFromIdentifier,
+ src = null, specifiers = [],
marker = markerCreate();
expectKeyword('export');
+ if (matchKeyword('default')) {
+ // covers:
+ // export default ...
+ lex();
+ if (matchKeyword('function') || matchKeyword('class')) {
+ backtrackToken = lookahead;
+ lex();
+ if (isIdentifierName(lookahead)) {
+ // covers:
+ // export default function foo () {}
+ // export default class foo {}
+ id = parseNonComputedProperty();
+ rewind(backtrackToken);
+ return markerApply(marker, delegate.createExportDeclaration(true, parseSourceElement(), [id], null));
+ }
+ // covers:
+ // export default function () {}
+ // export default class {}
+ rewind(backtrackToken);
+ switch (lookahead.value) {
+ case 'class':
+ return markerApply(marker, delegate.createExportDeclaration(true, parseClassExpression(), [], null));
+ case 'function':
+ return markerApply(marker, delegate.createExportDeclaration(true, parseFunctionExpression(), [], null));
+ }
+ }
+
+ if (matchContextualKeyword('from')) {
+ throwError({}, Messages.UnexpectedToken, lookahead.value);
+ }
+
+ // covers:
+ // export default {};
+ // export default [];
+ if (match('{')) {
+ declaration = parseObjectInitialiser();
+ } else if (match('[')) {
+ declaration = parseArrayInitialiser();
+ } else {
+ declaration = parseAssignmentExpression();
+ }
+ consumeSemicolon();
+ return markerApply(marker, delegate.createExportDeclaration(true, declaration, [], null));
+ }
+
+ // non-default export
if (lookahead.type === Token.Keyword) {
+ // covers:
+ // export var f = 1;
switch (lookahead.value) {
case 'let':
case 'const':
case 'var':
case 'class':
case 'function':
- return markerApply(marker, delegate.createExportDeclaration(parseSourceElement(), null, null));
+ return markerApply(marker, delegate.createExportDeclaration(false, parseSourceElement(), specifiers, null));
}
}
- if (isIdentifierName(lookahead)) {
- previousAllowKeyword = state.allowKeyword;
- state.allowKeyword = true;
- decl = parseVariableDeclarationList('let');
- state.allowKeyword = previousAllowKeyword;
- return markerApply(marker, delegate.createExportDeclaration(decl, null, null));
+ if (match('*')) {
+ // covers:
+ // export * from "foo";
+ specifiers.push(parseExportBatchSpecifier());
+
+ if (!matchContextualKeyword('from')) {
+ throwError({}, lookahead.value ?
+ Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
+ }
+ lex();
+ src = parseModuleSpecifier();
+ consumeSemicolon();
+
+ return markerApply(marker, delegate.createExportDeclaration(false, null, specifiers, src));
}
- specifiers = [];
- src = null;
+ expect('{');
+ do {
+ isExportFromIdentifier = isExportFromIdentifier || matchKeyword('default');
+ specifiers.push(parseExportSpecifier());
+ } while (match(',') && lex());
+ expect('}');
- if (match('*')) {
- specifiers.push(parseExportBatchSpecifier());
+ if (matchContextualKeyword('from')) {
+ // covering:
+ // export {default} from "foo";
+ // export {foo} from "foo";
+ lex();
+ src = parseModuleSpecifier();
+ consumeSemicolon();
+ } else if (isExportFromIdentifier) {
+ // covering:
+ // export {default}; // missing fromClause
+ throwError({}, lookahead.value ?
+ Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
} else {
- expect('{');
- do {
- specifiers.push(parseExportSpecifier());
- } while (match(',') && lex());
- expect('}');
+ // cover
+ // export {foo};
+ consumeSemicolon();
}
+ return markerApply(marker, delegate.createExportDeclaration(false, declaration, specifiers, src));
+ }
- if (matchContextualKeyword('from')) {
+
+ function parseImportSpecifier() {
+ // import {<foo as bar>} ...;
+ var id, name = null, marker = markerCreate();
+
+ id = parseNonComputedProperty();
+ if (matchContextualKeyword('as')) {
lex();
- src = parsePrimaryExpression();
- if (src.type !== Syntax.Literal) {
- throwError({}, Messages.InvalidModuleSpecifier);
- }
+ name = parseVariableIdentifier();
}
- consumeSemicolon();
+ return markerApply(marker, delegate.createImportSpecifier(id, name));
+ }
+
+ function parseNamedImports() {
+ var specifiers = [];
+ // {foo, bar as bas}
+ expect('{');
+ do {
+ specifiers.push(parseImportSpecifier());
+ } while (match(',') && lex());
+ expect('}');
+ return specifiers;
+ }
+
+ function parseImportDefaultSpecifier() {
+ // import <foo> ...;
+ var id, marker = markerCreate();
+
+ id = parseNonComputedProperty();
+
+ return markerApply(marker, delegate.createImportDefaultSpecifier(id));
+ }
+
+ function parseImportNamespaceSpecifier() {
+ // import <* as foo> ...;
+ var id, marker = markerCreate();
+
+ expect('*');
+ if (!matchContextualKeyword('as')) {
+ throwError({}, Messages.NoAsAfterImportNamespace);
+ }
+ lex();
+ id = parseNonComputedProperty();
- return markerApply(marker, delegate.createExportDeclaration(null, specifiers, src));
+ return markerApply(marker, delegate.createImportNamespaceSpecifier(id));
}
function parseImportDeclaration() {
- var specifiers, kind, src, marker = markerCreate();
+ var specifiers, src, marker = markerCreate();
expectKeyword('import');
specifiers = [];
- if (isIdentifierName(lookahead)) {
- kind = 'default';
- specifiers.push(parseImportSpecifier());
+ if (lookahead.type === Token.StringLiteral) {
+ // covers:
+ // import "foo";
+ src = parseModuleSpecifier();
+ consumeSemicolon();
+ return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
+ }
- if (!matchContextualKeyword('from')) {
- throwError({}, Messages.NoFromAfterImport);
+ if (!matchKeyword('default') && isIdentifierName(lookahead)) {
+ // covers:
+ // import foo
+ // import foo, ...
+ specifiers.push(parseImportDefaultSpecifier());
+ if (match(',')) {
+ lex();
}
- lex();
+ }
+ if (match('*')) {
+ // covers:
+ // import foo, * as foo
+ // import * as foo
+ specifiers.push(parseImportNamespaceSpecifier());
} else if (match('{')) {
- kind = 'named';
- lex();
- do {
- specifiers.push(parseImportSpecifier());
- } while (match(',') && lex());
- expect('}');
-
- if (!matchContextualKeyword('from')) {
- throwError({}, Messages.NoFromAfterImport);
- }
- lex();
+ // covers:
+ // import foo, {bar}
+ // import {bar}
+ specifiers = specifiers.concat(parseNamedImports());
}
- src = parsePrimaryExpression();
- if (src.type !== Syntax.Literal) {
- throwError({}, Messages.InvalidModuleSpecifier);
+ if (!matchContextualKeyword('from')) {
+ throwError({}, lookahead.value ?
+ Messages.UnexpectedToken : Messages.MissingFromClause, lookahead.value);
}
-
+ lex();
+ src = parseModuleSpecifier();
consumeSemicolon();
- return markerApply(marker, delegate.createImportDeclaration(specifiers, kind, src));
- }
-
- function parseImportSpecifier() {
- var id, name = null, marker = markerCreate();
-
- id = parseNonComputedProperty();
- if (matchContextualKeyword('as')) {
- lex();
- name = parseVariableIdentifier();
- }
-
- return markerApply(marker, delegate.createImportSpecifier(id, name));
+ return markerApply(marker, delegate.createImportDeclaration(specifiers, src));
}
// 12.3 Empty Statement
@@ -6101,6 +7394,10 @@ parseYieldExpression: true
}
}
+ if (matchAsyncFuncExprOrDecl()) {
+ return parseFunctionDeclaration();
+ }
+
marker = markerCreate();
expr = parseExpression();
@@ -6226,7 +7523,7 @@ parseYieldExpression: true
}
function parseParam(options) {
- var token, rest, param, def;
+ var marker, token, rest, param, def;
token = lookahead;
if (token.value === '...') {
@@ -6235,19 +7532,31 @@ parseYieldExpression: true
}
if (match('[')) {
+ marker = markerCreate();
param = parseArrayInitialiser();
reinterpretAsDestructuredParameter(options, param);
+ if (match(':')) {
+ param.typeAnnotation = parseTypeAnnotation();
+ markerApply(marker, param);
+ }
} else if (match('{')) {
+ marker = markerCreate();
if (rest) {
throwError({}, Messages.ObjectPatternAsRestParameter);
}
param = parseObjectInitialiser();
reinterpretAsDestructuredParameter(options, param);
+ if (match(':')) {
+ param.typeAnnotation = parseTypeAnnotation();
+ markerApply(marker, param);
+ }
} else {
- // Typing rest params is awkward, so punting on that for now
param =
rest
- ? parseVariableIdentifier()
+ ? parseTypeAnnotatableIdentifier(
+ false, /* requireTypeAnnotation */
+ false /* canBeOptionalParam */
+ )
: parseTypeAnnotatableIdentifier(
false, /* requireTypeAnnotation */
true /* canBeOptionalParam */
@@ -6315,8 +7624,15 @@ parseYieldExpression: true
}
function parseFunctionDeclaration() {
- var id, body, token, tmp, firstRestricted, message, previousStrict, previousYieldAllowed, generator,
- marker = markerCreate(), parametricType;
+ var id, body, token, tmp, firstRestricted, message, generator, isAsync,
+ previousStrict, previousYieldAllowed, previousAwaitAllowed,
+ marker = markerCreate(), typeParameters;
+
+ isAsync = false;
+ if (matchAsync()) {
+ lex();
+ isAsync = true;
+ }
expectKeyword('function');
@@ -6331,7 +7647,7 @@ parseYieldExpression: true
id = parseVariableIdentifier();
if (match('<')) {
- parametricType = parseParametricTypeAnnotation();
+ typeParameters = parseTypeParameterDeclaration();
}
if (strict) {
@@ -6357,6 +7673,8 @@ parseYieldExpression: true
previousStrict = strict;
previousYieldAllowed = state.yieldAllowed;
state.yieldAllowed = generator;
+ previousAwaitAllowed = state.awaitAllowed;
+ state.awaitAllowed = isAsync;
body = parseFunctionSourceElements();
@@ -6368,14 +7686,35 @@ parseYieldExpression: true
}
strict = previousStrict;
state.yieldAllowed = previousYieldAllowed;
+ state.awaitAllowed = previousAwaitAllowed;
- return markerApply(marker, delegate.createFunctionDeclaration(id, tmp.params, tmp.defaults, body, tmp.rest, generator, false,
- tmp.returnType, parametricType));
+ return markerApply(
+ marker,
+ delegate.createFunctionDeclaration(
+ id,
+ tmp.params,
+ tmp.defaults,
+ body,
+ tmp.rest,
+ generator,
+ false,
+ isAsync,
+ tmp.returnType,
+ typeParameters
+ )
+ );
}
function parseFunctionExpression() {
- var token, id = null, firstRestricted, message, tmp, body, previousStrict, previousYieldAllowed, generator,
- marker = markerCreate(), parametricType;
+ var token, id = null, firstRestricted, message, tmp, body, generator, isAsync,
+ previousStrict, previousYieldAllowed, previousAwaitAllowed,
+ marker = markerCreate(), typeParameters;
+
+ isAsync = false;
+ if (matchAsync()) {
+ lex();
+ isAsync = true;
+ }
expectKeyword('function');
@@ -6407,7 +7746,7 @@ parseYieldExpression: true
}
if (match('<')) {
- parametricType = parseParametricTypeAnnotation();
+ typeParameters = parseTypeParameterDeclaration();
}
}
@@ -6420,6 +7759,8 @@ parseYieldExpression: true
previousStrict = strict;
previousYieldAllowed = state.yieldAllowed;
state.yieldAllowed = generator;
+ previousAwaitAllowed = state.awaitAllowed;
+ state.awaitAllowed = isAsync;
body = parseFunctionSourceElements();
@@ -6431,20 +7772,29 @@ parseYieldExpression: true
}
strict = previousStrict;
state.yieldAllowed = previousYieldAllowed;
+ state.awaitAllowed = previousAwaitAllowed;
- return markerApply(marker, delegate.createFunctionExpression(id, tmp.params, tmp.defaults, body, tmp.rest, generator, false,
- tmp.returnType, parametricType));
+ return markerApply(
+ marker,
+ delegate.createFunctionExpression(
+ id,
+ tmp.params,
+ tmp.defaults,
+ body,
+ tmp.rest,
+ generator,
+ false,
+ isAsync,
+ tmp.returnType,
+ typeParameters
+ )
+ );
}
function parseYieldExpression() {
- var yieldToken, delegateFlag, expr, marker = markerCreate();
+ var delegateFlag, expr, marker = markerCreate();
- yieldToken = lex();
- assert(yieldToken.value === 'yield', 'Called parseYieldExpression with non-yield lookahead.');
-
- if (!state.yieldAllowed) {
- throwErrorTolerant({}, Messages.IllegalYield);
- }
+ expectKeyword('yield', !strict);
delegateFlag = false;
if (match('*')) {
@@ -6457,35 +7807,34 @@ parseYieldExpression: true
return markerApply(marker, delegate.createYieldExpression(expr, delegateFlag));
}
+ function parseAwaitExpression() {
+ var expr, marker = markerCreate();
+ expectContextualKeyword('await');
+ expr = parseAssignmentExpression();
+ return markerApply(marker, delegate.createAwaitExpression(expr));
+ }
+
// 14 Classes
- function parseMethodDefinition(existingPropNames) {
- var token, key, param, propType, isValidDuplicateProp = false,
- marker = markerCreate(), token2, parametricType,
- parametricTypeMarker, annotationMarker;
+ function parseMethodDefinition(existingPropNames, key, isStatic, generator, computed) {
+ var token, param, propType, isValidDuplicateProp = false,
+ isAsync, typeParameters, tokenValue, returnType,
+ annotationMarker;
- if (lookahead.value === 'static') {
- propType = ClassPropertyType["static"];
- lex();
- } else {
- propType = ClassPropertyType.prototype;
- }
+ propType = isStatic ? ClassPropertyType["static"] : ClassPropertyType.prototype;
- if (match('*')) {
- lex();
- return markerApply(marker, delegate.createMethodDefinition(
+ if (generator) {
+ return delegate.createMethodDefinition(
propType,
'',
- parseObjectPropertyKey(),
+ key,
parsePropertyMethodFunction({ generator: true })
- ));
+ );
}
- token = lookahead;
- //parametricTypeMarker = markerCreate();
- key = parseObjectPropertyKey();
+ tokenValue = key.type === 'Identifier' && key.name;
- if (token.value === 'get' && !match('(')) {
+ if (tokenValue === 'get' && !match('(')) {
key = parseObjectPropertyKey();
// It is a syntax error if any other properties have a name
@@ -6508,14 +7857,17 @@ parseYieldExpression: true
expect('(');
expect(')');
- return markerApply(marker, delegate.createMethodDefinition(
+ if (match(':')) {
+ returnType = parseTypeAnnotation();
+ }
+ return delegate.createMethodDefinition(
propType,
'get',
key,
- parsePropertyFunction({ generator: false })
- ));
+ parsePropertyFunction({ generator: false, returnType: returnType })
+ );
}
- if (token.value === 'set' && !match('(')) {
+ if (tokenValue === 'set' && !match('(')) {
key = parseObjectPropertyKey();
// It is a syntax error if any other properties have a name
@@ -6540,16 +7892,29 @@ parseYieldExpression: true
token = lookahead;
param = [ parseTypeAnnotatableIdentifier() ];
expect(')');
- return markerApply(marker, delegate.createMethodDefinition(
+ if (match(':')) {
+ returnType = parseTypeAnnotation();
+ }
+ return delegate.createMethodDefinition(
propType,
'set',
key,
- parsePropertyFunction({ params: param, generator: false, name: token })
- ));
+ parsePropertyFunction({
+ params: param,
+ generator: false,
+ name: token,
+ returnType: returnType
+ })
+ );
}
if (match('<')) {
- parametricType = parseParametricTypeAnnotation();
+ typeParameters = parseTypeParameterDeclaration();
+ }
+
+ isAsync = tokenValue === 'async' && !match('(');
+ if (isAsync) {
+ key = parseObjectPropertyKey();
}
// It is a syntax error if any other properties have the same name as a
@@ -6561,42 +7926,64 @@ parseYieldExpression: true
}
existingPropNames[propType][key.name].data = true;
- return markerApply(marker, delegate.createMethodDefinition(
+ return delegate.createMethodDefinition(
propType,
'',
key,
parsePropertyMethodFunction({
generator: false,
- parametricType: parametricType
+ async: isAsync,
+ typeParameters: typeParameters
})
- ));
+ );
}
- function parseClassProperty(existingPropNames) {
- var marker = markerCreate(), propertyIdentifier;
+ function parseClassProperty(existingPropNames, key, computed, isStatic) {
+ var typeAnnotation;
- propertyIdentifier = parseTypeAnnotatableIdentifier();
+ typeAnnotation = parseTypeAnnotation();
expect(';');
- return markerApply(marker, delegate.createClassProperty(
- propertyIdentifier
- ));
+ return delegate.createClassProperty(
+ key,
+ typeAnnotation,
+ computed,
+ isStatic
+ );
}
function parseClassElement(existingProps) {
+ var computed, generator = false, key, marker = markerCreate(),
+ isStatic = false;
if (match(';')) {
lex();
return;
}
- var doubleLookahead = lookahead2();
- if (doubleLookahead.type === Token.Punctuator) {
- if (doubleLookahead.value === ':') {
- return parseClassProperty(existingProps);
- }
+ if (lookahead.value === 'static') {
+ lex();
+ isStatic = true;
+ }
+
+ if (match('*')) {
+ lex();
+ generator = true;
+ }
+
+ computed = (lookahead.value === '[');
+ key = parseObjectPropertyKey();
+
+ if (!generator && lookahead.value === ':') {
+ return markerApply(marker, parseClassProperty(existingProps, key, computed, isStatic));
}
- return parseMethodDefinition(existingProps);
+ return markerApply(marker, parseMethodDefinition(
+ existingProps,
+ key,
+ isStatic,
+ generator,
+ computed
+ ));
}
function parseClassBody() {
@@ -6623,66 +8010,109 @@ parseYieldExpression: true
return markerApply(marker, delegate.createClassBody(classElements));
}
+ function parseClassImplements() {
+ var id, implemented = [], marker, typeParameters;
+ expectContextualKeyword('implements');
+ while (index < length) {
+ marker = markerCreate();
+ id = parseVariableIdentifier();
+ if (match('<')) {
+ typeParameters = parseTypeParameterInstantiation();
+ } else {
+ typeParameters = null;
+ }
+ implemented.push(markerApply(marker, delegate.createClassImplements(
+ id,
+ typeParameters
+ )));
+ if (!match(',')) {
+ break;
+ }
+ expect(',');
+ }
+ return implemented;
+ }
+
function parseClassExpression() {
- var id, previousYieldAllowed, superClass = null, marker = markerCreate(),
- parametricType;
+ var id, implemented, previousYieldAllowed, superClass = null,
+ superTypeParameters, marker = markerCreate(), typeParameters;
expectKeyword('class');
- if (!matchKeyword('extends') && !match('{')) {
+ if (!matchKeyword('extends') && !matchContextualKeyword('implements') && !match('{')) {
id = parseVariableIdentifier();
}
if (match('<')) {
- parametricType = parseParametricTypeAnnotation();
+ typeParameters = parseTypeParameterDeclaration();
}
if (matchKeyword('extends')) {
expectKeyword('extends');
previousYieldAllowed = state.yieldAllowed;
state.yieldAllowed = false;
- superClass = parseAssignmentExpression();
+ superClass = parseLeftHandSideExpressionAllowCall();
+ if (match('<')) {
+ superTypeParameters = parseTypeParameterInstantiation();
+ }
state.yieldAllowed = previousYieldAllowed;
}
- return markerApply(marker, delegate.createClassExpression(id, superClass, parseClassBody(), parametricType));
+ if (matchContextualKeyword('implements')) {
+ implemented = parseClassImplements();
+ }
+
+ return markerApply(marker, delegate.createClassExpression(
+ id,
+ superClass,
+ parseClassBody(),
+ typeParameters,
+ superTypeParameters,
+ implemented
+ ));
}
function parseClassDeclaration() {
- var id, previousYieldAllowed, superClass = null, marker = markerCreate(),
- parametricType, superParametricType;
+ var id, implemented, previousYieldAllowed, superClass = null,
+ superTypeParameters, marker = markerCreate(), typeParameters;
expectKeyword('class');
id = parseVariableIdentifier();
if (match('<')) {
- parametricType = parseParametricTypeAnnotation();
+ typeParameters = parseTypeParameterDeclaration();
}
if (matchKeyword('extends')) {
expectKeyword('extends');
previousYieldAllowed = state.yieldAllowed;
state.yieldAllowed = false;
- superClass = parseAssignmentExpression();
+ superClass = parseLeftHandSideExpressionAllowCall();
+ if (match('<')) {
+ superTypeParameters = parseTypeParameterInstantiation();
+ }
state.yieldAllowed = previousYieldAllowed;
}
- return markerApply(marker, delegate.createClassDeclaration(id, superClass, parseClassBody(), parametricType, superParametricType));
+ if (matchContextualKeyword('implements')) {
+ implemented = parseClassImplements();
+ }
+
+ return markerApply(marker, delegate.createClassDeclaration(
+ id,
+ superClass,
+ parseClassBody(),
+ typeParameters,
+ superTypeParameters,
+ implemented
+ ));
}
// 15 Program
- function matchModuleDeclaration() {
- var id;
- if (matchContextualKeyword('module')) {
- id = lookahead2();
- return id.type === Token.StringLiteral || id.type === Token.Identifier;
- }
- return false;
- }
-
function parseSourceElement() {
+ var token;
if (lookahead.type === Token.Keyword) {
switch (lookahead.value) {
case 'const':
@@ -6690,17 +8120,36 @@ parseYieldExpression: true
return parseConstLetDeclaration(lookahead.value);
case 'function':
return parseFunctionDeclaration();
- case 'export':
- return parseExportDeclaration();
- case 'import':
- return parseImportDeclaration();
default:
return parseStatement();
}
}
- if (matchModuleDeclaration()) {
- throwError({}, Messages.NestedModule);
+ if (matchContextualKeyword('type')
+ && lookahead2().type === Token.Identifier) {
+ return parseTypeAlias();
+ }
+
+ if (matchContextualKeyword('interface')
+ && lookahead2().type === Token.Identifier) {
+ return parseInterface();
+ }
+
+ if (matchContextualKeyword('declare')) {
+ token = lookahead2();
+ if (token.type === Token.Keyword) {
+ switch (token.value) {
+ case 'class':
+ return parseDeclareClass();
+ case 'function':
+ return parseDeclareFunction();
+ case 'var':
+ return parseDeclareVariable();
+ }
+ } else if (token.type === Token.Identifier
+ && token.value === 'module') {
+ return parseDeclareModule();
+ }
}
if (lookahead.type !== Token.EOF) {
@@ -6718,10 +8167,6 @@ parseYieldExpression: true
}
}
- if (matchModuleDeclaration()) {
- return parseModuleDeclaration();
- }
-
return parseSourceElement();
}
@@ -6763,40 +8208,6 @@ parseYieldExpression: true
return sourceElements;
}
- function parseModuleElement() {
- return parseSourceElement();
- }
-
- function parseModuleElements() {
- var list = [],
- statement;
-
- while (index < length) {
- if (match('}')) {
- break;
- }
- statement = parseModuleElement();
- if (typeof statement === 'undefined') {
- break;
- }
- list.push(statement);
- }
-
- return list;
- }
-
- function parseModuleBlock() {
- var block, marker = markerCreate();
-
- expect('{');
-
- block = parseModuleElements();
-
- expect('}');
-
- return markerApply(marker, delegate.createBlockStatement(block));
- }
-
function parseProgram() {
var body, marker = markerCreate();
strict = false;
@@ -6833,6 +8244,10 @@ parseYieldExpression: true
comment.loc = loc;
}
extra.comments.push(comment);
+ if (extra.attachComment) {
+ extra.leadingComments.push(comment);
+ extra.trailingComments.push(comment);
+ }
}
function scanComment() {
@@ -6873,17 +8288,18 @@ parseYieldExpression: true
}
} else if (blockComment) {
if (isLineTerminator(ch.charCodeAt(0))) {
- if (ch === '\r' && source[index + 1] === '\n') {
+ if (ch === '\r') {
++index;
- comment += '\r\n';
- } else {
- comment += ch;
+ comment += '\r';
}
- ++lineNumber;
- ++index;
- lineStart = index;
- if (index >= length) {
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
+ if (ch !== '\r' || source[index] === '\n') {
+ comment += source[index];
+ ++lineNumber;
+ ++index;
+ lineStart = index;
+ if (index >= length) {
+ throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
+ }
}
} else {
ch = source[index++];
@@ -7262,7 +8678,7 @@ parseYieldExpression: true
}
function scanXJSEntity() {
- var ch, str = '', count = 0, entity;
+ var ch, str = '', start = index, count = 0, code;
ch = source[index];
assert(ch === '&', 'Entity must start with an ampersand');
index++;
@@ -7274,14 +8690,28 @@ parseYieldExpression: true
str += ch;
}
- if (str[0] === '#' && str[1] === 'x') {
- entity = String.fromCharCode(parseInt(str.substr(2), 16));
- } else if (str[0] === '#') {
- entity = String.fromCharCode(parseInt(str.substr(1), 10));
- } else {
- entity = XHTMLEntities[str];
+ // Well-formed entity (ending was found).
+ if (ch === ';') {
+ // Numeric entity.
+ if (str[0] === '#') {
+ if (str[1] === 'x') {
+ code = +('0' + str.substr(1));
+ } else {
+ // Removing leading zeros in order to avoid treating as octal in old browsers.
+ code = +str.substr(1).replace(Regex.LeadingZeros, '');
+ }
+
+ if (!isNaN(code)) {
+ return String.fromCharCode(code);
+ }
+ } else if (XHTMLEntities[str]) {
+ return XHTMLEntities[str];
+ }
}
- return entity;
+
+ // Treat non-entity sequences as regular text.
+ index = start + 1;
+ return '&';
}
function scanXJSText(stopChars) {
@@ -7296,6 +8726,11 @@ parseYieldExpression: true
str += scanXJSEntity();
} else {
index++;
+ if (ch === '\r' && source[index] === '\n') {
+ str += ch;
+ ch = source[index];
+ index++;
+ }
if (isLineTerminator(ch.charCodeAt(0))) {
++lineNumber;
lineStart = index;
@@ -7564,7 +8999,7 @@ parseYieldExpression: true
}
function parseXJSElement() {
- var openingElement, closingElement, children = [], origInXJSChild, origInXJSTag, marker = markerCreate();
+ var openingElement, closingElement = null, children = [], origInXJSChild, origInXJSTag, marker = markerCreate();
origInXJSChild = state.inXJSChild;
origInXJSTag = state.inXJSTag;
@@ -7603,8 +9038,181 @@ parseYieldExpression: true
return markerApply(marker, delegate.createXJSElement(openingElement, closingElement, children));
}
+ function parseTypeAlias() {
+ var id, marker = markerCreate(), typeParameters = null, right;
+ expectContextualKeyword('type');
+ id = parseVariableIdentifier();
+ if (match('<')) {
+ typeParameters = parseTypeParameterDeclaration();
+ }
+ expect('=');
+ right = parseType();
+ consumeSemicolon();
+ return markerApply(marker, delegate.createTypeAlias(id, typeParameters, right));
+ }
+
+ function parseInterfaceExtends() {
+ var marker = markerCreate(), id, typeParameters = null;
+
+ id = parseVariableIdentifier();
+ if (match('<')) {
+ typeParameters = parseTypeParameterInstantiation();
+ }
+
+ return markerApply(marker, delegate.createInterfaceExtends(
+ id,
+ typeParameters
+ ));
+ }
+
+ function parseInterfaceish(marker, allowStatic) {
+ var body, bodyMarker, extended = [], id,
+ typeParameters = null;
+
+ id = parseVariableIdentifier();
+ if (match('<')) {
+ typeParameters = parseTypeParameterDeclaration();
+ }
+
+ if (matchKeyword('extends')) {
+ expectKeyword('extends');
+
+ while (index < length) {
+ extended.push(parseInterfaceExtends());
+ if (!match(',')) {
+ break;
+ }
+ expect(',');
+ }
+ }
+
+ bodyMarker = markerCreate();
+ body = markerApply(bodyMarker, parseObjectType(allowStatic));
+
+ return markerApply(marker, delegate.createInterface(
+ id,
+ typeParameters,
+ body,
+ extended
+ ));
+ }
+
+ function parseInterface() {
+ var body, bodyMarker, extended = [], id, marker = markerCreate(),
+ typeParameters = null;
+
+ expectContextualKeyword('interface');
+ return parseInterfaceish(marker, /* allowStatic */false);
+ }
+
+ function parseDeclareClass() {
+ var marker = markerCreate(), ret;
+ expectContextualKeyword('declare');
+ expectKeyword('class');
+
+ ret = parseInterfaceish(marker, /* allowStatic */true);
+ ret.type = Syntax.DeclareClass;
+ return ret;
+ }
+
+ function parseDeclareFunction() {
+ var id, idMarker,
+ marker = markerCreate(), params, returnType, rest, tmp,
+ typeParameters = null, value, valueMarker;
+
+ expectContextualKeyword('declare');
+ expectKeyword('function');
+ idMarker = markerCreate();
+ id = parseVariableIdentifier();
+
+ valueMarker = markerCreate();
+ if (match('<')) {
+ typeParameters = parseTypeParameterDeclaration();
+ }
+ expect('(');
+ tmp = parseFunctionTypeParams();
+ params = tmp.params;
+ rest = tmp.rest;
+ expect(')');
+
+ expect(':');
+ returnType = parseType();
+
+ value = markerApply(valueMarker, delegate.createFunctionTypeAnnotation(
+ params,
+ returnType,
+ rest,
+ typeParameters
+ ));
+
+ id.typeAnnotation = markerApply(valueMarker, delegate.createTypeAnnotation(
+ value
+ ));
+ markerApply(idMarker, id);
+
+ consumeSemicolon();
+
+ return markerApply(marker, delegate.createDeclareFunction(
+ id
+ ));
+ }
+
+ function parseDeclareVariable() {
+ var id, marker = markerCreate();
+ expectContextualKeyword('declare');
+ expectKeyword('var');
+ id = parseTypeAnnotatableIdentifier();
+
+ consumeSemicolon();
+
+ return markerApply(marker, delegate.createDeclareVariable(
+ id
+ ));
+ }
+
+ function parseDeclareModule() {
+ var body = [], bodyMarker, id, idMarker, marker = markerCreate(), token;
+ expectContextualKeyword('declare');
+ expectContextualKeyword('module');
+
+ if (lookahead.type === Token.StringLiteral) {
+ if (strict && lookahead.octal) {
+ throwErrorTolerant(lookahead, Messages.StrictOctalLiteral);
+ }
+ idMarker = markerCreate();
+ id = markerApply(idMarker, delegate.createLiteral(lex()));
+ } else {
+ id = parseVariableIdentifier();
+ }
+
+ bodyMarker = markerCreate();
+ expect('{');
+ while (index < length && !match('}')) {
+ token = lookahead2();
+ switch (token.value) {
+ case 'class':
+ body.push(parseDeclareClass());
+ break;
+ case 'function':
+ body.push(parseDeclareFunction());
+ break;
+ case 'var':
+ body.push(parseDeclareVariable());
+ break;
+ default:
+ throwUnexpected(lookahead);
+ }
+ }
+ expect('}');
+
+ return markerApply(marker, delegate.createDeclareModule(
+ id,
+ markerApply(bodyMarker, delegate.createBlockStatement(body))
+ ));
+ }
+
function collectToken() {
- var start, loc, token, range, value;
+ var start, loc, token, range, value, entry;
if (!state.inXJSChild) {
skipComment();
@@ -7627,12 +9235,19 @@ parseYieldExpression: true
if (token.type !== Token.EOF) {
range = [token.range[0], token.range[1]];
value = source.slice(token.range[0], token.range[1]);
- extra.tokens.push({
+ entry = {
type: TokenName[token.type],
value: value,
range: range,
loc: loc
- });
+ };
+ if (token.regex) {
+ entry.regex = {
+ pattern: token.regex.pattern,
+ flags: token.regex.flags
+ };
+ }
+ extra.tokens.push(entry);
}
return token;
@@ -7671,6 +9286,7 @@ parseYieldExpression: true
extra.tokens.push({
type: 'RegularExpression',
value: regex.literal,
+ regex: regex.regex,
range: [pos, index],
loc: loc
});
@@ -7688,6 +9304,12 @@ parseYieldExpression: true
type: entry.type,
value: entry.value
};
+ if (entry.regex) {
+ token.regex = {
+ pattern: entry.regex.pattern,
+ flags: entry.regex.flags
+ };
+ }
if (extra.range) {
token.range = entry.range;
}
@@ -7874,14 +9496,17 @@ parseYieldExpression: true
inSwitch: false,
inXJSChild: false,
inXJSTag: false,
+ inType: false,
lastCommentStart: -1,
- yieldAllowed: false
+ yieldAllowed: false,
+ awaitAllowed: false
};
extra = {};
if (typeof options !== 'undefined') {
extra.range = (typeof options.range === 'boolean') && options.range;
extra.loc = (typeof options.loc === 'boolean') && options.loc;
+ extra.attachComment = (typeof options.attachComment === 'boolean') && options.attachComment;
if (extra.loc && options.source !== null && options.source !== undefined) {
delegate = extend(delegate, {
@@ -7901,6 +9526,13 @@ parseYieldExpression: true
if (typeof options.tolerant === 'boolean' && options.tolerant) {
extra.errors = [];
}
+ if (extra.attachComment) {
+ extra.range = true;
+ extra.comments = [];
+ extra.bottomRightStack = [];
+ extra.trailingComments = [];
+ extra.leadingComments = [];
+ }
}
if (length > 0) {
@@ -7938,7 +9570,7 @@ parseYieldExpression: true
}
// Sync with *.json manifests.
- exports.version = '4001.3001.0000-dev-harmony-fb';
+ exports.version = '8001.1001.0-dev-harmony-fb';
exports.tokenize = tokenize;
@@ -7968,35 +9600,7 @@ parseYieldExpression: true
}));
/* vim: set sw=4 ts=4 et tw=80 : */
-},{}],7:[function(_dereq_,module,exports){
-var Base62 = (function (my) {
- my.chars = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
-
- my.encode = function(i){
- if (i === 0) {return '0'}
- var s = ''
- while (i > 0) {
- s = this.chars[i % 62] + s
- i = Math.floor(i/62)
- }
- return s
- };
- my.decode = function(a,b,c,d){
- for (
- b = c = (
- a === (/\W|_|^$/.test(a += "") || a)
- ) - 1;
- d = a.charCodeAt(c++);
- )
- b = b * 62 + d - [, 48, 29, 87][d >> 5];
- return b
- };
-
- return my;
-}({}));
-
-module.exports = Base62
-},{}],8:[function(_dereq_,module,exports){
+},{}],10:[function(_dereq_,module,exports){
/*
* Copyright 2009-2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE.txt or:
@@ -8006,7 +9610,7 @@ exports.SourceMapGenerator = _dereq_('./source-map/source-map-generator').Source
exports.SourceMapConsumer = _dereq_('./source-map/source-map-consumer').SourceMapConsumer;
exports.SourceNode = _dereq_('./source-map/source-node').SourceNode;
-},{"./source-map/source-map-consumer":13,"./source-map/source-map-generator":14,"./source-map/source-node":15}],9:[function(_dereq_,module,exports){
+},{"./source-map/source-map-consumer":15,"./source-map/source-map-generator":16,"./source-map/source-node":17}],11:[function(_dereq_,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
@@ -8105,7 +9709,7 @@ define(function (_dereq_, exports, module) {
});
-},{"./util":16,"amdefine":17}],10:[function(_dereq_,module,exports){
+},{"./util":18,"amdefine":19}],12:[function(_dereq_,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
@@ -8251,7 +9855,7 @@ define(function (_dereq_, exports, module) {
});
-},{"./base64":11,"amdefine":17}],11:[function(_dereq_,module,exports){
+},{"./base64":13,"amdefine":19}],13:[function(_dereq_,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
@@ -8295,7 +9899,7 @@ define(function (_dereq_, exports, module) {
});
-},{"amdefine":17}],12:[function(_dereq_,module,exports){
+},{"amdefine":19}],14:[function(_dereq_,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
@@ -8378,7 +9982,7 @@ define(function (_dereq_, exports, module) {
});
-},{"amdefine":17}],13:[function(_dereq_,module,exports){
+},{"amdefine":19}],15:[function(_dereq_,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
@@ -8857,7 +10461,7 @@ define(function (_dereq_, exports, module) {
});
-},{"./array-set":9,"./base64-vlq":10,"./binary-search":12,"./util":16,"amdefine":17}],14:[function(_dereq_,module,exports){
+},{"./array-set":11,"./base64-vlq":12,"./binary-search":14,"./util":18,"amdefine":19}],16:[function(_dereq_,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
@@ -9239,7 +10843,7 @@ define(function (_dereq_, exports, module) {
});
-},{"./array-set":9,"./base64-vlq":10,"./util":16,"amdefine":17}],15:[function(_dereq_,module,exports){
+},{"./array-set":11,"./base64-vlq":12,"./util":18,"amdefine":19}],17:[function(_dereq_,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
@@ -9612,7 +11216,7 @@ define(function (_dereq_, exports, module) {
});
-},{"./source-map-generator":14,"./util":16,"amdefine":17}],16:[function(_dereq_,module,exports){
+},{"./source-map-generator":16,"./util":18,"amdefine":19}],18:[function(_dereq_,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
@@ -9819,7 +11423,7 @@ define(function (_dereq_, exports, module) {
});
-},{"amdefine":17}],17:[function(_dereq_,module,exports){
+},{"amdefine":19}],19:[function(_dereq_,module,exports){
(function (process,__filename){
/** vim: et:ts=4:sw=4:sts=4
* @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
@@ -10121,8 +11725,8 @@ function amdefine(module, requireFn) {
module.exports = amdefine;
-}).call(this,_dereq_("FWaASH"),"/../node_modules/jstransform/node_modules/source-map/node_modules/amdefine/amdefine.js")
-},{"FWaASH":5,"path":4}],18:[function(_dereq_,module,exports){
+}).call(this,_dereq_('_process'),"/node_modules/jstransform/node_modules/source-map/node_modules/amdefine/amdefine.js")
+},{"_process":7,"path":6}],20:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
*
@@ -10210,7 +11814,7 @@ exports.extract = extract;
exports.parse = parse;
exports.parseAsObject = parseAsObject;
-},{}],19:[function(_dereq_,module,exports){
+},{}],21:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
*
@@ -10268,7 +11872,6 @@ function _nodeIsBlockScopeBoundary(node, parentNode) {
/**
* @param {object} node
- * @param {function} visitor
* @param {array} path
* @param {object} state
*/
@@ -10464,8 +12067,9 @@ function transform(visitors, source, options) {
}
exports.transform = transform;
+exports.Syntax = Syntax;
-},{"./utils":20,"esprima-fb":6,"source-map":8}],20:[function(_dereq_,module,exports){
+},{"./utils":22,"esprima-fb":9,"source-map":10}],22:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
*
@@ -10916,8 +12520,8 @@ function initScopeMetadata(boundaryNode, path, node) {
function declareIdentInLocalScope(identName, metaData, state) {
state.localScope.identifiers[identName] = {
boundaryNode: metaData.boundaryNode,
- path: metaData.path,
- node: metaData.node,
+ path: metaData.bindingPath,
+ node: metaData.bindingNode,
state: Object.create(state)
};
}
@@ -10934,7 +12538,6 @@ function getLexicalBindingMetadata(identName, state) {
* @param {function} analyzer
* @param {function} traverser
* @param {object} node
- * @param {function} visitor
* @param {array} path
* @param {object} state
*/
@@ -11011,16 +12614,22 @@ function enqueueNodeWithStartIndex(queue, node) {
* @param {string} type - node type to lookup.
*/
function containsChildOfType(node, type) {
+ return containsChildMatching(node, function(node) {
+ return node.type === type;
+ });
+}
+
+function containsChildMatching(node, matcher) {
var foundMatchingChild = false;
function nodeTypeAnalyzer(node) {
- if (node.type === type) {
+ if (matcher(node) === true) {
foundMatchingChild = true;
return false;
}
}
function nodeTypeTraverser(child, path, state) {
if (!foundMatchingChild) {
- foundMatchingChild = containsChildOfType(child, type);
+ foundMatchingChild = containsChildMatching(child, matcher);
}
}
analyzeAndTraverse(
@@ -11049,11 +12658,20 @@ function getBoundaryNode(path) {
);
}
+function getTempVar(tempVarIndex) {
+ return '$__' + tempVarIndex;
+}
+
+function getTempVarWithValue(tempVarIndex, tempVarValue) {
+ return getTempVar(tempVarIndex) + '=' + tempVarValue;
+}
+
exports.append = append;
exports.catchup = catchup;
exports.catchupWhiteOut = catchupWhiteOut;
exports.catchupWhiteSpace = catchupWhiteSpace;
exports.catchupNewlines = catchupNewlines;
+exports.containsChildMatching = containsChildMatching;
exports.containsChildOfType = containsChildOfType;
exports.createState = createState;
exports.declareIdentInLocalScope = declareIdentInLocalScope;
@@ -11071,8 +12689,10 @@ exports.updateState = updateState;
exports.analyzeAndTraverse = analyzeAndTraverse;
exports.getOrderedChildren = getOrderedChildren;
exports.getNodeSourceText = getNodeSourceText;
+exports.getTempVar = getTempVar;
+exports.getTempVarWithValue = getTempVarWithValue;
-},{"./docblock":18,"esprima-fb":6}],21:[function(_dereq_,module,exports){
+},{"./docblock":20,"esprima-fb":9}],23:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
*
@@ -11147,7 +12767,14 @@ function visitArrowFunction(traverse, node, path, state) {
// Bind the function only if `this` value is used
// inside it or inside any sub-expression.
- if (utils.containsChildOfType(node.body, Syntax.ThisExpression)) {
+ var containsBindingSyntax =
+ utils.containsChildMatching(node.body, function(node) {
+ return node.type === Syntax.ThisExpression
+ || (node.type === Syntax.Identifier
+ && node.name === "super");
+ });
+
+ if (containsBindingSyntax) {
utils.append('.bind(this)', state);
}
@@ -11188,7 +12815,7 @@ function renderExpressionBody(traverse, node, path, state) {
// Special handling of rest param.
if (node.rest) {
utils.append(
- restParamVisitors.renderRestParamSetup(node),
+ restParamVisitors.renderRestParamSetup(node, state),
state
);
}
@@ -11225,7 +12852,7 @@ exports.visitorList = [
];
-},{"../src/utils":20,"./es6-destructuring-visitors":23,"./es6-rest-param-visitors":26,"esprima-fb":6}],22:[function(_dereq_,module,exports){
+},{"../src/utils":22,"./es6-destructuring-visitors":25,"./es6-rest-param-visitors":28,"esprima-fb":9}],24:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
*
@@ -11252,6 +12879,7 @@ exports.visitorList = [
var base62 = _dereq_('base62');
var Syntax = _dereq_('esprima-fb').Syntax;
var utils = _dereq_('../src/utils');
+var reservedWordsHelper = _dereq_('./reserved-words-helper');
var declareIdentInLocalScope = utils.declareIdentInLocalScope;
var initScopeMetadata = utils.initScopeMetadata;
@@ -11370,7 +12998,7 @@ function _shouldMungeIdentifier(node, state) {
* @param {object} state
*/
function visitClassMethod(traverse, node, path, state) {
- if (node.kind === 'get' || node.kind === 'set') {
+ if (!state.g.opts.es5 && (node.kind === 'get' || node.kind === 'set')) {
throw new Error(
'This transform does not support ' + node.kind + 'ter methods for ES6 ' +
'classes. (line: ' + node.loc.start.line + ', col: ' +
@@ -11398,6 +13026,8 @@ visitClassMethod.test = function(node, path, state) {
*/
function visitClassFunctionExpression(traverse, node, path, state) {
var methodNode = path[0];
+ var isGetter = methodNode.kind === 'get';
+ var isSetter = methodNode.kind === 'set';
state = utils.updateState(state, {
methodFuncNode: node
@@ -11408,6 +13038,7 @@ function visitClassFunctionExpression(traverse, node, path, state) {
} else {
var methodAccessor;
var prototypeOrStatic = methodNode["static"] ? '' : '.prototype';
+ var objectAccessor = state.className + prototypeOrStatic;
if (methodNode.key.type === Syntax.Identifier) {
// foo() {}
@@ -11415,24 +13046,44 @@ function visitClassFunctionExpression(traverse, node, path, state) {
if (_shouldMungeIdentifier(methodNode.key, state)) {
methodAccessor = _getMungedName(methodAccessor, state);
}
- methodAccessor = '.' + methodAccessor;
+ if (isGetter || isSetter) {
+ methodAccessor = JSON.stringify(methodAccessor);
+ } else if (reservedWordsHelper.isReservedWord(methodAccessor)) {
+ methodAccessor = '[' + JSON.stringify(methodAccessor) + ']';
+ } else {
+ methodAccessor = '.' + methodAccessor;
+ }
} else if (methodNode.key.type === Syntax.Literal) {
- // 'foo bar'() {}
- methodAccessor = '[' + JSON.stringify(methodNode.key.value) + ']';
+ // 'foo bar'() {} | get 'foo bar'() {} | set 'foo bar'() {}
+ methodAccessor = JSON.stringify(methodNode.key.value);
+ if (!(isGetter || isSetter)) {
+ methodAccessor = '[' + methodAccessor + ']';
+ }
}
- utils.append(
- state.className + prototypeOrStatic +
- methodAccessor + '=function',
- state
- );
+ if (isSetter || isGetter) {
+ utils.append(
+ 'Object.defineProperty(' +
+ objectAccessor + ',' +
+ methodAccessor + ',' +
+ '{enumerable:true,configurable:true,' +
+ methodNode.kind + ':function',
+ state
+ );
+ } else {
+ utils.append(
+ objectAccessor +
+ methodAccessor + '=function' + (node.generator ? '*' : ''),
+ state
+ );
+ }
}
utils.move(methodNode.key.range[1], state);
utils.append('(', state);
var params = node.params;
if (params.length > 0) {
- utils.move(params[0].range[0], state);
+ utils.catchupNewlines(params[0].range[0], state);
for (var i = 0; i < params.length; i++) {
utils.catchup(node.params[i].range[0], state);
path.unshift(node);
@@ -11457,6 +13108,9 @@ function visitClassFunctionExpression(traverse, node, path, state) {
utils.catchup(node.body.range[1], state);
if (methodNode.key.name !== 'constructor') {
+ if (isGetter || isSetter) {
+ utils.append('})', state);
+ }
utils.append(';', state);
}
return false;
@@ -11767,7 +13421,7 @@ exports.visitorList = [
visitSuperMemberExpression
];
-},{"../src/utils":20,"base62":7,"esprima-fb":6}],23:[function(_dereq_,module,exports){
+},{"../src/utils":22,"./reserved-words-helper":32,"base62":8,"esprima-fb":9}],25:[function(_dereq_,module,exports){
/**
* Copyright 2014 Facebook, Inc.
*
@@ -11810,7 +13464,9 @@ exports.visitorList = [
var Syntax = _dereq_('esprima-fb').Syntax;
var utils = _dereq_('../src/utils');
+var reservedWordsHelper = _dereq_('./reserved-words-helper');
var restParamVisitors = _dereq_('./es6-rest-param-visitors');
+var restPropertyHelpers = _dereq_('./es7-rest-property-helpers');
// -------------------------------------------------------
// 1. Structured variable declarations.
@@ -11821,7 +13477,7 @@ var restParamVisitors = _dereq_('./es6-rest-param-visitors');
function visitStructuredVariable(traverse, node, path, state) {
// Allocate new temp for the pattern.
- utils.append(getTmpVar(state.localScope.tempVarIndex) + '=', state);
+ utils.append(utils.getTempVar(state.localScope.tempVarIndex) + '=', state);
// Skip the pattern and assign the init to the temp.
utils.catchupWhiteSpace(node.init.range[0], state);
traverse(node.init, path, state);
@@ -11855,6 +13511,26 @@ function getDestructuredComponents(node, state) {
continue;
}
+ if (item.type === Syntax.SpreadElement) {
+ // Spread/rest of an array.
+ // TODO(dmitrys): support spread in the middle of a pattern
+ // and also for function param patterns: [x, ...xs, y]
+ components.push(item.argument.name +
+ '=Array.prototype.slice.call(' +
+ utils.getTempVar(tmpIndex) + ',' + idx + ')'
+ );
+ continue;
+ }
+
+ if (item.type === Syntax.SpreadProperty) {
+ var restExpression = restPropertyHelpers.renderRestExpression(
+ utils.getTempVar(tmpIndex),
+ patternItems
+ );
+ components.push(item.argument.name + '=' + restExpression);
+ continue;
+ }
+
// Depending on pattern type (Array or Object), we get
// corresponding pattern item parts.
var accessor = getPatternItemAccessor(node, item, tmpIndex, idx);
@@ -11864,19 +13540,11 @@ function getDestructuredComponents(node, state) {
if (value.type === Syntax.Identifier) {
// Simple pattern item.
components.push(value.name + '=' + accessor);
- } else if (value.type === Syntax.SpreadElement) {
- // Spread/rest of an array.
- // TODO(dmitrys): support spread in the middle of a pattern
- // and also for function param patterns: [x, ...xs, y]
- components.push(value.argument.name +
- '=Array.prototype.slice.call(' +
- getTmpVar(tmpIndex) + ',' + idx + ')'
- );
} else {
// Complex sub-structure.
components.push(
- getInitialValue(++state.localScope.tempVarIndex, accessor) + ',' +
- getDestructuredComponents(value, state)
+ utils.getTempVarWithValue(++state.localScope.tempVarIndex, accessor) +
+ ',' + getDestructuredComponents(value, state)
);
}
}
@@ -11889,10 +13557,18 @@ function getPatternItems(node) {
}
function getPatternItemAccessor(node, patternItem, tmpIndex, idx) {
- var tmpName = getTmpVar(tmpIndex);
- return node.type === Syntax.ObjectPattern
- ? tmpName + '.' + patternItem.key.name
- : tmpName + '[' + idx + ']';
+ var tmpName = utils.getTempVar(tmpIndex);
+ if (node.type === Syntax.ObjectPattern) {
+ if (reservedWordsHelper.isReservedWord(patternItem.key.name)) {
+ return tmpName + '["' + patternItem.key.name + '"]';
+ } else if (patternItem.key.type === Syntax.Literal) {
+ return tmpName + '[' + JSON.stringify(patternItem.key.value) + ']';
+ } else if (patternItem.key.type === Syntax.Identifier) {
+ return tmpName + '.' + patternItem.key.name;
+ }
+ } else if (node.type === Syntax.ArrayPattern) {
+ return tmpName + '[' + idx + ']';
+ }
}
function getPatternItemValue(node, patternItem) {
@@ -11901,14 +13577,6 @@ function getPatternItemValue(node, patternItem) {
: patternItem;
}
-function getInitialValue(index, value) {
- return getTmpVar(index) + '=' + value;
-}
-
-function getTmpVar(index) {
- return '$__' + index;
-}
-
// -------------------------------------------------------
// 2. Assignment expression.
//
@@ -11918,14 +13586,14 @@ function getTmpVar(index) {
function visitStructuredAssignment(traverse, node, path, state) {
var exprNode = node.expression;
- utils.append('var ' + getTmpVar(state.localScope.tempVarIndex) + '=', state);
+ utils.append('var ' + utils.getTempVar(state.localScope.tempVarIndex) + '=', state);
utils.catchupWhiteSpace(exprNode.right.range[0], state);
traverse(exprNode.right, path, state);
utils.catchup(exprNode.right.range[1], state);
utils.append(
- ',' + getDestructuredComponents(exprNode.left, state) + ';',
+ ';' + getDestructuredComponents(exprNode.left, state) + ';',
state
);
@@ -11950,7 +13618,7 @@ visitStructuredAssignment.test = function(node, path, state) {
// -------------------------------------------------------
function visitStructuredParameter(traverse, node, path, state) {
- utils.append(getTmpVar(getParamIndex(node, path)), state);
+ utils.append(utils.getTempVar(getParamIndex(node, path)), state);
utils.catchupWhiteSpace(node.range[1], state);
return true;
}
@@ -11995,7 +13663,7 @@ function visitFunctionBodyForStructuredParameter(traverse, node, path, state) {
if (funcNode.rest) {
utils.append(
- restParamVisitors.renderRestParamSetup(funcNode),
+ restParamVisitors.renderRestParamSetup(funcNode, state),
state
);
}
@@ -12035,7 +13703,7 @@ exports.visitorList = [
exports.renderDestructuredComponents = renderDestructuredComponents;
-},{"../src/utils":20,"./es6-rest-param-visitors":26,"esprima-fb":6}],24:[function(_dereq_,module,exports){
+},{"../src/utils":22,"./es6-rest-param-visitors":28,"./es7-rest-property-helpers":30,"./reserved-words-helper":32,"esprima-fb":9}],26:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
*
@@ -12055,7 +13723,7 @@ exports.renderDestructuredComponents = renderDestructuredComponents;
/*jslint node:true*/
/**
- * Desugars concise methods of objects to ES3 function expressions.
+ * Desugars concise methods of objects to function expressions.
*
* var foo = {
* method(x, y) { ... }
@@ -12069,10 +13737,27 @@ exports.renderDestructuredComponents = renderDestructuredComponents;
var Syntax = _dereq_('esprima-fb').Syntax;
var utils = _dereq_('../src/utils');
+var reservedWordsHelper = _dereq_('./reserved-words-helper');
function visitObjectConciseMethod(traverse, node, path, state) {
+ var isGenerator = node.value.generator;
+ if (isGenerator) {
+ utils.catchupWhiteSpace(node.range[0] + 1, state);
+ }
+ if (node.computed) { // [<expr>]() { ...}
+ utils.catchup(node.key.range[1] + 1, state);
+ } else if (reservedWordsHelper.isReservedWord(node.key.name)) {
+ utils.catchup(node.key.range[0], state);
+ utils.append('"', state);
+ utils.catchup(node.key.range[1], state);
+ utils.append('"', state);
+ }
+
utils.catchup(node.key.range[1], state);
- utils.append(':function', state);
+ utils.append(
+ ':function' + (isGenerator ? '*' : ''),
+ state
+ );
path.unshift(node);
traverse(node.value, path, state);
path.shift();
@@ -12089,7 +13774,7 @@ exports.visitorList = [
visitObjectConciseMethod
];
-},{"../src/utils":20,"esprima-fb":6}],25:[function(_dereq_,module,exports){
+},{"../src/utils":22,"./reserved-words-helper":32,"esprima-fb":9}],27:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
*
@@ -12116,7 +13801,7 @@ exports.visitorList = [
* return {x, y}; // {x: x, y: y}
* };
*
- * // Destrucruting.
+ * // Destructuring.
* function init({port, ip, coords: {x, y}}) { ... }
*
*/
@@ -12144,7 +13829,7 @@ exports.visitorList = [
];
-},{"../src/utils":20,"esprima-fb":6}],26:[function(_dereq_,module,exports){
+},{"../src/utils":22,"esprima-fb":9}],28:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
*
@@ -12164,16 +13849,20 @@ exports.visitorList = [
/*jslint node:true*/
/**
- * Desugars ES6 rest parameters into ES3 arguments slicing.
+ * Desugars ES6 rest parameters into an ES3 arguments array.
*
* function printf(template, ...args) {
* args.forEach(...);
- * };
+ * }
+ *
+ * We could use `Array.prototype.slice.call`, but that usage of arguments causes
+ * functions to be deoptimized in V8, so instead we use a for-loop.
*
* function printf(template) {
- * var args = [].slice.call(arguments, 1);
+ * for (var args = [], $__0 = 1, $__1 = arguments.length; $__0 < $__1; $__0++)
+ * args.push(arguments[$__0]);
* args.forEach(...);
- * };
+ * }
*
*/
var Syntax = _dereq_('esprima-fb').Syntax;
@@ -12218,17 +13907,22 @@ visitFunctionParamsWithRestParam.test = function(node, path, state) {
return _nodeIsFunctionWithRestParam(node);
};
-function renderRestParamSetup(functionNode) {
- return 'var ' + functionNode.rest.name + '=Array.prototype.slice.call(' +
- 'arguments,' +
- functionNode.params.length +
- ');';
+function renderRestParamSetup(functionNode, state) {
+ var idx = state.localScope.tempVarIndex++;
+ var len = state.localScope.tempVarIndex++;
+
+ return 'for (var ' + functionNode.rest.name + '=[],' +
+ utils.getTempVarWithValue(idx, functionNode.params.length) + ',' +
+ utils.getTempVarWithValue(len, 'arguments.length') + ';' +
+ utils.getTempVar(idx) + '<' + utils.getTempVar(len) + ';' +
+ utils.getTempVar(idx) + '++) ' +
+ functionNode.rest.name + '.push(arguments[' + utils.getTempVar(idx) + ']);';
}
function visitFunctionBodyWithRestParam(traverse, node, path, state) {
utils.catchup(node.range[0] + 1, state);
var parentNode = path[0];
- utils.append(renderRestParamSetup(parentNode), state);
+ utils.append(renderRestParamSetup(parentNode, state), state);
return true;
}
@@ -12243,7 +13937,7 @@ exports.visitorList = [
visitFunctionBodyWithRestParam
];
-},{"../src/utils":20,"esprima-fb":6}],27:[function(_dereq_,module,exports){
+},{"../src/utils":22,"esprima-fb":9}],29:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
*
@@ -12401,9 +14095,9 @@ exports.visitorList = [
visitTaggedTemplateExpression
];
-},{"../src/utils":20,"esprima-fb":6}],28:[function(_dereq_,module,exports){
+},{"../src/utils":22,"esprima-fb":9}],30:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12417,319 +14111,186 @@ exports.visitorList = [
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/* jshint browser: true */
-/* jslint evil: true */
-
-'use strict';
-var buffer = _dereq_('buffer');
-var docblock = _dereq_('jstransform/src/docblock');
-var transform = _dereq_('jstransform').transform;
-var visitors = _dereq_('./fbtransform/visitors');
-
-var headEl;
-var dummyAnchor;
-var inlineScriptCount = 0;
-
-// The source-map library relies on Object.defineProperty, but IE8 doesn't
-// support it fully even with es5-sham. Indeed, es5-sham's defineProperty
-// throws when Object.prototype.__defineGetter__ is missing, so we skip building
-// the source map in that case.
-var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
+/*jslint node:true*/
/**
- * Run provided code through jstransform.
- *
- * @param {string} source Original source code
- * @param {object?} options Options to pass to jstransform
- * @return {object} object as returned from jstransform
+ * Desugars ES7 rest properties into ES5 object iteration.
*/
-function transformReact(source, options) {
- // TODO: just use react-tools
- var visitorList;
- if (options && options.harmony) {
- visitorList = visitors.getAllVisitors();
- } else {
- visitorList = visitors.transformVisitors.react;
+
+var Syntax = _dereq_('esprima-fb').Syntax;
+var utils = _dereq_('../src/utils');
+
+// TODO: This is a pretty massive helper, it should only be defined once, in the
+// transform's runtime environment. We don't currently have a runtime though.
+var restFunction =
+ '(function(source, exclusion) {' +
+ 'var rest = {};' +
+ 'var hasOwn = Object.prototype.hasOwnProperty;' +
+ 'if (source == null) {' +
+ 'throw new TypeError();' +
+ '}' +
+ 'for (var key in source) {' +
+ 'if (hasOwn.call(source, key) && !hasOwn.call(exclusion, key)) {' +
+ 'rest[key] = source[key];' +
+ '}' +
+ '}' +
+ 'return rest;' +
+ '})';
+
+function getPropertyNames(properties) {
+ var names = [];
+ for (var i = 0; i < properties.length; i++) {
+ var property = properties[i];
+ if (property.type === Syntax.SpreadProperty) {
+ continue;
+ }
+ if (property.type === Syntax.Identifier) {
+ names.push(property.name);
+ } else {
+ names.push(property.key.name);
+ }
}
+ return names;
+}
- return transform(visitorList, source, {
- sourceMap: supportsAccessors
- });
+function getRestFunctionCall(source, exclusion) {
+ return restFunction + '(' + source + ',' + exclusion + ')';
+}
+
+function getSimpleShallowCopy(accessorExpression) {
+ // This could be faster with 'Object.assign({}, ' + accessorExpression + ')'
+ // but to unify code paths and avoid a ES6 dependency we use the same
+ // helper as for the exclusion case.
+ return getRestFunctionCall(accessorExpression, '{}');
+}
+
+function renderRestExpression(accessorExpression, excludedProperties) {
+ var excludedNames = getPropertyNames(excludedProperties);
+ if (!excludedNames.length) {
+ return getSimpleShallowCopy(accessorExpression);
+ }
+ return getRestFunctionCall(
+ accessorExpression,
+ '{' + excludedNames.join(':1,') + ':1}'
+ );
}
+exports.renderRestExpression = renderRestExpression;
+
+},{"../src/utils":22,"esprima-fb":9}],31:[function(_dereq_,module,exports){
/**
- * Eval provided source after transforming it.
- *
- * @param {string} source Original source code
- * @param {object?} options Options to pass to jstransform
+ * Copyright 2004-present Facebook. All Rights Reserved.
*/
-function exec(source, options) {
- return eval(transformReact(source, options).code);
-}
+/*global exports:true*/
/**
- * This method returns a nicely formated line of code pointing to the exact
- * location of the error `e`. The line is limited in size so big lines of code
- * are also shown in a readable way.
+ * Implements ES7 object spread property.
+ * https://gist.github.com/sebmarkbage/aa849c7973cb4452c547
*
- * Example:
- * ... x', overflow:'scroll'}} id={} onScroll={this.scroll} class=" ...
- * ^
+ * { ...a, x: 1 }
+ *
+ * Object.assign({}, a, {x: 1 })
*
- * @param {string} code The full string of code
- * @param {Error} e The error being thrown
- * @return {string} formatted message
- * @internal
*/
-function createSourceCodeErrorMessage(code, e) {
- var sourceLines = code.split('\n');
- var erroneousLine = sourceLines[e.lineNumber - 1];
- // Removes any leading indenting spaces and gets the number of
- // chars indenting the `erroneousLine`
- var indentation = 0;
- erroneousLine = erroneousLine.replace(/^\s+/, function(leadingSpaces) {
- indentation = leadingSpaces.length;
- return '';
- });
+var Syntax = _dereq_('esprima-fb').Syntax;
+var utils = _dereq_('../src/utils');
- // Defines the number of characters that are going to show
- // before and after the erroneous code
- var LIMIT = 30;
- var errorColumn = e.column - indentation;
+function visitObjectLiteralSpread(traverse, node, path, state) {
+ utils.catchup(node.range[0], state);
- if (errorColumn > LIMIT) {
- erroneousLine = '... ' + erroneousLine.slice(errorColumn - LIMIT);
- errorColumn = 4 + LIMIT;
- }
- if (erroneousLine.length - errorColumn > LIMIT) {
- erroneousLine = erroneousLine.slice(0, errorColumn + LIMIT) + ' ...';
- }
- var message = '\n\n' + erroneousLine + '\n';
- message += new Array(errorColumn - 1).join(' ') + '^';
- return message;
-}
+ utils.append('Object.assign({', state);
-/**
- * Actually transform the code.
- *
- * @param {string} code
- * @param {string?} url
- * @param {object?} options
- * @return {string} The transformed code.
- * @internal
- */
-function transformCode(code, url, options) {
- var jsx = docblock.parseAsObject(docblock.extract(code)).jsx;
-
- if (jsx) {
- try {
- var transformed = transformReact(code, options);
- } catch(e) {
- e.message += '\n at ';
- if (url) {
- if ('fileName' in e) {
- // We set `fileName` if it's supported by this error object and
- // a `url` was provided.
- // The error will correctly point to `url` in Firefox.
- e.fileName = url;
- }
- e.message += url + ':' + e.lineNumber + ':' + e.column;
- } else {
- e.message += location.href;
- }
- e.message += createSourceCodeErrorMessage(code, e);
- throw e;
- }
+ // Skip the original {
+ utils.move(node.range[0] + 1, state);
- if (!transformed.sourceMap) {
- return transformed.code;
- }
+ var previousWasSpread = false;
+
+ for (var i = 0; i < node.properties.length; i++) {
+ var property = node.properties[i];
+ if (property.type === Syntax.SpreadProperty) {
- var map = transformed.sourceMap.toJSON();
- var source;
- if (url == null) {
- source = "Inline JSX script";
- inlineScriptCount++;
- if (inlineScriptCount > 1) {
- source += ' (' + inlineScriptCount + ')';
+ // Close the previous object or initial object
+ if (!previousWasSpread) {
+ utils.append('}', state);
}
- } else if (dummyAnchor) {
- // Firefox has problems when the sourcemap source is a proper URL with a
- // protocol and hostname, so use the pathname. We could use just the
- // filename, but hopefully using the full path will prevent potential
- // issues where the same filename exists in multiple directories.
- dummyAnchor.href = url;
- source = dummyAnchor.pathname.substr(1);
- }
- map.sources = [source];
- map.sourcesContent = [code];
-
- return (
- transformed.code +
- '\n//# sourceMappingURL=data:application/json;base64,' +
- buffer.Buffer(JSON.stringify(map)).toString('base64')
- );
- } else {
- // TODO: warn that we found a script tag missing the docblock?
- // or warn and proceed anyway?
- // or warn, add it ourselves, and proceed anyway?
- return code;
- }
-}
+ if (i === 0) {
+ // Normally there will be a comma when we catch up, but not before
+ // the first property.
+ utils.append(',', state);
+ }
-/**
- * Appends a script element at the end of the <head> with the content of code,
- * after transforming it.
- *
- * @param {string} code The original source code
- * @param {string?} url Where the code came from. null if inline
- * @param {object?} options Options to pass to jstransform
- * @internal
- */
-function run(code, url, options) {
- var scriptEl = document.createElement('script');
- scriptEl.text = transformCode(code, url, options);
- headEl.appendChild(scriptEl);
-}
+ utils.catchup(property.range[0], state);
-/**
- * Load script from the provided url and pass the content to the callback.
- *
- * @param {string} url The location of the script src
- * @param {function} callback Function to call with the content of url
- * @internal
- */
-function load(url, callback) {
- var xhr;
- xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP')
- : new XMLHttpRequest();
+ // skip ...
+ utils.move(property.range[0] + 3, state);
- // async, however scripts will be executed in the order they are in the
- // DOM to mirror normal script loading.
- xhr.open('GET', url, true);
- if ('overrideMimeType' in xhr) {
- xhr.overrideMimeType('text/plain');
- }
- xhr.onreadystatechange = function() {
- if (xhr.readyState === 4) {
- if (xhr.status === 0 || xhr.status === 200) {
- callback(xhr.responseText, url);
- } else {
- throw new Error("Could not load " + url);
- }
- }
- };
- return xhr.send(null);
-}
+ traverse(property.argument, path, state);
-/**
- * Loop over provided script tags and get the content, via innerHTML if an
- * inline script, or by using XHR. Transforms are applied if needed. The scripts
- * are executed in the order they are found on the page.
- *
- * @param {array} scripts The <script> elements to load and run.
- * @internal
- */
-function loadScripts(scripts) {
- var result = scripts.map(function() {
- return false;
- });
- var count = result.length;
+ utils.catchup(property.range[1], state);
- function check() {
- var script, i;
+ previousWasSpread = true;
- for (i = 0; i < count; i++) {
- script = result[i];
+ } else {
- if (script && !script.executed) {
- run(script.content, script.url, script.options);
- script.executed = true;
- } else if (!script) {
- break;
+ utils.catchup(property.range[0], state);
+
+ if (previousWasSpread) {
+ utils.append('{', state);
}
- }
- }
- scripts.forEach(function(script, i) {
- var options;
- if (script.type.indexOf('harmony=true') !== -1) {
- options = {
- harmony: true
- };
- }
+ traverse(property, path, state);
- if (script.src) {
- load(script.src, function(content, url) {
- result[i] = {
- executed: false,
- content: content,
- url: url,
- options: options
- };
- check();
- });
- } else {
- result[i] = {
- executed: false,
- content: script.innerHTML,
- url: null,
- options: options
- };
- check();
- }
- });
-}
+ utils.catchup(property.range[1], state);
-/**
- * Find and run all script tags with type="text/jsx".
- *
- * @internal
- */
-function runScripts() {
- var scripts = document.getElementsByTagName('script');
+ previousWasSpread = false;
- // Array.prototype.slice cannot be used on NodeList on IE8
- var jsxScripts = [];
- for (var i = 0; i < scripts.length; i++) {
- if (scripts.item(i).type.indexOf('text/jsx') !== -1) {
- jsxScripts.push(scripts.item(i));
}
}
- console.warn(
- 'You are using the in-browser JSX transformer. Be sure to precompile ' +
- 'your JSX for production - ' +
- 'http://facebook.github.io/react/docs/tooling-integration.html#jsx'
- );
-
- loadScripts(jsxScripts);
-}
+ // Strip any non-whitespace between the last item and the end.
+ // We only catch up on whitespace so that we ignore any trailing commas which
+ // are stripped out for IE8 support. Unfortunately, this also strips out any
+ // trailing comments.
+ utils.catchupWhiteSpace(node.range[1] - 1, state);
-// Listen for load event if we're in a browser and then kick off finding and
-// running of scripts.
-if (typeof window !== "undefined" && window !== null) {
- headEl = document.getElementsByTagName('head')[0];
- dummyAnchor = document.createElement('a');
+ // Skip the trailing }
+ utils.move(node.range[1], state);
- if (window.addEventListener) {
- window.addEventListener('DOMContentLoaded', runScripts, false);
- } else {
- window.attachEvent('onload', runScripts);
+ if (!previousWasSpread) {
+ utils.append('}', state);
}
+
+ utils.append(')', state);
+ return false;
}
-module.exports = {
- transform: transformReact,
- exec: exec
+visitObjectLiteralSpread.test = function(node, path, state) {
+ if (node.type !== Syntax.ObjectExpression) {
+ return false;
+ }
+ // Tight loop optimization
+ var hasAtLeastOneSpreadProperty = false;
+ for (var i = 0; i < node.properties.length; i++) {
+ var property = node.properties[i];
+ if (property.type === Syntax.SpreadProperty) {
+ hasAtLeastOneSpreadProperty = true;
+ } else if (property.kind !== 'init') {
+ return false;
+ }
+ }
+ return hasAtLeastOneSpreadProperty;
};
-},{"./fbtransform/visitors":32,"buffer":1,"jstransform":19,"jstransform/src/docblock":18}],29:[function(_dereq_,module,exports){
+exports.visitorList = [
+ visitObjectLiteralSpread
+];
+
+},{"../src/utils":22,"esprima-fb":9}],32:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -12743,10 +14304,203 @@ module.exports = {
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+var KEYWORDS = [
+ 'break', 'do', 'in', 'typeof', 'case', 'else', 'instanceof', 'var', 'catch',
+ 'export', 'new', 'void', 'class', 'extends', 'return', 'while', 'const',
+ 'finally', 'super', 'with', 'continue', 'for', 'switch', 'yield', 'debugger',
+ 'function', 'this', 'default', 'if', 'throw', 'delete', 'import', 'try'
+];
+
+var FUTURE_RESERVED_WORDS = [
+ 'enum', 'await', 'implements', 'package', 'protected', 'static', 'interface',
+ 'private', 'public'
+];
+
+var LITERALS = [
+ 'null',
+ 'true',
+ 'false'
+];
+
+// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-reserved-words
+var RESERVED_WORDS = [].concat(
+ KEYWORDS,
+ FUTURE_RESERVED_WORDS,
+ LITERALS
+);
+
+var reservedWordsMap = Object.create(null);
+RESERVED_WORDS.forEach(function(k) {
+ reservedWordsMap[k] = true;
+});
+
+exports.isReservedWord = function(word) {
+ return !!reservedWordsMap[word];
+};
+
+},{}],33:[function(_dereq_,module,exports){
+var esprima = _dereq_('esprima-fb');
+var utils = _dereq_('../src/utils');
+
+var Syntax = esprima.Syntax;
+
+function _isFunctionNode(node) {
+ return node.type === Syntax.FunctionDeclaration
+ || node.type === Syntax.FunctionExpression
+ || node.type === Syntax.ArrowFunctionExpression;
+}
+
+function visitClassProperty(traverse, node, path, state) {
+ utils.catchup(node.range[0], state);
+ utils.catchupWhiteOut(node.range[1], state);
+ return false;
+}
+visitClassProperty.test = function(node, path, state) {
+ return node.type === Syntax.ClassProperty;
+};
+
+function visitTypeAlias(traverse, node, path, state) {
+ utils.catchupWhiteOut(node.range[1], state);
+ return false;
+}
+visitTypeAlias.test = function(node, path, state) {
+ return node.type === Syntax.TypeAlias;
+};
+
+function visitInterfaceDeclaration(traverse, node, path, state) {
+ utils.catchupWhiteOut(node.range[1], state);
+ return false;
+}
+visitInterfaceDeclaration.test = function(node, path, state) {
+ return node.type === Syntax.InterfaceDeclaration;
+};
+
+function visitDeclare(traverse, node, path, state) {
+ utils.catchupWhiteOut(node.range[1], state);
+ return false;
+}
+visitDeclare.test = function(node, path, state) {
+ switch (node.type) {
+ case Syntax.DeclareVariable:
+ case Syntax.DeclareFunction:
+ case Syntax.DeclareClass:
+ case Syntax.DeclareModule: return true
+ }
+ return false;
+}
+
+function visitFunctionParametricAnnotation(traverse, node, path, state) {
+ utils.catchup(node.range[0], state);
+ utils.catchupWhiteOut(node.range[1], state);
+ return false;
+}
+visitFunctionParametricAnnotation.test = function(node, path, state) {
+ return node.type === Syntax.TypeParameterDeclaration
+ && path[0]
+ && _isFunctionNode(path[0])
+ && node === path[0].typeParameters;
+};
+
+function visitFunctionReturnAnnotation(traverse, node, path, state) {
+ utils.catchup(node.range[0], state);
+ utils.catchupWhiteOut(node.range[1], state);
+ return false;
+}
+visitFunctionReturnAnnotation.test = function(node, path, state) {
+ return path[0] && _isFunctionNode(path[0]) && node === path[0].returnType;
+};
+
+function visitOptionalFunctionParameterAnnotation(traverse, node, path, state) {
+ utils.catchup(node.range[0] + node.name.length, state);
+ utils.catchupWhiteOut(node.range[1], state);
+ return false;
+}
+visitOptionalFunctionParameterAnnotation.test = function(node, path, state) {
+ return node.type === Syntax.Identifier
+ && node.optional
+ && path[0]
+ && _isFunctionNode(path[0]);
+};
+
+function visitTypeAnnotatedIdentifier(traverse, node, path, state) {
+ utils.catchup(node.typeAnnotation.range[0], state);
+ utils.catchupWhiteOut(node.typeAnnotation.range[1], state);
+ return false;
+}
+visitTypeAnnotatedIdentifier.test = function(node, path, state) {
+ return node.type === Syntax.Identifier && node.typeAnnotation;
+};
+
+function visitTypeAnnotatedObjectOrArrayPattern(traverse, node, path, state) {
+ utils.catchup(node.typeAnnotation.range[0], state);
+ utils.catchupWhiteOut(node.typeAnnotation.range[1], state);
+ return false;
+}
+visitTypeAnnotatedObjectOrArrayPattern.test = function(node, path, state) {
+ var rightType = node.type === Syntax.ObjectPattern
+ || node.type === Syntax.ArrayPattern;
+ return rightType && node.typeAnnotation;
+};
+
+/**
+ * Methods cause trouble, since esprima parses them as a key/value pair, where
+ * the location of the value starts at the method body. For example
+ * { bar(x:number,...y:Array<number>):number {} }
+ * is parsed as
+ * { bar: function(x: number, ...y:Array<number>): number {} }
+ * except that the location of the FunctionExpression value is 40-something,
+ * which is the location of the function body. This means that by the time we
+ * visit the params, rest param, and return type organically, we've already
+ * catchup()'d passed them.
+ */
+function visitMethod(traverse, node, path, state) {
+ path.unshift(node);
+ traverse(node.key, path, state);
+
+ path.unshift(node.value);
+ traverse(node.value.params, path, state);
+ node.value.rest && traverse(node.value.rest, path, state);
+ node.value.returnType && traverse(node.value.returnType, path, state);
+ traverse(node.value.body, path, state);
+
+ path.shift();
+
+ path.shift();
+ return false;
+}
+
+visitMethod.test = function(node, path, state) {
+ return (node.type === "Property" && (node.method || node.kind === "set" || node.kind === "get"))
+ || (node.type === "MethodDefinition");
+};
+
+exports.visitorList = [
+ visitClassProperty,
+ visitDeclare,
+ visitInterfaceDeclaration,
+ visitFunctionParametricAnnotation,
+ visitFunctionReturnAnnotation,
+ visitMethod,
+ visitOptionalFunctionParameterAnnotation,
+ visitTypeAlias,
+ visitTypeAnnotatedIdentifier,
+ visitTypeAnnotatedObjectOrArrayPattern
+];
+
+},{"../src/utils":22,"esprima-fb":9}],34:[function(_dereq_,module,exports){
+/**
+ * Copyright 2013-2014, 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.
+ */
/*global exports:true*/
"use strict";
-var Syntax = _dereq_('esprima-fb').Syntax;
+var Syntax = _dereq_('jstransform').Syntax;
var utils = _dereq_('jstransform/src/utils');
var FALLBACK_TAGS = _dereq_('./xjs').knownTags;
@@ -12758,27 +14512,16 @@ var quoteAttrName = _dereq_('./xjs').quoteAttrName;
var trimLeft = _dereq_('./xjs').trimLeft;
/**
- * Customized desugar processor.
- *
- * Currently: (Somewhat tailored to React)
- * <X> </X> => X(null, null)
- * <X prop="1" /> => X({prop: '1'}, null)
- * <X prop="2"><Y /></X> => X({prop:'2'}, Y(null, null))
- * <X prop="2"><Y /><Z /></X> => X({prop:'2'}, [Y(null, null), Z(null, null)])
+ * Customized desugar processor for React JSX. Currently:
*
- * Exceptions to the simple rules above:
- * if a property is named "class" it will be changed to "className" in the
- * javascript since "class" is not a valid object key in javascript.
+ * <X> </X> => React.createElement(X, null)
+ * <X prop="1" /> => React.createElement(X, {prop: '1'}, null)
+ * <X prop="2"><Y /></X> => React.createElement(X, {prop:'2'},
+ * React.createElement(Y, null)
+ * )
+ * <div /> => React.createElement("div", null)
*/
-var JSX_ATTRIBUTE_TRANSFORMS = {
- cxName: function(attr) {
- throw new Error(
- "cxName is no longer supported, use className={cx(...)} instead"
- );
- }
-};
-
/**
* Removes all non-whitespace/parenthesis characters
*/
@@ -12787,8 +14530,12 @@ function stripNonWhiteParen(value) {
return value.replace(reNonWhiteParen, '');
}
+var tagConvention = /^[a-z]|\-/;
+function isTagName(name) {
+ return tagConvention.test(name);
+}
+
function visitReactTag(traverse, object, path, state) {
- var jsxObjIdent = utils.getDocblock(state).jsx;
var openingElement = object.openingElement;
var nameObject = openingElement.name;
var attributesObject = openingElement.attributes;
@@ -12799,44 +14546,31 @@ function visitReactTag(traverse, object, path, state) {
throw new Error('Namespace tags are not supported. ReactJSX is not XML.');
}
- // Only identifiers can be fallback tags or need quoting. We don't need to
- // handle quoting for other types.
- var didAddTag = false;
-
- // Only identifiers can be fallback tags. XJSMemberExpressions are not.
- if (nameObject.type === Syntax.XJSIdentifier) {
- var tagName = nameObject.name;
- var quotedTagName = quoteAttrName(tagName);
-
- if (FALLBACK_TAGS.hasOwnProperty(tagName)) {
- // "Properly" handle invalid identifiers, like <font-face>, which needs to
- // be enclosed in quotes.
- var predicate =
- tagName === quotedTagName ?
- ('.' + tagName) :
- ('[' + quotedTagName + ']');
- utils.append(jsxObjIdent + predicate, state);
- utils.move(nameObject.range[1], state);
- didAddTag = true;
- } else if (tagName !== quotedTagName) {
- // If we're in the case where we need to quote and but don't recognize the
- // tag, throw.
+ // We assume that the React runtime is already in scope
+ utils.append('React.createElement(', state);
+
+ // Identifiers with lower case or hypthens are fallback tags (strings).
+ // XJSMemberExpressions are not.
+ if (nameObject.type === Syntax.XJSIdentifier && isTagName(nameObject.name)) {
+ // This is a temporary error message to assist upgrades
+ if (!FALLBACK_TAGS.hasOwnProperty(nameObject.name)) {
throw new Error(
- 'Tags must be valid JS identifiers or a recognized special case. `<' +
- tagName + '>` is not one of them.'
+ 'Lower case component names (' + nameObject.name + ') are no longer ' +
+ 'supported in JSX: See http://fb.me/react-jsx-lower-case'
);
}
- }
- // Use utils.catchup in this case so we can easily handle XJSMemberExpressions
- // which look like Foo.Bar.Baz. This also handles unhyphenated XJSIdentifiers
- // that aren't fallback tags.
- if (!didAddTag) {
+ utils.append('"' + nameObject.name + '"', state);
+ utils.move(nameObject.range[1], state);
+ } else {
+ // Use utils.catchup in this case so we can easily handle
+ // XJSMemberExpressions which look like Foo.Bar.Baz. This also handles
+ // XJSIdentifiers that aren't fallback tags.
utils.move(nameObject.range[0], state);
utils.catchup(nameObject.range[1], state);
}
- utils.append('(', state);
+ utils.append(', ', state);
var hasAttributes = attributesObject.length;
@@ -12846,7 +14580,7 @@ function visitReactTag(traverse, object, path, state) {
// if we don't have any attributes, pass in null
if (hasAtLeastOneSpreadProperty) {
- utils.append('Object.assign({', state);
+ utils.append('React.__spread({', state);
} else if (hasAttributes) {
utils.append('{', state);
} else {
@@ -12861,9 +14595,6 @@ function visitReactTag(traverse, object, path, state) {
var isLast = index === attributesObject.length - 1;
if (attr.type === Syntax.XJSSpreadAttribute) {
- // Plus 1 to skip `{`.
- utils.move(attr.range[0] + 1, state);
-
// Close the previous object or initial object
if (!previousWasSpread) {
utils.append('}, ', state);
@@ -12871,6 +14602,9 @@ function visitReactTag(traverse, object, path, state) {
// Move to the expression start, ignoring everything except parenthesis
// and whitespace.
+ utils.catchup(attr.range[0], state, stripNonWhiteParen);
+ // Plus 1 to skip `{`.
+ utils.move(attr.range[0] + 1, state);
utils.catchup(attr.argument.range[0], state, stripNonWhiteParen);
traverse(attr.argument, path, state);
@@ -12921,13 +14655,7 @@ function visitReactTag(traverse, object, path, state) {
utils.move(attr.name.range[1], state);
// Use catchupNewlines to skip over the '=' in the attribute
utils.catchupNewlines(attr.value.range[0], state);
- if (JSX_ATTRIBUTE_TRANSFORMS.hasOwnProperty(attr.name.name)) {
- utils.append(JSX_ATTRIBUTE_TRANSFORMS[attr.name.name](attr), state);
- utils.move(attr.value.range[1], state);
- if (!isLast) {
- utils.append(', ', state);
- }
- } else if (attr.value.type === Syntax.Literal) {
+ if (attr.value.type === Syntax.Literal) {
renderXJSLiteral(attr.value, isLast, state);
} else {
renderXJSExpressionContainer(traverse, attr.value, isLast, path, state);
@@ -13008,35 +14736,26 @@ function visitReactTag(traverse, object, path, state) {
}
visitReactTag.test = function(object, path, state) {
- // only run react when react @jsx namespace is specified in docblock
- var jsx = utils.getDocblock(state).jsx;
- return object.type === Syntax.XJSElement && jsx && jsx.length;
+ return object.type === Syntax.XJSElement;
};
exports.visitorList = [
visitReactTag
];
-},{"./xjs":31,"esprima-fb":6,"jstransform/src/utils":20}],30:[function(_dereq_,module,exports){
+},{"./xjs":36,"jstransform":21,"jstransform/src/utils":22}],35:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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.
*/
/*global exports:true*/
"use strict";
-var Syntax = _dereq_('esprima-fb').Syntax;
+var Syntax = _dereq_('jstransform').Syntax;
var utils = _dereq_('jstransform/src/utils');
function addDisplayName(displayName, object, state) {
@@ -13107,44 +14826,30 @@ function visitReactDisplayName(traverse, object, path, state) {
}
}
-/**
- * Will only run on @jsx files for now.
- */
visitReactDisplayName.test = function(object, path, state) {
- if (utils.getDocblock(state).jsx) {
- return (
- object.type === Syntax.AssignmentExpression ||
- object.type === Syntax.Property ||
- object.type === Syntax.VariableDeclarator
- );
- } else {
- return false;
- }
+ return (
+ object.type === Syntax.AssignmentExpression ||
+ object.type === Syntax.Property ||
+ object.type === Syntax.VariableDeclarator
+ );
};
exports.visitorList = [
visitReactDisplayName
];
-},{"esprima-fb":6,"jstransform/src/utils":20}],31:[function(_dereq_,module,exports){
+},{"jstransform":21,"jstransform/src/utils":22}],36:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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.
*/
/*global exports:true*/
"use strict";
-var Syntax = _dereq_('esprima-fb').Syntax;
+var Syntax = _dereq_('jstransform').Syntax;
var utils = _dereq_('jstransform/src/utils');
var knownTags = {
@@ -13237,6 +14942,7 @@ var knownTags = {
param: true,
path: true,
pattern: false,
+ picture: true,
polygon: true,
polyline: true,
pre: true,
@@ -13381,7 +15087,7 @@ exports.renderXJSLiteral = renderXJSLiteral;
exports.quoteAttrName = quoteAttrName;
exports.trimLeft = trimLeft;
-},{"esprima-fb":6,"jstransform/src/utils":20}],32:[function(_dereq_,module,exports){
+},{"jstransform":21,"jstransform/src/utils":22}],37:[function(_dereq_,module,exports){
/*global exports:true*/
var es6ArrowFunctions = _dereq_('jstransform/visitors/es6-arrow-function-visitors');
var es6Classes = _dereq_('jstransform/visitors/es6-class-visitors');
@@ -13390,6 +15096,7 @@ var es6ObjectConciseMethod = _dereq_('jstransform/visitors/es6-object-concise-me
var es6ObjectShortNotation = _dereq_('jstransform/visitors/es6-object-short-notation-visitors');
var es6RestParameters = _dereq_('jstransform/visitors/es6-rest-param-visitors');
var es6Templates = _dereq_('jstransform/visitors/es6-template-visitors');
+var es7SpreadProperty = _dereq_('jstransform/visitors/es7-spread-property-visitors');
var react = _dereq_('./transforms/react');
var reactDisplayName = _dereq_('./transforms/reactDisplayName');
@@ -13404,9 +15111,26 @@ var transformVisitors = {
'es6-object-short-notation': es6ObjectShortNotation.visitorList,
'es6-rest-params': es6RestParameters.visitorList,
'es6-templates': es6Templates.visitorList,
+ 'es7-spread-property': es7SpreadProperty.visitorList,
'react': react.visitorList.concat(reactDisplayName.visitorList)
};
+var transformSets = {
+ 'harmony': [
+ 'es6-arrow-functions',
+ 'es6-object-concise-method',
+ 'es6-object-short-notation',
+ 'es6-classes',
+ 'es6-rest-params',
+ 'es6-templates',
+ 'es6-destructuring',
+ 'es7-spread-property'
+ ],
+ 'react': [
+ 'react'
+ ]
+};
+
/**
* Specifies the order in which each transform should run.
*/
@@ -13418,6 +15142,7 @@ var transformRunOrder = [
'es6-rest-params',
'es6-templates',
'es6-destructuring',
+ 'es7-spread-property',
'react'
];
@@ -13438,9 +15163,37 @@ function getAllVisitors(excludes) {
return ret;
}
+/**
+ * Given a list of visitor set names, return the ordered list of visitors to be
+ * passed to jstransform.
+ *
+ * @param {array}
+ * @return {array}
+ */
+function getVisitorsBySet(sets) {
+ var visitorsToInclude = sets.reduce(function(visitors, set) {
+ if (!transformSets.hasOwnProperty(set)) {
+ throw new Error('Unknown visitor set: ' + set);
+ }
+ transformSets[set].forEach(function(visitor) {
+ visitors[visitor] = true;
+ });
+ return visitors;
+ }, {});
+
+ var visitorList = [];
+ for (var i = 0; i < transformRunOrder.length; i++) {
+ if (visitorsToInclude.hasOwnProperty(transformRunOrder[i])) {
+ visitorList = visitorList.concat(transformVisitors[transformRunOrder[i]]);
+ }
+ }
+
+ return visitorList;
+}
+
+exports.getVisitorsBySet = getVisitorsBySet;
exports.getAllVisitors = getAllVisitors;
exports.transformVisitors = transformVisitors;
-},{"./transforms/react":29,"./transforms/reactDisplayName":30,"jstransform/visitors/es6-arrow-function-visitors":21,"jstransform/visitors/es6-class-visitors":22,"jstransform/visitors/es6-destructuring-visitors":23,"jstransform/visitors/es6-object-concise-method-visitors":24,"jstransform/visitors/es6-object-short-notation-visitors":25,"jstransform/visitors/es6-rest-param-visitors":26,"jstransform/visitors/es6-template-visitors":27}]},{},[28])
-(28)
+},{"./transforms/react":34,"./transforms/reactDisplayName":35,"jstransform/visitors/es6-arrow-function-visitors":23,"jstransform/visitors/es6-class-visitors":24,"jstransform/visitors/es6-destructuring-visitors":25,"jstransform/visitors/es6-object-concise-method-visitors":26,"jstransform/visitors/es6-object-short-notation-visitors":27,"jstransform/visitors/es6-rest-param-visitors":28,"jstransform/visitors/es6-template-visitors":29,"jstransform/visitors/es7-spread-property-visitors":31}]},{},[1])(1)
}); \ No newline at end of file
diff --git a/web/src/vendor/react/react-with-addons.js b/web/src/vendor/react/react-with-addons.js
index b45d8205..b637678d 100644
--- a/web/src/vendor/react/react-with-addons.js
+++ b/web/src/vendor/react/react-with-addons.js
@@ -1,21 +1,66 @@
/**
- * React (with addons) v0.11.1
+ * React (with addons) v0.12.1
*/
-!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.React=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
+!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.React=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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
+ * 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.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * @providesModule ReactWithAddons
+ */
+
+/**
+ * This module exists purely in the open source project, and is meant as a way
+ * to create a separate standalone build of React. This build has "addons", or
+ * functionality we've built and think might be useful but doesn't have a good
+ * place to live inside React core.
+ */
+
+"use strict";
+
+var LinkedStateMixin = _dereq_("./LinkedStateMixin");
+var React = _dereq_("./React");
+var ReactComponentWithPureRenderMixin =
+ _dereq_("./ReactComponentWithPureRenderMixin");
+var ReactCSSTransitionGroup = _dereq_("./ReactCSSTransitionGroup");
+var ReactTransitionGroup = _dereq_("./ReactTransitionGroup");
+var ReactUpdates = _dereq_("./ReactUpdates");
+
+var cx = _dereq_("./cx");
+var cloneWithProps = _dereq_("./cloneWithProps");
+var update = _dereq_("./update");
+
+React.addons = {
+ CSSTransitionGroup: ReactCSSTransitionGroup,
+ LinkedStateMixin: LinkedStateMixin,
+ PureRenderMixin: ReactComponentWithPureRenderMixin,
+ TransitionGroup: ReactTransitionGroup,
+
+ batchedUpdates: ReactUpdates.batchedUpdates,
+ classSet: cx,
+ cloneWithProps: cloneWithProps,
+ update: update
+};
+
+if ("production" !== "development") {
+ React.addons.Perf = _dereq_("./ReactDefaultPerf");
+ React.addons.TestUtils = _dereq_("./ReactTestUtils");
+}
+
+module.exports = React;
+
+},{"./LinkedStateMixin":25,"./React":31,"./ReactCSSTransitionGroup":34,"./ReactComponentWithPureRenderMixin":39,"./ReactDefaultPerf":56,"./ReactTestUtils":86,"./ReactTransitionGroup":90,"./ReactUpdates":91,"./cloneWithProps":113,"./cx":118,"./update":159}],2:[function(_dereq_,module,exports){
+/**
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 AutoFocusMixin
* @typechecks static-only
@@ -35,21 +80,14 @@ var AutoFocusMixin = {
module.exports = AutoFocusMixin;
-},{"./focusNode":120}],2:[function(_dereq_,module,exports){
+},{"./focusNode":125}],3:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 BeforeInputEventPlugin
* @typechecks static-only
@@ -107,6 +145,9 @@ var eventTypes = {
// Track characters inserted via keypress and composition events.
var fallbackChars = null;
+// Track whether we've ever handled a keypress on the space key.
+var hasSpaceKeypress = false;
+
/**
* Return whether a native keypress event is assumed to be a command.
* This is required because Firefox fires `keypress` events for key commands
@@ -176,7 +217,8 @@ var BeforeInputEventPlugin = {
return;
}
- chars = String.fromCharCode(which);
+ hasSpaceKeypress = true;
+ chars = SPACEBAR_CHAR;
break;
case topLevelTypes.topTextInput:
@@ -184,8 +226,9 @@ var BeforeInputEventPlugin = {
chars = nativeEvent.data;
// If it's a spacebar character, assume that we have already handled
- // it at the keypress level and bail immediately.
- if (chars === SPACEBAR_CHAR) {
+ // it at the keypress level and bail immediately. Android Chrome
+ // doesn't give us keycodes, so we need to blacklist it.
+ if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
return;
}
@@ -259,21 +302,14 @@ var BeforeInputEventPlugin = {
module.exports = BeforeInputEventPlugin;
-},{"./EventConstants":16,"./EventPropagators":21,"./ExecutionEnvironment":22,"./SyntheticInputEvent":98,"./keyOf":141}],3:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./EventPropagators":22,"./ExecutionEnvironment":23,"./SyntheticInputEvent":101,"./keyOf":147}],4:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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
@@ -359,7 +395,7 @@ var CSSCore = {
*
* @param {DOMNode|DOMWindow} element the element to set the class on
* @param {string} className the CSS className
- * @returns {boolean} true if the element has the class, false if not
+ * @return {boolean} true if the element has the class, false if not
*/
hasClass: function(element, className) {
("production" !== "development" ? invariant(
@@ -376,21 +412,14 @@ var CSSCore = {
module.exports = CSSCore;
-},{"./invariant":134}],4:[function(_dereq_,module,exports){
+},{"./invariant":140}],5:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 CSSProperty
*/
@@ -499,21 +528,14 @@ var CSSProperty = {
module.exports = CSSProperty;
-},{}],5:[function(_dereq_,module,exports){
+},{}],6:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 CSSPropertyOperations
* @typechecks static-only
@@ -522,15 +544,43 @@ module.exports = CSSProperty;
"use strict";
var CSSProperty = _dereq_("./CSSProperty");
+var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
+var camelizeStyleName = _dereq_("./camelizeStyleName");
var dangerousStyleValue = _dereq_("./dangerousStyleValue");
var hyphenateStyleName = _dereq_("./hyphenateStyleName");
var memoizeStringOnly = _dereq_("./memoizeStringOnly");
+var warning = _dereq_("./warning");
var processStyleName = memoizeStringOnly(function(styleName) {
return hyphenateStyleName(styleName);
});
+var styleFloatAccessor = 'cssFloat';
+if (ExecutionEnvironment.canUseDOM) {
+ // IE8 only supports accessing cssFloat (standard) as styleFloat
+ if (document.documentElement.style.cssFloat === undefined) {
+ styleFloatAccessor = 'styleFloat';
+ }
+}
+
+if ("production" !== "development") {
+ var warnedStyleNames = {};
+
+ var warnHyphenatedStyleName = function(name) {
+ if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
+ return;
+ }
+
+ warnedStyleNames[name] = true;
+ ("production" !== "development" ? warning(
+ false,
+ 'Unsupported style property ' + name + '. Did you mean ' +
+ camelizeStyleName(name) + '?'
+ ) : null);
+ };
+}
+
/**
* Operations for dealing with CSS properties.
*/
@@ -554,6 +604,11 @@ var CSSPropertyOperations = {
if (!styles.hasOwnProperty(styleName)) {
continue;
}
+ if ("production" !== "development") {
+ if (styleName.indexOf('-') > -1) {
+ warnHyphenatedStyleName(styleName);
+ }
+ }
var styleValue = styles[styleName];
if (styleValue != null) {
serialized += processStyleName(styleName) + ':';
@@ -576,7 +631,15 @@ var CSSPropertyOperations = {
if (!styles.hasOwnProperty(styleName)) {
continue;
}
+ if ("production" !== "development") {
+ if (styleName.indexOf('-') > -1) {
+ warnHyphenatedStyleName(styleName);
+ }
+ }
var styleValue = dangerousStyleValue(styleName, styles[styleName]);
+ if (styleName === 'float') {
+ styleName = styleFloatAccessor;
+ }
if (styleValue) {
style[styleName] = styleValue;
} else {
@@ -598,21 +661,14 @@ var CSSPropertyOperations = {
module.exports = CSSPropertyOperations;
-},{"./CSSProperty":4,"./dangerousStyleValue":115,"./hyphenateStyleName":132,"./memoizeStringOnly":143}],6:[function(_dereq_,module,exports){
+},{"./CSSProperty":5,"./ExecutionEnvironment":23,"./camelizeStyleName":112,"./dangerousStyleValue":119,"./hyphenateStyleName":138,"./memoizeStringOnly":149,"./warning":160}],7:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 CallbackQueue
*/
@@ -621,8 +677,8 @@ module.exports = CSSPropertyOperations;
var PooledClass = _dereq_("./PooledClass");
+var assign = _dereq_("./Object.assign");
var invariant = _dereq_("./invariant");
-var mixInto = _dereq_("./mixInto");
/**
* A specialized pseudo-event module to help keep track of components waiting to
@@ -640,7 +696,7 @@ function CallbackQueue() {
this._contexts = null;
}
-mixInto(CallbackQueue, {
+assign(CallbackQueue.prototype, {
/**
* Enqueues a callback to be invoked when `notifyAll` is invoked.
@@ -703,21 +759,14 @@ PooledClass.addPoolingTo(CallbackQueue);
module.exports = CallbackQueue;
-},{"./PooledClass":28,"./invariant":134,"./mixInto":147}],7:[function(_dereq_,module,exports){
+},{"./Object.assign":29,"./PooledClass":30,"./invariant":140}],8:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ChangeEventPlugin
*/
@@ -1092,21 +1141,14 @@ var ChangeEventPlugin = {
module.exports = ChangeEventPlugin;
-},{"./EventConstants":16,"./EventPluginHub":18,"./EventPropagators":21,"./ExecutionEnvironment":22,"./ReactUpdates":87,"./SyntheticEvent":96,"./isEventSupported":135,"./isTextInputElement":137,"./keyOf":141}],8:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./EventPluginHub":19,"./EventPropagators":22,"./ExecutionEnvironment":23,"./ReactUpdates":91,"./SyntheticEvent":99,"./isEventSupported":141,"./isTextInputElement":143,"./keyOf":147}],9:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ClientReactRootIndex
* @typechecks
@@ -1124,21 +1166,14 @@ var ClientReactRootIndex = {
module.exports = ClientReactRootIndex;
-},{}],9:[function(_dereq_,module,exports){
+},{}],10:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 CompositionEventPlugin
* @typechecks static-only
@@ -1390,21 +1425,14 @@ var CompositionEventPlugin = {
module.exports = CompositionEventPlugin;
-},{"./EventConstants":16,"./EventPropagators":21,"./ExecutionEnvironment":22,"./ReactInputSelection":63,"./SyntheticCompositionEvent":94,"./getTextContentAccessor":129,"./keyOf":141}],10:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./EventPropagators":22,"./ExecutionEnvironment":23,"./ReactInputSelection":65,"./SyntheticCompositionEvent":97,"./getTextContentAccessor":135,"./keyOf":147}],11:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 DOMChildrenOperations
* @typechecks static-only
@@ -1512,9 +1540,9 @@ var DOMChildrenOperations = {
'processUpdates(): Unable to find child %s of element. This ' +
'probably means the DOM was unexpectedly mutated (e.g., by the ' +
'browser), usually due to forgetting a <tbody> when using tables, ' +
- 'nesting <p> or <a> tags, or using non-SVG elements in an <svg> '+
- 'parent. Try inspecting the child nodes of the element with React ' +
- 'ID `%s`.',
+ 'nesting tags like <form>, <p>, or <a>, or using non-SVG elements '+
+ 'in an <svg> parent. Try inspecting the child nodes of the element ' +
+ 'with React ID `%s`.',
updatedIndex,
parentID
) : invariant(updatedChild));
@@ -1570,21 +1598,14 @@ var DOMChildrenOperations = {
module.exports = DOMChildrenOperations;
-},{"./Danger":13,"./ReactMultiChildUpdateTypes":69,"./getTextContentAccessor":129,"./invariant":134}],11:[function(_dereq_,module,exports){
+},{"./Danger":14,"./ReactMultiChildUpdateTypes":72,"./getTextContentAccessor":135,"./invariant":140}],12:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 DOMProperty
* @typechecks static-only
@@ -1596,6 +1617,10 @@ module.exports = DOMChildrenOperations;
var invariant = _dereq_("./invariant");
+function checkMask(value, bitmask) {
+ return (value & bitmask) === bitmask;
+}
+
var DOMPropertyInjection = {
/**
* Mapping from normalized, camelcased property names to a configuration that
@@ -1682,19 +1707,19 @@ var DOMPropertyInjection = {
var propConfig = Properties[propName];
DOMProperty.mustUseAttribute[propName] =
- propConfig & DOMPropertyInjection.MUST_USE_ATTRIBUTE;
+ checkMask(propConfig, DOMPropertyInjection.MUST_USE_ATTRIBUTE);
DOMProperty.mustUseProperty[propName] =
- propConfig & DOMPropertyInjection.MUST_USE_PROPERTY;
+ checkMask(propConfig, DOMPropertyInjection.MUST_USE_PROPERTY);
DOMProperty.hasSideEffects[propName] =
- propConfig & DOMPropertyInjection.HAS_SIDE_EFFECTS;
+ checkMask(propConfig, DOMPropertyInjection.HAS_SIDE_EFFECTS);
DOMProperty.hasBooleanValue[propName] =
- propConfig & DOMPropertyInjection.HAS_BOOLEAN_VALUE;
+ checkMask(propConfig, DOMPropertyInjection.HAS_BOOLEAN_VALUE);
DOMProperty.hasNumericValue[propName] =
- propConfig & DOMPropertyInjection.HAS_NUMERIC_VALUE;
+ checkMask(propConfig, DOMPropertyInjection.HAS_NUMERIC_VALUE);
DOMProperty.hasPositiveNumericValue[propName] =
- propConfig & DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE;
+ checkMask(propConfig, DOMPropertyInjection.HAS_POSITIVE_NUMERIC_VALUE);
DOMProperty.hasOverloadedBooleanValue[propName] =
- propConfig & DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE;
+ checkMask(propConfig, DOMPropertyInjection.HAS_OVERLOADED_BOOLEAN_VALUE);
("production" !== "development" ? invariant(
!DOMProperty.mustUseAttribute[propName] ||
@@ -1870,21 +1895,14 @@ var DOMProperty = {
module.exports = DOMProperty;
-},{"./invariant":134}],12:[function(_dereq_,module,exports){
+},{"./invariant":140}],13:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 DOMPropertyOperations
* @typechecks static-only
@@ -2011,10 +2029,17 @@ var DOMPropertyOperations = {
} else if (shouldIgnoreValue(name, value)) {
this.deleteValueForProperty(node, name);
} else if (DOMProperty.mustUseAttribute[name]) {
+ // `setAttribute` with objects becomes only `[object]` in IE8/9,
+ // ('' + value) makes it output the correct toString()-value.
node.setAttribute(DOMProperty.getAttributeName[name], '' + value);
} else {
var propName = DOMProperty.getPropertyName[name];
- if (!DOMProperty.hasSideEffects[name] || node[propName] !== value) {
+ // Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
+ // property type before comparing; only `value` does and is string.
+ if (!DOMProperty.hasSideEffects[name] ||
+ ('' + node[propName]) !== ('' + value)) {
+ // Contrary to `setAttribute`, object properties are properly
+ // `toString`ed by IE8/9.
node[propName] = value;
}
}
@@ -2050,7 +2075,7 @@ var DOMPropertyOperations = {
propName
);
if (!DOMProperty.hasSideEffects[name] ||
- node[propName] !== defaultValue) {
+ ('' + node[propName]) !== defaultValue) {
node[propName] = defaultValue;
}
}
@@ -2065,21 +2090,14 @@ var DOMPropertyOperations = {
module.exports = DOMPropertyOperations;
-},{"./DOMProperty":11,"./escapeTextForBrowser":118,"./memoizeStringOnly":143,"./warning":158}],13:[function(_dereq_,module,exports){
+},{"./DOMProperty":12,"./escapeTextForBrowser":123,"./memoizeStringOnly":149,"./warning":160}],14:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 Danger
* @typechecks static-only
@@ -2128,9 +2146,10 @@ var Danger = {
dangerouslyRenderMarkup: function(markupList) {
("production" !== "development" ? invariant(
ExecutionEnvironment.canUseDOM,
- 'dangerouslyRenderMarkup(...): Cannot render markup in a Worker ' +
- 'thread. This is likely a bug in the framework. Please report ' +
- 'immediately.'
+ 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' +
+ 'thread. Make sure `window` and `document` are available globally ' +
+ 'before requiring React when unit testing or use ' +
+ 'React.renderToString for server rendering.'
) : invariant(ExecutionEnvironment.canUseDOM));
var nodeName;
var markupByNodeName = {};
@@ -2234,8 +2253,9 @@ var Danger = {
("production" !== "development" ? invariant(
ExecutionEnvironment.canUseDOM,
'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' +
- 'worker thread. This is likely a bug in the framework. Please report ' +
- 'immediately.'
+ 'worker thread. Make sure `window` and `document` are available ' +
+ 'globally before requiring React when unit testing or use ' +
+ 'React.renderToString for server rendering.'
) : invariant(ExecutionEnvironment.canUseDOM));
("production" !== "development" ? invariant(markup, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(markup));
("production" !== "development" ? invariant(
@@ -2254,21 +2274,14 @@ var Danger = {
module.exports = Danger;
-},{"./ExecutionEnvironment":22,"./createNodesFromMarkup":113,"./emptyFunction":116,"./getMarkupWrap":126,"./invariant":134}],14:[function(_dereq_,module,exports){
+},{"./ExecutionEnvironment":23,"./createNodesFromMarkup":117,"./emptyFunction":121,"./getMarkupWrap":132,"./invariant":140}],15:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 DefaultEventPluginOrder
*/
@@ -2301,21 +2314,14 @@ var DefaultEventPluginOrder = [
module.exports = DefaultEventPluginOrder;
-},{"./keyOf":141}],15:[function(_dereq_,module,exports){
+},{"./keyOf":147}],16:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 EnterLeaveEventPlugin
* @typechecks static-only
@@ -2448,21 +2454,14 @@ var EnterLeaveEventPlugin = {
module.exports = EnterLeaveEventPlugin;
-},{"./EventConstants":16,"./EventPropagators":21,"./ReactMount":67,"./SyntheticMouseEvent":100,"./keyOf":141}],16:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./EventPropagators":22,"./ReactMount":70,"./SyntheticMouseEvent":103,"./keyOf":147}],17:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 EventConstants
*/
@@ -2527,8 +2526,22 @@ var EventConstants = {
module.exports = EventConstants;
-},{"./keyMirror":140}],17:[function(_dereq_,module,exports){
+},{"./keyMirror":146}],18:[function(_dereq_,module,exports){
/**
+ * Copyright 2013-2014 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
*/
@@ -2601,21 +2614,14 @@ var EventListener = {
module.exports = EventListener;
-},{"./emptyFunction":116}],18:[function(_dereq_,module,exports){
+},{"./emptyFunction":121}],19:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 EventPluginHub
*/
@@ -2625,11 +2631,9 @@ module.exports = EventListener;
var EventPluginRegistry = _dereq_("./EventPluginRegistry");
var EventPluginUtils = _dereq_("./EventPluginUtils");
-var accumulate = _dereq_("./accumulate");
+var accumulateInto = _dereq_("./accumulateInto");
var forEachAccumulated = _dereq_("./forEachAccumulated");
var invariant = _dereq_("./invariant");
-var isEventSupported = _dereq_("./isEventSupported");
-var monitorCodeUse = _dereq_("./monitorCodeUse");
/**
* Internal store for event listeners
@@ -2763,15 +2767,6 @@ var EventPluginHub = {
registrationName, typeof listener
) : invariant(!listener || typeof listener === 'function'));
- if ("production" !== "development") {
- // IE8 has no API for event capturing and the `onScroll` event doesn't
- // bubble.
- if (registrationName === 'onScroll' &&
- !isEventSupported('scroll', true)) {
- monitorCodeUse('react_no_scroll_event');
- console.warn('This browser doesn\'t support the `onScroll` event');
- }
- }
var bankForRegistrationName =
listenerBank[registrationName] || (listenerBank[registrationName] = {});
bankForRegistrationName[id] = listener;
@@ -2840,7 +2835,7 @@ var EventPluginHub = {
nativeEvent
);
if (extractedEvents) {
- events = accumulate(events, extractedEvents);
+ events = accumulateInto(events, extractedEvents);
}
}
}
@@ -2856,7 +2851,7 @@ var EventPluginHub = {
*/
enqueueEvents: function(events) {
if (events) {
- eventQueue = accumulate(eventQueue, events);
+ eventQueue = accumulateInto(eventQueue, events);
}
},
@@ -2893,21 +2888,14 @@ var EventPluginHub = {
module.exports = EventPluginHub;
-},{"./EventPluginRegistry":19,"./EventPluginUtils":20,"./accumulate":106,"./forEachAccumulated":121,"./invariant":134,"./isEventSupported":135,"./monitorCodeUse":148}],19:[function(_dereq_,module,exports){
+},{"./EventPluginRegistry":20,"./EventPluginUtils":21,"./accumulateInto":109,"./forEachAccumulated":126,"./invariant":140}],20:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 EventPluginRegistry
* @typechecks static-only
@@ -3178,21 +3166,14 @@ var EventPluginRegistry = {
module.exports = EventPluginRegistry;
-},{"./invariant":134}],20:[function(_dereq_,module,exports){
+},{"./invariant":140}],21:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 EventPluginUtils
*/
@@ -3404,21 +3385,14 @@ var EventPluginUtils = {
module.exports = EventPluginUtils;
-},{"./EventConstants":16,"./invariant":134}],21:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./invariant":140}],22:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 EventPropagators
*/
@@ -3428,7 +3402,7 @@ module.exports = EventPluginUtils;
var EventConstants = _dereq_("./EventConstants");
var EventPluginHub = _dereq_("./EventPluginHub");
-var accumulate = _dereq_("./accumulate");
+var accumulateInto = _dereq_("./accumulateInto");
var forEachAccumulated = _dereq_("./forEachAccumulated");
var PropagationPhases = EventConstants.PropagationPhases;
@@ -3459,8 +3433,9 @@ function accumulateDirectionalDispatches(domID, upwards, event) {
var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
var listener = listenerAtPhase(domID, event, phase);
if (listener) {
- event._dispatchListeners = accumulate(event._dispatchListeners, listener);
- event._dispatchIDs = accumulate(event._dispatchIDs, domID);
+ event._dispatchListeners =
+ accumulateInto(event._dispatchListeners, listener);
+ event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
}
}
@@ -3492,8 +3467,9 @@ function accumulateDispatches(id, ignoredDirection, event) {
var registrationName = event.dispatchConfig.registrationName;
var listener = getListener(id, registrationName);
if (listener) {
- event._dispatchListeners = accumulate(event._dispatchListeners, listener);
- event._dispatchIDs = accumulate(event._dispatchIDs, id);
+ event._dispatchListeners =
+ accumulateInto(event._dispatchListeners, listener);
+ event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
}
}
}
@@ -3549,21 +3525,14 @@ var EventPropagators = {
module.exports = EventPropagators;
-},{"./EventConstants":16,"./EventPluginHub":18,"./accumulate":106,"./forEachAccumulated":121}],22:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./EventPluginHub":19,"./accumulateInto":109,"./forEachAccumulated":126}],23:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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
*/
@@ -3601,21 +3570,14 @@ var ExecutionEnvironment = {
module.exports = ExecutionEnvironment;
-},{}],23:[function(_dereq_,module,exports){
+},{}],24:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 HTMLDOMPropertyConfig
*/
@@ -3660,6 +3622,7 @@ var HTMLDOMPropertyConfig = {
* Standard Properties
*/
accept: null,
+ acceptCharset: null,
accessKey: null,
action: null,
allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
@@ -3674,6 +3637,7 @@ var HTMLDOMPropertyConfig = {
cellSpacing: null,
charSet: MUST_USE_ATTRIBUTE,
checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
+ classID: MUST_USE_ATTRIBUTE,
// To set className on SVG elements, it's necessary to use .setAttribute;
// this works on HTML elements too in all browsers except IE8. Conveniently,
// IE8 doesn't support SVG and so we can simply use the attribute in
@@ -3709,10 +3673,12 @@ var HTMLDOMPropertyConfig = {
id: MUST_USE_PROPERTY,
label: null,
lang: null,
- list: null,
+ list: MUST_USE_ATTRIBUTE,
loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
+ manifest: MUST_USE_ATTRIBUTE,
max: null,
maxLength: MUST_USE_ATTRIBUTE,
+ media: MUST_USE_ATTRIBUTE,
mediaGroup: null,
method: null,
min: null,
@@ -3720,6 +3686,7 @@ var HTMLDOMPropertyConfig = {
muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
name: null,
noValidate: HAS_BOOLEAN_VALUE,
+ open: null,
pattern: null,
placeholder: null,
poster: null,
@@ -3733,18 +3700,17 @@ var HTMLDOMPropertyConfig = {
rowSpan: null,
sandbox: null,
scope: null,
- scrollLeft: MUST_USE_PROPERTY,
scrolling: null,
- scrollTop: MUST_USE_PROPERTY,
seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
shape: null,
size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
+ sizes: MUST_USE_ATTRIBUTE,
span: HAS_POSITIVE_NUMERIC_VALUE,
spellCheck: null,
src: null,
srcDoc: MUST_USE_PROPERTY,
- srcSet: null,
+ srcSet: MUST_USE_ATTRIBUTE,
start: HAS_NUMERIC_VALUE,
step: null,
style: null,
@@ -3768,6 +3734,7 @@ var HTMLDOMPropertyConfig = {
property: null // Supports OG in meta tags
},
DOMAttributeNames: {
+ acceptCharset: 'accept-charset',
className: 'class',
htmlFor: 'for',
httpEquiv: 'http-equiv'
@@ -3789,21 +3756,14 @@ var HTMLDOMPropertyConfig = {
module.exports = HTMLDOMPropertyConfig;
-},{"./DOMProperty":11,"./ExecutionEnvironment":22}],24:[function(_dereq_,module,exports){
+},{"./DOMProperty":12,"./ExecutionEnvironment":23}],25:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 LinkedStateMixin
* @typechecks static-only
@@ -3837,21 +3797,14 @@ var LinkedStateMixin = {
module.exports = LinkedStateMixin;
-},{"./ReactLink":65,"./ReactStateSetters":81}],25:[function(_dereq_,module,exports){
+},{"./ReactLink":68,"./ReactStateSetters":85}],26:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 LinkedValueUtils
* @typechecks static-only
@@ -3998,21 +3951,14 @@ var LinkedValueUtils = {
module.exports = LinkedValueUtils;
-},{"./ReactPropTypes":75,"./invariant":134}],26:[function(_dereq_,module,exports){
+},{"./ReactPropTypes":79,"./invariant":140}],27:[function(_dereq_,module,exports){
/**
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 LocalEventTrapMixin
*/
@@ -4021,7 +3967,7 @@ module.exports = LinkedValueUtils;
var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
-var accumulate = _dereq_("./accumulate");
+var accumulateInto = _dereq_("./accumulateInto");
var forEachAccumulated = _dereq_("./forEachAccumulated");
var invariant = _dereq_("./invariant");
@@ -4037,7 +3983,8 @@ var LocalEventTrapMixin = {
handlerBaseName,
this.getDOMNode()
);
- this._localEventListeners = accumulate(this._localEventListeners, listener);
+ this._localEventListeners =
+ accumulateInto(this._localEventListeners, listener);
},
// trapCapturedEvent would look nearly identical. We don't implement that
@@ -4052,21 +3999,14 @@ var LocalEventTrapMixin = {
module.exports = LocalEventTrapMixin;
-},{"./ReactBrowserEventEmitter":31,"./accumulate":106,"./forEachAccumulated":121,"./invariant":134}],27:[function(_dereq_,module,exports){
+},{"./ReactBrowserEventEmitter":33,"./accumulateInto":109,"./forEachAccumulated":126,"./invariant":140}],28:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 MobileSafariClickEventPlugin
* @typechecks static-only
@@ -4117,21 +4057,61 @@ var MobileSafariClickEventPlugin = {
module.exports = MobileSafariClickEventPlugin;
-},{"./EventConstants":16,"./emptyFunction":116}],28:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./emptyFunction":121}],29:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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
+ * 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.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * @providesModule Object.assign
+ */
+
+// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
+
+function assign(target, sources) {
+ if (target == null) {
+ throw new TypeError('Object.assign target cannot be null or undefined');
+ }
+
+ var to = Object(target);
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+ for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
+ var nextSource = arguments[nextIndex];
+ if (nextSource == null) {
+ continue;
+ }
+
+ var from = Object(nextSource);
+
+ // We don't currently support accessors nor proxies. Therefore this
+ // copy cannot throw. If we ever supported this then we must handle
+ // exceptions and side-effects. We don't support symbols so they won't
+ // be transferred.
+
+ for (var key in from) {
+ if (hasOwnProperty.call(from, key)) {
+ to[key] = from[key];
+ }
+ }
+ }
+
+ return to;
+};
+
+module.exports = assign;
+
+},{}],30:[function(_dereq_,module,exports){
+/**
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 PooledClass
*/
@@ -4238,21 +4218,14 @@ var PooledClass = {
module.exports = PooledClass;
-},{"./invariant":134}],29:[function(_dereq_,module,exports){
+},{"./invariant":140}],31:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 React
*/
@@ -4266,11 +4239,13 @@ var ReactComponent = _dereq_("./ReactComponent");
var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
var ReactContext = _dereq_("./ReactContext");
var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
-var ReactDescriptor = _dereq_("./ReactDescriptor");
+var ReactElement = _dereq_("./ReactElement");
+var ReactElementValidator = _dereq_("./ReactElementValidator");
var ReactDOM = _dereq_("./ReactDOM");
var ReactDOMComponent = _dereq_("./ReactDOMComponent");
var ReactDefaultInjection = _dereq_("./ReactDefaultInjection");
var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
+var ReactLegacyElement = _dereq_("./ReactLegacyElement");
var ReactMount = _dereq_("./ReactMount");
var ReactMultiChild = _dereq_("./ReactMultiChild");
var ReactPerf = _dereq_("./ReactPerf");
@@ -4278,10 +4253,30 @@ var ReactPropTypes = _dereq_("./ReactPropTypes");
var ReactServerRendering = _dereq_("./ReactServerRendering");
var ReactTextComponent = _dereq_("./ReactTextComponent");
+var assign = _dereq_("./Object.assign");
+var deprecated = _dereq_("./deprecated");
var onlyChild = _dereq_("./onlyChild");
ReactDefaultInjection.inject();
+var createElement = ReactElement.createElement;
+var createFactory = ReactElement.createFactory;
+
+if ("production" !== "development") {
+ createElement = ReactElementValidator.createElement;
+ createFactory = ReactElementValidator.createFactory;
+}
+
+// TODO: Drop legacy elements once classes no longer export these factories
+createElement = ReactLegacyElement.wrapCreateElement(
+ createElement
+);
+createFactory = ReactLegacyElement.wrapCreateFactory(
+ createFactory
+);
+
+var render = ReactPerf.measure('React', 'render', ReactMount.render);
+
var React = {
Children: {
map: ReactChildren.map,
@@ -4295,25 +4290,58 @@ var React = {
EventPluginUtils.useTouchEvents = shouldUseTouch;
},
createClass: ReactCompositeComponent.createClass,
- createDescriptor: function(type, props, children) {
- var args = Array.prototype.slice.call(arguments, 1);
- return type.apply(null, args);
- },
+ createElement: createElement,
+ createFactory: createFactory,
constructAndRenderComponent: ReactMount.constructAndRenderComponent,
constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID,
- renderComponent: ReactPerf.measure(
+ render: render,
+ renderToString: ReactServerRendering.renderToString,
+ renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
+ unmountComponentAtNode: ReactMount.unmountComponentAtNode,
+ isValidClass: ReactLegacyElement.isValidClass,
+ isValidElement: ReactElement.isValidElement,
+ withContext: ReactContext.withContext,
+
+ // Hook for JSX spread, don't use this for anything else.
+ __spread: assign,
+
+ // Deprecations (remove for 0.13)
+ renderComponent: deprecated(
'React',
'renderComponent',
- ReactMount.renderComponent
+ 'render',
+ this,
+ render
),
- renderComponentToString: ReactServerRendering.renderComponentToString,
- renderComponentToStaticMarkup:
- ReactServerRendering.renderComponentToStaticMarkup,
- unmountComponentAtNode: ReactMount.unmountComponentAtNode,
- isValidClass: ReactDescriptor.isValidFactory,
- isValidComponent: ReactDescriptor.isValidDescriptor,
- withContext: ReactContext.withContext,
- __internals: {
+ renderComponentToString: deprecated(
+ 'React',
+ 'renderComponentToString',
+ 'renderToString',
+ this,
+ ReactServerRendering.renderToString
+ ),
+ renderComponentToStaticMarkup: deprecated(
+ 'React',
+ 'renderComponentToStaticMarkup',
+ 'renderToStaticMarkup',
+ this,
+ ReactServerRendering.renderToStaticMarkup
+ ),
+ isValidComponent: deprecated(
+ 'React',
+ 'isValidComponent',
+ 'isValidElement',
+ this,
+ ReactElement.isValidElement
+ )
+};
+
+// Inject the runtime into a devtools global hook regardless of browser.
+// Allows for debugging when the hook is injected on the page.
+if (
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
+ __REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
Component: ReactComponent,
CurrentOwner: ReactCurrentOwner,
DOMComponent: ReactDOMComponent,
@@ -4322,18 +4350,23 @@ var React = {
Mount: ReactMount,
MultiChild: ReactMultiChild,
TextComponent: ReactTextComponent
- }
-};
+ });
+}
if ("production" !== "development") {
var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
- if (ExecutionEnvironment.canUseDOM &&
- window.top === window.self &&
- navigator.userAgent.indexOf('Chrome') > -1) {
- console.debug(
- 'Download the React DevTools for a better development experience: ' +
- 'http://fb.me/react-devtools'
- );
+ if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
+
+ // If we're in Chrome, look for the devtools marker and provide a download
+ // link if not installed.
+ if (navigator.userAgent.indexOf('Chrome') > -1) {
+ if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
+ console.debug(
+ 'Download the React DevTools for a better development experience: ' +
+ 'http://fb.me/react-devtools'
+ );
+ }
+ }
var expectedFeatures = [
// shims
@@ -4353,7 +4386,7 @@ if ("production" !== "development") {
Object.freeze
];
- for (var i in expectedFeatures) {
+ for (var i = 0; i < expectedFeatures.length; i++) {
if (!expectedFeatures[i]) {
console.error(
'One or more ES5 shim/shams expected by React are not available: ' +
@@ -4367,25 +4400,18 @@ if ("production" !== "development") {
// Version exists only in the open-source version of React, not in Facebook's
// internal version.
-React.version = '0.11.1';
+React.version = '0.12.1';
module.exports = React;
-},{"./DOMPropertyOperations":12,"./EventPluginUtils":20,"./ExecutionEnvironment":22,"./ReactChildren":34,"./ReactComponent":35,"./ReactCompositeComponent":38,"./ReactContext":39,"./ReactCurrentOwner":40,"./ReactDOM":41,"./ReactDOMComponent":43,"./ReactDefaultInjection":53,"./ReactDescriptor":56,"./ReactInstanceHandles":64,"./ReactMount":67,"./ReactMultiChild":68,"./ReactPerf":71,"./ReactPropTypes":75,"./ReactServerRendering":79,"./ReactTextComponent":83,"./onlyChild":149}],30:[function(_dereq_,module,exports){
+},{"./DOMPropertyOperations":13,"./EventPluginUtils":21,"./ExecutionEnvironment":23,"./Object.assign":29,"./ReactChildren":36,"./ReactComponent":37,"./ReactCompositeComponent":40,"./ReactContext":41,"./ReactCurrentOwner":42,"./ReactDOM":43,"./ReactDOMComponent":45,"./ReactDefaultInjection":55,"./ReactElement":58,"./ReactElementValidator":59,"./ReactInstanceHandles":66,"./ReactLegacyElement":67,"./ReactMount":70,"./ReactMultiChild":71,"./ReactPerf":75,"./ReactPropTypes":79,"./ReactServerRendering":83,"./ReactTextComponent":87,"./deprecated":120,"./onlyChild":151}],32:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactBrowserComponentMixin
*/
@@ -4419,21 +4445,14 @@ var ReactBrowserComponentMixin = {
module.exports = ReactBrowserComponentMixin;
-},{"./ReactEmptyComponent":58,"./ReactMount":67,"./invariant":134}],31:[function(_dereq_,module,exports){
+},{"./ReactEmptyComponent":60,"./ReactMount":70,"./invariant":140}],33:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactBrowserEventEmitter
* @typechecks static-only
@@ -4447,8 +4466,8 @@ var EventPluginRegistry = _dereq_("./EventPluginRegistry");
var ReactEventEmitterMixin = _dereq_("./ReactEventEmitterMixin");
var ViewportMetrics = _dereq_("./ViewportMetrics");
+var assign = _dereq_("./Object.assign");
var isEventSupported = _dereq_("./isEventSupported");
-var merge = _dereq_("./merge");
/**
* Summary of `ReactBrowserEventEmitter` event handling:
@@ -4577,7 +4596,7 @@ function getListeningForDocument(mountAt) {
*
* @internal
*/
-var ReactBrowserEventEmitter = merge(ReactEventEmitterMixin, {
+var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
/**
* Injectable event backend
@@ -4781,21 +4800,14 @@ var ReactBrowserEventEmitter = merge(ReactEventEmitterMixin, {
module.exports = ReactBrowserEventEmitter;
-},{"./EventConstants":16,"./EventPluginHub":18,"./EventPluginRegistry":19,"./ReactEventEmitterMixin":60,"./ViewportMetrics":105,"./isEventSupported":135,"./merge":144}],32:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./EventPluginHub":19,"./EventPluginRegistry":20,"./Object.assign":29,"./ReactEventEmitterMixin":62,"./ViewportMetrics":108,"./isEventSupported":141}],34:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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.
*
* @typechecks
* @providesModule ReactCSSTransitionGroup
@@ -4805,8 +4817,14 @@ module.exports = ReactBrowserEventEmitter;
var React = _dereq_("./React");
-var ReactTransitionGroup = _dereq_("./ReactTransitionGroup");
-var ReactCSSTransitionGroupChild = _dereq_("./ReactCSSTransitionGroupChild");
+var assign = _dereq_("./Object.assign");
+
+var ReactTransitionGroup = React.createFactory(
+ _dereq_("./ReactTransitionGroup")
+);
+var ReactCSSTransitionGroupChild = React.createFactory(
+ _dereq_("./ReactCSSTransitionGroupChild")
+);
var ReactCSSTransitionGroup = React.createClass({
displayName: 'ReactCSSTransitionGroup',
@@ -4839,10 +4857,9 @@ var ReactCSSTransitionGroup = React.createClass({
},
render: function() {
- return this.transferPropsTo(
+ return (
ReactTransitionGroup(
- {childFactory: this._wrapChild},
- this.props.children
+ assign({}, this.props, {childFactory: this._wrapChild})
)
);
}
@@ -4850,21 +4867,14 @@ var ReactCSSTransitionGroup = React.createClass({
module.exports = ReactCSSTransitionGroup;
-},{"./React":29,"./ReactCSSTransitionGroupChild":33,"./ReactTransitionGroup":86}],33:[function(_dereq_,module,exports){
+},{"./Object.assign":29,"./React":31,"./ReactCSSTransitionGroupChild":35,"./ReactTransitionGroup":90}],35:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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.
*
* @typechecks
* @providesModule ReactCSSTransitionGroupChild
@@ -4909,7 +4919,10 @@ var ReactCSSTransitionGroupChild = React.createClass({
var activeClassName = className + '-active';
var noEventTimeout = null;
- var endListener = function() {
+ var endListener = function(e) {
+ if (e && e.target !== node) {
+ return;
+ }
if ("production" !== "development") {
clearTimeout(noEventTimeout);
}
@@ -4987,21 +5000,14 @@ var ReactCSSTransitionGroupChild = React.createClass({
module.exports = ReactCSSTransitionGroupChild;
-},{"./CSSCore":3,"./React":29,"./ReactTransitionEvents":85,"./onlyChild":149}],34:[function(_dereq_,module,exports){
+},{"./CSSCore":4,"./React":31,"./ReactTransitionEvents":89,"./onlyChild":151}],36:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactChildren
*/
@@ -5142,34 +5148,27 @@ var ReactChildren = {
module.exports = ReactChildren;
-},{"./PooledClass":28,"./traverseAllChildren":156,"./warning":158}],35:[function(_dereq_,module,exports){
+},{"./PooledClass":30,"./traverseAllChildren":158,"./warning":160}],37:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactComponent
*/
"use strict";
-var ReactDescriptor = _dereq_("./ReactDescriptor");
+var ReactElement = _dereq_("./ReactElement");
var ReactOwner = _dereq_("./ReactOwner");
var ReactUpdates = _dereq_("./ReactUpdates");
+var assign = _dereq_("./Object.assign");
var invariant = _dereq_("./invariant");
var keyMirror = _dereq_("./keyMirror");
-var merge = _dereq_("./merge");
/**
* Every React component is in one of these life cycles.
@@ -5292,11 +5291,11 @@ var ReactComponent = {
* @public
*/
setProps: function(partialProps, callback) {
- // Merge with the pending descriptor if it exists, otherwise with existing
- // descriptor props.
- var descriptor = this._pendingDescriptor || this._descriptor;
+ // Merge with the pending element if it exists, otherwise with existing
+ // element props.
+ var element = this._pendingElement || this._currentElement;
this.replaceProps(
- merge(descriptor.props, partialProps),
+ assign({}, element.props, partialProps),
callback
);
},
@@ -5322,10 +5321,10 @@ var ReactComponent = {
'`render` method to pass the correct value as props to the component ' +
'where it is created.'
) : invariant(this._mountDepth === 0));
- // This is a deoptimized path. We optimize for always having a descriptor.
- // This creates an extra internal descriptor.
- this._pendingDescriptor = ReactDescriptor.cloneAndReplaceProps(
- this._pendingDescriptor || this._descriptor,
+ // This is a deoptimized path. We optimize for always having a element.
+ // This creates an extra internal element.
+ this._pendingElement = ReactElement.cloneAndReplaceProps(
+ this._pendingElement || this._currentElement,
props
);
ReactUpdates.enqueueUpdate(this, callback);
@@ -5340,12 +5339,12 @@ var ReactComponent = {
* @internal
*/
_setPropsInternal: function(partialProps, callback) {
- // This is a deoptimized path. We optimize for always having a descriptor.
- // This creates an extra internal descriptor.
- var descriptor = this._pendingDescriptor || this._descriptor;
- this._pendingDescriptor = ReactDescriptor.cloneAndReplaceProps(
- descriptor,
- merge(descriptor.props, partialProps)
+ // This is a deoptimized path. We optimize for always having a element.
+ // This creates an extra internal element.
+ var element = this._pendingElement || this._currentElement;
+ this._pendingElement = ReactElement.cloneAndReplaceProps(
+ element,
+ assign({}, element.props, partialProps)
);
ReactUpdates.enqueueUpdate(this, callback);
},
@@ -5356,19 +5355,19 @@ var ReactComponent = {
* Subclasses that override this method should make sure to invoke
* `ReactComponent.Mixin.construct.call(this, ...)`.
*
- * @param {ReactDescriptor} descriptor
+ * @param {ReactElement} element
* @internal
*/
- construct: function(descriptor) {
+ construct: function(element) {
// This is the public exposed props object after it has been processed
- // with default props. The descriptor's props represents the true internal
+ // with default props. The element's props represents the true internal
// state of the props.
- this.props = descriptor.props;
+ this.props = element.props;
// Record the component responsible for creating this component.
- // This is accessible through the descriptor but we maintain an extra
+ // This is accessible through the element but we maintain an extra
// field for compatibility with devtools and as a way to make an
// incremental update. TODO: Consider deprecating this field.
- this._owner = descriptor._owner;
+ this._owner = element._owner;
// All components start unmounted.
this._lifeCycleState = ComponentLifeCycle.UNMOUNTED;
@@ -5376,10 +5375,10 @@ var ReactComponent = {
// See ReactUpdates.
this._pendingCallbacks = null;
- // We keep the old descriptor and a reference to the pending descriptor
+ // We keep the old element and a reference to the pending element
// to track updates.
- this._descriptor = descriptor;
- this._pendingDescriptor = null;
+ this._currentElement = element;
+ this._pendingElement = null;
},
/**
@@ -5404,10 +5403,10 @@ var ReactComponent = {
'single component instance in multiple places.',
rootID
) : invariant(!this.isMounted()));
- var props = this._descriptor.props;
- if (props.ref != null) {
- var owner = this._descriptor._owner;
- ReactOwner.addComponentAsRefTo(this, props.ref, owner);
+ var ref = this._currentElement.ref;
+ if (ref != null) {
+ var owner = this._currentElement._owner;
+ ReactOwner.addComponentAsRefTo(this, ref, owner);
}
this._rootNodeID = rootID;
this._lifeCycleState = ComponentLifeCycle.MOUNTED;
@@ -5430,9 +5429,9 @@ var ReactComponent = {
this.isMounted(),
'unmountComponent(): Can only unmount a mounted component.'
) : invariant(this.isMounted()));
- var props = this.props;
- if (props.ref != null) {
- ReactOwner.removeComponentAsRefFrom(this, props.ref, this._owner);
+ var ref = this._currentElement.ref;
+ if (ref != null) {
+ ReactOwner.removeComponentAsRefFrom(this, ref, this._owner);
}
unmountIDFromEnvironment(this._rootNodeID);
this._rootNodeID = null;
@@ -5450,49 +5449,49 @@ var ReactComponent = {
* @param {ReactReconcileTransaction} transaction
* @internal
*/
- receiveComponent: function(nextDescriptor, transaction) {
+ receiveComponent: function(nextElement, transaction) {
("production" !== "development" ? invariant(
this.isMounted(),
'receiveComponent(...): Can only update a mounted component.'
) : invariant(this.isMounted()));
- this._pendingDescriptor = nextDescriptor;
+ this._pendingElement = nextElement;
this.performUpdateIfNecessary(transaction);
},
/**
- * If `_pendingDescriptor` is set, update the component.
+ * If `_pendingElement` is set, update the component.
*
* @param {ReactReconcileTransaction} transaction
* @internal
*/
performUpdateIfNecessary: function(transaction) {
- if (this._pendingDescriptor == null) {
+ if (this._pendingElement == null) {
return;
}
- var prevDescriptor = this._descriptor;
- var nextDescriptor = this._pendingDescriptor;
- this._descriptor = nextDescriptor;
- this.props = nextDescriptor.props;
- this._owner = nextDescriptor._owner;
- this._pendingDescriptor = null;
- this.updateComponent(transaction, prevDescriptor);
+ var prevElement = this._currentElement;
+ var nextElement = this._pendingElement;
+ this._currentElement = nextElement;
+ this.props = nextElement.props;
+ this._owner = nextElement._owner;
+ this._pendingElement = null;
+ this.updateComponent(transaction, prevElement);
},
/**
* Updates the component's currently mounted representation.
*
* @param {ReactReconcileTransaction} transaction
- * @param {object} prevDescriptor
+ * @param {object} prevElement
* @internal
*/
- updateComponent: function(transaction, prevDescriptor) {
- var nextDescriptor = this._descriptor;
+ updateComponent: function(transaction, prevElement) {
+ var nextElement = this._currentElement;
// If either the owner or a `ref` has changed, make sure the newest owner
// has stored a reference to `this`, and the previous owner (if different)
- // has forgotten the reference to `this`. We use the descriptor instead
+ // has forgotten the reference to `this`. We use the element instead
// of the public this.props because the post processing cannot determine
- // a ref. The ref conceptually lives on the descriptor.
+ // a ref. The ref conceptually lives on the element.
// TODO: Should this even be possible? The owner cannot change because
// it's forbidden by shouldUpdateReactComponent. The ref can change
@@ -5500,19 +5499,19 @@ var ReactComponent = {
// is made. It probably belongs where the key checking and
// instantiateReactComponent is done.
- if (nextDescriptor._owner !== prevDescriptor._owner ||
- nextDescriptor.props.ref !== prevDescriptor.props.ref) {
- if (prevDescriptor.props.ref != null) {
+ if (nextElement._owner !== prevElement._owner ||
+ nextElement.ref !== prevElement.ref) {
+ if (prevElement.ref != null) {
ReactOwner.removeComponentAsRefFrom(
- this, prevDescriptor.props.ref, prevDescriptor._owner
+ this, prevElement.ref, prevElement._owner
);
}
// Correct, even if the owner is the same, and only the ref has changed.
- if (nextDescriptor.props.ref != null) {
+ if (nextElement.ref != null) {
ReactOwner.addComponentAsRefTo(
this,
- nextDescriptor.props.ref,
- nextDescriptor._owner
+ nextElement.ref,
+ nextElement._owner
);
}
}
@@ -5526,7 +5525,7 @@ var ReactComponent = {
* @param {boolean} shouldReuseMarkup If true, do not insert markup
* @final
* @internal
- * @see {ReactMount.renderComponent}
+ * @see {ReactMount.render}
*/
mountComponentIntoNode: function(rootID, container, shouldReuseMarkup) {
var transaction = ReactUpdates.ReactReconcileTransaction.getPooled();
@@ -5590,21 +5589,14 @@ var ReactComponent = {
module.exports = ReactComponent;
-},{"./ReactDescriptor":56,"./ReactOwner":70,"./ReactUpdates":87,"./invariant":134,"./keyMirror":140,"./merge":144}],36:[function(_dereq_,module,exports){
+},{"./Object.assign":29,"./ReactElement":58,"./ReactOwner":74,"./ReactUpdates":91,"./invariant":140,"./keyMirror":146}],38:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactComponentBrowserEnvironment
*/
@@ -5717,21 +5709,14 @@ var ReactComponentBrowserEnvironment = {
module.exports = ReactComponentBrowserEnvironment;
-},{"./ReactDOMIDOperations":45,"./ReactMarkupChecksum":66,"./ReactMount":67,"./ReactPerf":71,"./ReactReconcileTransaction":77,"./getReactRootElementInContainer":128,"./invariant":134,"./setInnerHTML":152}],37:[function(_dereq_,module,exports){
+},{"./ReactDOMIDOperations":47,"./ReactMarkupChecksum":69,"./ReactMount":70,"./ReactPerf":75,"./ReactReconcileTransaction":81,"./getReactRootElementInContainer":134,"./invariant":140,"./setInnerHTML":154}],39:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactComponentWithPureRenderMixin
*/
@@ -5773,21 +5758,14 @@ var ReactComponentWithPureRenderMixin = {
module.exports = ReactComponentWithPureRenderMixin;
-},{"./shallowEqual":153}],38:[function(_dereq_,module,exports){
+},{"./shallowEqual":155}],40:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactCompositeComponent
*/
@@ -5797,10 +5775,11 @@ module.exports = ReactComponentWithPureRenderMixin;
var ReactComponent = _dereq_("./ReactComponent");
var ReactContext = _dereq_("./ReactContext");
var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
-var ReactDescriptor = _dereq_("./ReactDescriptor");
-var ReactDescriptorValidator = _dereq_("./ReactDescriptorValidator");
+var ReactElement = _dereq_("./ReactElement");
+var ReactElementValidator = _dereq_("./ReactElementValidator");
var ReactEmptyComponent = _dereq_("./ReactEmptyComponent");
var ReactErrorUtils = _dereq_("./ReactErrorUtils");
+var ReactLegacyElement = _dereq_("./ReactLegacyElement");
var ReactOwner = _dereq_("./ReactOwner");
var ReactPerf = _dereq_("./ReactPerf");
var ReactPropTransferer = _dereq_("./ReactPropTransferer");
@@ -5808,16 +5787,18 @@ var ReactPropTypeLocations = _dereq_("./ReactPropTypeLocations");
var ReactPropTypeLocationNames = _dereq_("./ReactPropTypeLocationNames");
var ReactUpdates = _dereq_("./ReactUpdates");
+var assign = _dereq_("./Object.assign");
var instantiateReactComponent = _dereq_("./instantiateReactComponent");
var invariant = _dereq_("./invariant");
var keyMirror = _dereq_("./keyMirror");
-var merge = _dereq_("./merge");
-var mixInto = _dereq_("./mixInto");
+var keyOf = _dereq_("./keyOf");
var monitorCodeUse = _dereq_("./monitorCodeUse");
var mapObject = _dereq_("./mapObject");
var shouldUpdateReactComponent = _dereq_("./shouldUpdateReactComponent");
var warning = _dereq_("./warning");
+var MIXINS_KEY = keyOf({mixins: null});
+
/**
* Policies that describe methods in `ReactCompositeComponentInterface`.
*/
@@ -6121,7 +6102,8 @@ var RESERVED_SPEC_KEYS = {
childContextTypes,
ReactPropTypeLocations.childContext
);
- Constructor.childContextTypes = merge(
+ Constructor.childContextTypes = assign(
+ {},
Constructor.childContextTypes,
childContextTypes
);
@@ -6132,7 +6114,11 @@ var RESERVED_SPEC_KEYS = {
contextTypes,
ReactPropTypeLocations.context
);
- Constructor.contextTypes = merge(Constructor.contextTypes, contextTypes);
+ Constructor.contextTypes = assign(
+ {},
+ Constructor.contextTypes,
+ contextTypes
+ );
},
/**
* Special case getDefaultProps which should move into statics but requires
@@ -6154,7 +6140,11 @@ var RESERVED_SPEC_KEYS = {
propTypes,
ReactPropTypeLocations.prop
);
- Constructor.propTypes = merge(Constructor.propTypes, propTypes);
+ Constructor.propTypes = assign(
+ {},
+ Constructor.propTypes,
+ propTypes
+ );
},
statics: function(Constructor, statics) {
mixStaticSpecIntoComponent(Constructor, statics);
@@ -6223,11 +6213,12 @@ function validateLifeCycleOnReplaceState(instance) {
'replaceState(...): Can only update a mounted or mounting component.'
) : invariant(instance.isMounted() ||
compositeLifeCycleState === CompositeLifeCycle.MOUNTING));
- ("production" !== "development" ? invariant(compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE,
+ ("production" !== "development" ? invariant(
+ ReactCurrentOwner.current == null,
'replaceState(...): Cannot update during an existing state transition ' +
- '(such as within `render`). This could potentially cause an infinite ' +
- 'loop so it is forbidden.'
- ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE));
+ '(such as within `render`). Render methods should be a pure function ' +
+ 'of props and state.'
+ ) : invariant(ReactCurrentOwner.current == null));
("production" !== "development" ? invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING,
'replaceState(...): Cannot update while unmounting component. This ' +
'usually means you called setState() on an unmounted component.'
@@ -6235,28 +6226,45 @@ function validateLifeCycleOnReplaceState(instance) {
}
/**
- * Custom version of `mixInto` which handles policy validation and reserved
+ * Mixin helper which handles policy validation and reserved
* specification keys when building `ReactCompositeComponent` classses.
*/
function mixSpecIntoComponent(Constructor, spec) {
+ if (!spec) {
+ return;
+ }
+
("production" !== "development" ? invariant(
- !ReactDescriptor.isValidFactory(spec),
+ !ReactLegacyElement.isValidFactory(spec),
'ReactCompositeComponent: You\'re attempting to ' +
'use a component class as a mixin. Instead, just use a regular object.'
- ) : invariant(!ReactDescriptor.isValidFactory(spec)));
+ ) : invariant(!ReactLegacyElement.isValidFactory(spec)));
("production" !== "development" ? invariant(
- !ReactDescriptor.isValidDescriptor(spec),
+ !ReactElement.isValidElement(spec),
'ReactCompositeComponent: You\'re attempting to ' +
'use a component as a mixin. Instead, just use a regular object.'
- ) : invariant(!ReactDescriptor.isValidDescriptor(spec)));
+ ) : invariant(!ReactElement.isValidElement(spec)));
var proto = Constructor.prototype;
+
+ // By handling mixins before any other properties, we ensure the same
+ // chaining order is applied to methods with DEFINE_MANY policy, whether
+ // mixins are listed before or after these methods in the spec.
+ if (spec.hasOwnProperty(MIXINS_KEY)) {
+ RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
+ }
+
for (var name in spec) {
- var property = spec[name];
if (!spec.hasOwnProperty(name)) {
continue;
}
+ if (name === MIXINS_KEY) {
+ // We have already handled mixins in a special case above
+ continue;
+ }
+
+ var property = spec[name];
validateMethodOverride(proto, name);
if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
@@ -6334,23 +6342,25 @@ function mixStaticSpecIntoComponent(Constructor, statics) {
continue;
}
+ var isReserved = name in RESERVED_SPEC_KEYS;
+ ("production" !== "development" ? invariant(
+ !isReserved,
+ 'ReactCompositeComponent: You are attempting to define a reserved ' +
+ 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' +
+ 'as an instance property instead; it will still be accessible on the ' +
+ 'constructor.',
+ name
+ ) : invariant(!isReserved));
+
var isInherited = name in Constructor;
- var result = property;
- if (isInherited) {
- var existingProperty = Constructor[name];
- var existingType = typeof existingProperty;
- var propertyType = typeof property;
- ("production" !== "development" ? invariant(
- existingType === 'function' && propertyType === 'function',
- 'ReactCompositeComponent: You are attempting to define ' +
- '`%s` on your component more than once, but that is only supported ' +
- 'for functions, which are chained together. This conflict may be ' +
- 'due to a mixin.',
- name
- ) : invariant(existingType === 'function' && propertyType === 'function'));
- result = createChainedFunction(existingProperty, property);
- }
- Constructor[name] = result;
+ ("production" !== "development" ? invariant(
+ !isInherited,
+ 'ReactCompositeComponent: You are attempting to define ' +
+ '`%s` on your component more than once. This conflict may be ' +
+ 'due to a mixin.',
+ name
+ ) : invariant(!isInherited));
+ Constructor[name] = property;
}
}
@@ -6371,7 +6381,10 @@ function mergeObjectsWithNoDuplicateKeys(one, two) {
("production" !== "development" ? invariant(
one[key] === undefined,
'mergeObjectsWithNoDuplicateKeys(): ' +
- 'Tried to merge two objects with the same key: %s',
+ 'Tried to merge two objects with the same key: `%s`. This conflict ' +
+ 'may be due to a mixin; in particular, this may be caused by two ' +
+ 'getInitialState() or getDefaultProps() methods returning objects ' +
+ 'with clashing keys.',
key
) : invariant(one[key] === undefined));
one[key] = value;
@@ -6427,19 +6440,19 @@ function createChainedFunction(one, two) {
* Top Row: ReactComponent.ComponentLifeCycle
* Low Row: ReactComponent.CompositeLifeCycle
*
- * +-------+------------------------------------------------------+--------+
- * | UN | MOUNTED | UN |
- * |MOUNTED| | MOUNTED|
- * +-------+------------------------------------------------------+--------+
- * | ^--------+ +------+ +------+ +------+ +--------^ |
- * | | | | | | | | | | | |
- * | 0--|MOUNTING|-0-|RECEIV|-0-|RECEIV|-0-|RECEIV|-0-| UN |--->0 |
- * | | | |PROPS | | PROPS| | STATE| |MOUNTING| |
- * | | | | | | | | | | | |
- * | | | | | | | | | | | |
- * | +--------+ +------+ +------+ +------+ +--------+ |
- * | | | |
- * +-------+------------------------------------------------------+--------+
+ * +-------+---------------------------------+--------+
+ * | UN | MOUNTED | UN |
+ * |MOUNTED| | MOUNTED|
+ * +-------+---------------------------------+--------+
+ * | ^--------+ +-------+ +--------^ |
+ * | | | | | | | |
+ * | 0--|MOUNTING|-0-|RECEIVE|-0-| UN |--->0 |
+ * | | | |PROPS | |MOUNTING| |
+ * | | | | | | | |
+ * | | | | | | | |
+ * | +--------+ +-------+ +--------+ |
+ * | | | |
+ * +-------+---------------------------------+--------+
*/
var CompositeLifeCycle = keyMirror({
/**
@@ -6456,12 +6469,7 @@ var CompositeLifeCycle = keyMirror({
* Components that are mounted and receiving new props respond to state
* changes differently.
*/
- RECEIVING_PROPS: null,
- /**
- * Components that are mounted and receiving new state are guarded against
- * additional state changes.
- */
- RECEIVING_STATE: null
+ RECEIVING_PROPS: null
});
/**
@@ -6472,11 +6480,11 @@ var ReactCompositeComponentMixin = {
/**
* Base constructor for all composite component.
*
- * @param {ReactDescriptor} descriptor
+ * @param {ReactElement} element
* @final
* @internal
*/
- construct: function(descriptor) {
+ construct: function(element) {
// Children can be either an array or more than one argument
ReactComponent.Mixin.construct.apply(this, arguments);
ReactOwner.Mixin.construct.apply(this, arguments);
@@ -6485,7 +6493,7 @@ var ReactCompositeComponentMixin = {
this._pendingState = null;
// This is the public post-processed context. The real context and pending
- // context lives on the descriptor.
+ // context lives on the element.
this.context = null;
this._compositeLifeCycleState = null;
@@ -6528,7 +6536,7 @@ var ReactCompositeComponentMixin = {
this._bindAutoBindMethods();
}
- this.context = this._processContext(this._descriptor._context);
+ this.context = this._processContext(this._currentElement._context);
this.props = this._processProps(this.props);
this.state = this.getInitialState ? this.getInitialState() : null;
@@ -6552,7 +6560,8 @@ var ReactCompositeComponentMixin = {
}
this._renderedComponent = instantiateReactComponent(
- this._renderValidatedComponent()
+ this._renderValidatedComponent(),
+ this._currentElement.type // The wrapping type
);
// Done with mounting, `setState` will now trigger UI changes.
@@ -6624,7 +6633,7 @@ var ReactCompositeComponentMixin = {
}
// Merge with `_pendingState` if it exists, otherwise with existing state.
this.replaceState(
- merge(this._pendingState || this.state, partialState),
+ assign({}, this._pendingState || this.state, partialState),
callback
);
},
@@ -6712,7 +6721,7 @@ var ReactCompositeComponentMixin = {
name
) : invariant(name in this.constructor.childContextTypes));
}
- return merge(currentContext, childContext);
+ return assign({}, currentContext, childContext);
}
return currentContext;
},
@@ -6727,25 +6736,13 @@ var ReactCompositeComponentMixin = {
* @private
*/
_processProps: function(newProps) {
- var defaultProps = this.constructor.defaultProps;
- var props;
- if (defaultProps) {
- props = merge(newProps);
- for (var propName in defaultProps) {
- if (typeof props[propName] === 'undefined') {
- props[propName] = defaultProps[propName];
- }
- }
- } else {
- props = newProps;
- }
if ("production" !== "development") {
var propTypes = this.constructor.propTypes;
if (propTypes) {
- this._checkPropTypes(propTypes, props, ReactPropTypeLocations.prop);
+ this._checkPropTypes(propTypes, newProps, ReactPropTypeLocations.prop);
}
}
- return props;
+ return newProps;
},
/**
@@ -6757,7 +6754,7 @@ var ReactCompositeComponentMixin = {
* @private
*/
_checkPropTypes: function(propTypes, props, location) {
- // TODO: Stop validating prop types here and only use the descriptor
+ // TODO: Stop validating prop types here and only use the element
// validation.
var componentName = this.constructor.displayName;
for (var propName in propTypes) {
@@ -6776,7 +6773,7 @@ var ReactCompositeComponentMixin = {
},
/**
- * If any of `_pendingDescriptor`, `_pendingState`, or `_pendingForceUpdate`
+ * If any of `_pendingElement`, `_pendingState`, or `_pendingForceUpdate`
* is set, update the component.
*
* @param {ReactReconcileTransaction} transaction
@@ -6791,7 +6788,7 @@ var ReactCompositeComponentMixin = {
return;
}
- if (this._pendingDescriptor == null &&
+ if (this._pendingElement == null &&
this._pendingState == null &&
!this._pendingForceUpdate) {
return;
@@ -6799,12 +6796,12 @@ var ReactCompositeComponentMixin = {
var nextContext = this.context;
var nextProps = this.props;
- var nextDescriptor = this._descriptor;
- if (this._pendingDescriptor != null) {
- nextDescriptor = this._pendingDescriptor;
- nextContext = this._processContext(nextDescriptor._context);
- nextProps = this._processProps(nextDescriptor.props);
- this._pendingDescriptor = null;
+ var nextElement = this._currentElement;
+ if (this._pendingElement != null) {
+ nextElement = this._pendingElement;
+ nextContext = this._processContext(nextElement._context);
+ nextProps = this._processProps(nextElement.props);
+ this._pendingElement = null;
this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_PROPS;
if (this.componentWillReceiveProps) {
@@ -6812,51 +6809,47 @@ var ReactCompositeComponentMixin = {
}
}
- this._compositeLifeCycleState = CompositeLifeCycle.RECEIVING_STATE;
+ this._compositeLifeCycleState = null;
var nextState = this._pendingState || this.state;
this._pendingState = null;
- try {
- var shouldUpdate =
- this._pendingForceUpdate ||
- !this.shouldComponentUpdate ||
- this.shouldComponentUpdate(nextProps, nextState, nextContext);
-
- if ("production" !== "development") {
- if (typeof shouldUpdate === "undefined") {
- console.warn(
- (this.constructor.displayName || 'ReactCompositeComponent') +
- '.shouldComponentUpdate(): Returned undefined instead of a ' +
- 'boolean value. Make sure to return true or false.'
- );
- }
- }
+ var shouldUpdate =
+ this._pendingForceUpdate ||
+ !this.shouldComponentUpdate ||
+ this.shouldComponentUpdate(nextProps, nextState, nextContext);
- if (shouldUpdate) {
- this._pendingForceUpdate = false;
- // Will set `this.props`, `this.state` and `this.context`.
- this._performComponentUpdate(
- nextDescriptor,
- nextProps,
- nextState,
- nextContext,
- transaction
+ if ("production" !== "development") {
+ if (typeof shouldUpdate === "undefined") {
+ console.warn(
+ (this.constructor.displayName || 'ReactCompositeComponent') +
+ '.shouldComponentUpdate(): Returned undefined instead of a ' +
+ 'boolean value. Make sure to return true or false.'
);
- } else {
- // If it's determined that a component should not update, we still want
- // to set props and state.
- this._descriptor = nextDescriptor;
- this.props = nextProps;
- this.state = nextState;
- this.context = nextContext;
-
- // Owner cannot change because shouldUpdateReactComponent doesn't allow
- // it. TODO: Remove this._owner completely.
- this._owner = nextDescriptor._owner;
}
- } finally {
- this._compositeLifeCycleState = null;
+ }
+
+ if (shouldUpdate) {
+ this._pendingForceUpdate = false;
+ // Will set `this.props`, `this.state` and `this.context`.
+ this._performComponentUpdate(
+ nextElement,
+ nextProps,
+ nextState,
+ nextContext,
+ transaction
+ );
+ } else {
+ // If it's determined that a component should not update, we still want
+ // to set props and state.
+ this._currentElement = nextElement;
+ this.props = nextProps;
+ this.state = nextState;
+ this.context = nextContext;
+
+ // Owner cannot change because shouldUpdateReactComponent doesn't allow
+ // it. TODO: Remove this._owner completely.
+ this._owner = nextElement._owner;
}
},
@@ -6864,7 +6857,7 @@ var ReactCompositeComponentMixin = {
* Merges new props and state, notifies delegate methods of update and
* performs update.
*
- * @param {ReactDescriptor} nextDescriptor Next descriptor
+ * @param {ReactElement} nextElement Next element
* @param {object} nextProps Next public object to set as properties.
* @param {?object} nextState Next object to set as state.
* @param {?object} nextContext Next public object to set as context.
@@ -6872,13 +6865,13 @@ var ReactCompositeComponentMixin = {
* @private
*/
_performComponentUpdate: function(
- nextDescriptor,
+ nextElement,
nextProps,
nextState,
nextContext,
transaction
) {
- var prevDescriptor = this._descriptor;
+ var prevElement = this._currentElement;
var prevProps = this.props;
var prevState = this.state;
var prevContext = this.context;
@@ -6887,18 +6880,18 @@ var ReactCompositeComponentMixin = {
this.componentWillUpdate(nextProps, nextState, nextContext);
}
- this._descriptor = nextDescriptor;
+ this._currentElement = nextElement;
this.props = nextProps;
this.state = nextState;
this.context = nextContext;
// Owner cannot change because shouldUpdateReactComponent doesn't allow
// it. TODO: Remove this._owner completely.
- this._owner = nextDescriptor._owner;
+ this._owner = nextElement._owner;
this.updateComponent(
transaction,
- prevDescriptor
+ prevElement
);
if (this.componentDidUpdate) {
@@ -6909,22 +6902,22 @@ var ReactCompositeComponentMixin = {
}
},
- receiveComponent: function(nextDescriptor, transaction) {
- if (nextDescriptor === this._descriptor &&
- nextDescriptor._owner != null) {
- // Since descriptors are immutable after the owner is rendered,
+ receiveComponent: function(nextElement, transaction) {
+ if (nextElement === this._currentElement &&
+ nextElement._owner != null) {
+ // Since elements are immutable after the owner is rendered,
// we can do a cheap identity compare here to determine if this is a
// superfluous reconcile. It's possible for state to be mutable but such
// change should trigger an update of the owner which would recreate
- // the descriptor. We explicitly check for the existence of an owner since
- // it's possible for a descriptor created outside a composite to be
+ // the element. We explicitly check for the existence of an owner since
+ // it's possible for a element created outside a composite to be
// deeply mutated and reused.
return;
}
ReactComponent.Mixin.receiveComponent.call(
this,
- nextDescriptor,
+ nextElement,
transaction
);
},
@@ -6936,31 +6929,34 @@ var ReactCompositeComponentMixin = {
* Sophisticated clients may wish to override this.
*
* @param {ReactReconcileTransaction} transaction
- * @param {ReactDescriptor} prevDescriptor
+ * @param {ReactElement} prevElement
* @internal
* @overridable
*/
updateComponent: ReactPerf.measure(
'ReactCompositeComponent',
'updateComponent',
- function(transaction, prevParentDescriptor) {
+ function(transaction, prevParentElement) {
ReactComponent.Mixin.updateComponent.call(
this,
transaction,
- prevParentDescriptor
+ prevParentElement
);
var prevComponentInstance = this._renderedComponent;
- var prevDescriptor = prevComponentInstance._descriptor;
- var nextDescriptor = this._renderValidatedComponent();
- if (shouldUpdateReactComponent(prevDescriptor, nextDescriptor)) {
- prevComponentInstance.receiveComponent(nextDescriptor, transaction);
+ var prevElement = prevComponentInstance._currentElement;
+ var nextElement = this._renderValidatedComponent();
+ if (shouldUpdateReactComponent(prevElement, nextElement)) {
+ prevComponentInstance.receiveComponent(nextElement, transaction);
} else {
// These two IDs are actually the same! But nothing should rely on that.
var thisID = this._rootNodeID;
var prevComponentID = prevComponentInstance._rootNodeID;
prevComponentInstance.unmountComponent();
- this._renderedComponent = instantiateReactComponent(nextDescriptor);
+ this._renderedComponent = instantiateReactComponent(
+ nextElement,
+ this._currentElement.type
+ );
var nextMarkup = this._renderedComponent.mountComponent(
thisID,
transaction,
@@ -6998,12 +6994,12 @@ var ReactCompositeComponentMixin = {
) : invariant(this.isMounted() ||
compositeLifeCycleState === CompositeLifeCycle.MOUNTING));
("production" !== "development" ? invariant(
- compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE &&
- compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING,
+ compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
+ ReactCurrentOwner.current == null,
'forceUpdate(...): Cannot force an update while unmounting component ' +
- 'or during an existing state transition (such as within `render`).'
- ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.RECEIVING_STATE &&
- compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING));
+ 'or within a `render` function.'
+ ) : invariant(compositeLifeCycleState !== CompositeLifeCycle.UNMOUNTING &&
+ ReactCurrentOwner.current == null));
this._pendingForceUpdate = true;
ReactUpdates.enqueueUpdate(this, callback);
},
@@ -7018,7 +7014,7 @@ var ReactCompositeComponentMixin = {
var renderedComponent;
var previousContext = ReactContext.current;
ReactContext.current = this._processChildContext(
- this._descriptor._context
+ this._currentElement._context
);
ReactCurrentOwner.current = this;
try {
@@ -7034,11 +7030,11 @@ var ReactCompositeComponentMixin = {
ReactCurrentOwner.current = null;
}
("production" !== "development" ? invariant(
- ReactDescriptor.isValidDescriptor(renderedComponent),
+ ReactElement.isValidElement(renderedComponent),
'%s.render(): A valid ReactComponent must be returned. You may have ' +
'returned undefined, an array or some other invalid object.',
this.constructor.displayName || 'ReactCompositeComponent'
- ) : invariant(ReactDescriptor.isValidDescriptor(renderedComponent)));
+ ) : invariant(ReactElement.isValidElement(renderedComponent)));
return renderedComponent;
}
),
@@ -7067,16 +7063,14 @@ var ReactCompositeComponentMixin = {
*/
_bindAutoBindMethod: function(method) {
var component = this;
- var boundMethod = function() {
- return method.apply(component, arguments);
- };
+ var boundMethod = method.bind(component);
if ("production" !== "development") {
boundMethod.__reactBoundContext = component;
boundMethod.__reactBoundMethod = method;
boundMethod.__reactBoundArguments = null;
var componentName = component.constructor.displayName;
var _bind = boundMethod.bind;
- boundMethod.bind = function(newThis ) {var args=Array.prototype.slice.call(arguments,1);
+ boundMethod.bind = function(newThis ) {for (var args=[],$__0=1,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
// User is trying to bind() an autobound method; we effectively will
// ignore the value of "this" that the user is trying to use, so
// let's warn.
@@ -7107,10 +7101,13 @@ var ReactCompositeComponentMixin = {
};
var ReactCompositeComponentBase = function() {};
-mixInto(ReactCompositeComponentBase, ReactComponent.Mixin);
-mixInto(ReactCompositeComponentBase, ReactOwner.Mixin);
-mixInto(ReactCompositeComponentBase, ReactPropTransferer.Mixin);
-mixInto(ReactCompositeComponentBase, ReactCompositeComponentMixin);
+assign(
+ ReactCompositeComponentBase.prototype,
+ ReactComponent.Mixin,
+ ReactOwner.Mixin,
+ ReactPropTransferer.Mixin,
+ ReactCompositeComponentMixin
+);
/**
* Module for creating composite components.
@@ -7134,8 +7131,10 @@ var ReactCompositeComponent = {
* @public
*/
createClass: function(spec) {
- var Constructor = function(props, owner) {
- this.construct(props, owner);
+ var Constructor = function(props) {
+ // This constructor is overridden by mocks. The argument is used
+ // by mocks to assert on what gets mounted. This will later be used
+ // by the stand-alone class implementation.
};
Constructor.prototype = new ReactCompositeComponentBase();
Constructor.prototype.constructor = Constructor;
@@ -7178,17 +7177,14 @@ var ReactCompositeComponent = {
}
}
- var descriptorFactory = ReactDescriptor.createFactory(Constructor);
-
if ("production" !== "development") {
- return ReactDescriptorValidator.createFactory(
- descriptorFactory,
- Constructor.propTypes,
- Constructor.contextTypes
+ return ReactLegacyElement.wrapFactory(
+ ReactElementValidator.createFactory(Constructor)
);
}
-
- return descriptorFactory;
+ return ReactLegacyElement.wrapFactory(
+ ReactElement.createFactory(Constructor)
+ );
},
injection: {
@@ -7200,28 +7196,21 @@ var ReactCompositeComponent = {
module.exports = ReactCompositeComponent;
-},{"./ReactComponent":35,"./ReactContext":39,"./ReactCurrentOwner":40,"./ReactDescriptor":56,"./ReactDescriptorValidator":57,"./ReactEmptyComponent":58,"./ReactErrorUtils":59,"./ReactOwner":70,"./ReactPerf":71,"./ReactPropTransferer":72,"./ReactPropTypeLocationNames":73,"./ReactPropTypeLocations":74,"./ReactUpdates":87,"./instantiateReactComponent":133,"./invariant":134,"./keyMirror":140,"./mapObject":142,"./merge":144,"./mixInto":147,"./monitorCodeUse":148,"./shouldUpdateReactComponent":154,"./warning":158}],39:[function(_dereq_,module,exports){
+},{"./Object.assign":29,"./ReactComponent":37,"./ReactContext":41,"./ReactCurrentOwner":42,"./ReactElement":58,"./ReactElementValidator":59,"./ReactEmptyComponent":60,"./ReactErrorUtils":61,"./ReactLegacyElement":67,"./ReactOwner":74,"./ReactPerf":75,"./ReactPropTransferer":76,"./ReactPropTypeLocationNames":77,"./ReactPropTypeLocations":78,"./ReactUpdates":91,"./instantiateReactComponent":139,"./invariant":140,"./keyMirror":146,"./keyOf":147,"./mapObject":148,"./monitorCodeUse":150,"./shouldUpdateReactComponent":156,"./warning":160}],41:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactContext
*/
"use strict";
-var merge = _dereq_("./merge");
+var assign = _dereq_("./Object.assign");
/**
* Keeps track of the current context.
@@ -7243,7 +7232,7 @@ var ReactContext = {
* A typical use case might look like
*
* render: function() {
- * var children = ReactContext.withContext({foo: 'foo'} () => (
+ * var children = ReactContext.withContext({foo: 'foo'}, () => (
*
* ));
* return <div>{children}</div>;
@@ -7256,7 +7245,7 @@ var ReactContext = {
withContext: function(newContext, scopedCallback) {
var result;
var previousContext = ReactContext.current;
- ReactContext.current = merge(previousContext, newContext);
+ ReactContext.current = assign({}, previousContext, newContext);
try {
result = scopedCallback();
} finally {
@@ -7269,21 +7258,14 @@ var ReactContext = {
module.exports = ReactContext;
-},{"./merge":144}],40:[function(_dereq_,module,exports){
+},{"./Object.assign":29}],42:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactCurrentOwner
*/
@@ -7310,21 +7292,14 @@ var ReactCurrentOwner = {
module.exports = ReactCurrentOwner;
-},{}],41:[function(_dereq_,module,exports){
+},{}],43:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDOM
* @typechecks static-only
@@ -7332,45 +7307,27 @@ module.exports = ReactCurrentOwner;
"use strict";
-var ReactDescriptor = _dereq_("./ReactDescriptor");
-var ReactDescriptorValidator = _dereq_("./ReactDescriptorValidator");
-var ReactDOMComponent = _dereq_("./ReactDOMComponent");
+var ReactElement = _dereq_("./ReactElement");
+var ReactElementValidator = _dereq_("./ReactElementValidator");
+var ReactLegacyElement = _dereq_("./ReactLegacyElement");
-var mergeInto = _dereq_("./mergeInto");
var mapObject = _dereq_("./mapObject");
/**
- * Creates a new React class that is idempotent and capable of containing other
- * React components. It accepts event listeners and DOM properties that are
- * valid according to `DOMProperty`.
- *
- * - Event listeners: `onClick`, `onMouseDown`, etc.
- * - DOM properties: `className`, `name`, `title`, etc.
- *
- * The `style` property functions differently from the DOM API. It accepts an
- * object mapping of style properties to values.
+ * Create a factory that creates HTML tag elements.
*
- * @param {boolean} omitClose True if the close tag should be omitted.
* @param {string} tag Tag name (e.g. `div`).
* @private
*/
-function createDOMComponentClass(omitClose, tag) {
- var Constructor = function(descriptor) {
- this.construct(descriptor);
- };
- Constructor.prototype = new ReactDOMComponent(tag, omitClose);
- Constructor.prototype.constructor = Constructor;
- Constructor.displayName = tag;
-
- var ConvenienceConstructor = ReactDescriptor.createFactory(Constructor);
-
+function createDOMFactory(tag) {
if ("production" !== "development") {
- return ReactDescriptorValidator.createFactory(
- ConvenienceConstructor
+ return ReactLegacyElement.markNonLegacyFactory(
+ ReactElementValidator.createFactory(tag)
);
}
-
- return ConvenienceConstructor;
+ return ReactLegacyElement.markNonLegacyFactory(
+ ReactElement.createFactory(tag)
+ );
}
/**
@@ -7380,162 +7337,150 @@ function createDOMComponentClass(omitClose, tag) {
* @public
*/
var ReactDOM = mapObject({
- a: false,
- abbr: false,
- address: false,
- area: true,
- article: false,
- aside: false,
- audio: false,
- b: false,
- base: true,
- bdi: false,
- bdo: false,
- big: false,
- blockquote: false,
- body: false,
- br: true,
- button: false,
- canvas: false,
- caption: false,
- cite: false,
- code: false,
- col: true,
- colgroup: false,
- data: false,
- datalist: false,
- dd: false,
- del: false,
- details: false,
- dfn: false,
- div: false,
- dl: false,
- dt: false,
- em: false,
- embed: true,
- fieldset: false,
- figcaption: false,
- figure: false,
- footer: false,
- form: false, // NOTE: Injected, see `ReactDOMForm`.
- h1: false,
- h2: false,
- h3: false,
- h4: false,
- h5: false,
- h6: false,
- head: false,
- header: false,
- hr: true,
- html: false,
- i: false,
- iframe: false,
- img: true,
- input: true,
- ins: false,
- kbd: false,
- keygen: true,
- label: false,
- legend: false,
- li: false,
- link: true,
- main: false,
- map: false,
- mark: false,
- menu: false,
- menuitem: false, // NOTE: Close tag should be omitted, but causes problems.
- meta: true,
- meter: false,
- nav: false,
- noscript: false,
- object: false,
- ol: false,
- optgroup: false,
- option: false,
- output: false,
- p: false,
- param: true,
- pre: false,
- progress: false,
- q: false,
- rp: false,
- rt: false,
- ruby: false,
- s: false,
- samp: false,
- script: false,
- section: false,
- select: false,
- small: false,
- source: true,
- span: false,
- strong: false,
- style: false,
- sub: false,
- summary: false,
- sup: false,
- table: false,
- tbody: false,
- td: false,
- textarea: false, // NOTE: Injected, see `ReactDOMTextarea`.
- tfoot: false,
- th: false,
- thead: false,
- time: false,
- title: false,
- tr: false,
- track: true,
- u: false,
- ul: false,
- 'var': false,
- video: false,
- wbr: true,
+ a: 'a',
+ abbr: 'abbr',
+ address: 'address',
+ area: 'area',
+ article: 'article',
+ aside: 'aside',
+ audio: 'audio',
+ b: 'b',
+ base: 'base',
+ bdi: 'bdi',
+ bdo: 'bdo',
+ big: 'big',
+ blockquote: 'blockquote',
+ body: 'body',
+ br: 'br',
+ button: 'button',
+ canvas: 'canvas',
+ caption: 'caption',
+ cite: 'cite',
+ code: 'code',
+ col: 'col',
+ colgroup: 'colgroup',
+ data: 'data',
+ datalist: 'datalist',
+ dd: 'dd',
+ del: 'del',
+ details: 'details',
+ dfn: 'dfn',
+ dialog: 'dialog',
+ div: 'div',
+ dl: 'dl',
+ dt: 'dt',
+ em: 'em',
+ embed: 'embed',
+ fieldset: 'fieldset',
+ figcaption: 'figcaption',
+ figure: 'figure',
+ footer: 'footer',
+ form: 'form',
+ h1: 'h1',
+ h2: 'h2',
+ h3: 'h3',
+ h4: 'h4',
+ h5: 'h5',
+ h6: 'h6',
+ head: 'head',
+ header: 'header',
+ hr: 'hr',
+ html: 'html',
+ i: 'i',
+ iframe: 'iframe',
+ img: 'img',
+ input: 'input',
+ ins: 'ins',
+ kbd: 'kbd',
+ keygen: 'keygen',
+ label: 'label',
+ legend: 'legend',
+ li: 'li',
+ link: 'link',
+ main: 'main',
+ map: 'map',
+ mark: 'mark',
+ menu: 'menu',
+ menuitem: 'menuitem',
+ meta: 'meta',
+ meter: 'meter',
+ nav: 'nav',
+ noscript: 'noscript',
+ object: 'object',
+ ol: 'ol',
+ optgroup: 'optgroup',
+ option: 'option',
+ output: 'output',
+ p: 'p',
+ param: 'param',
+ picture: 'picture',
+ pre: 'pre',
+ progress: 'progress',
+ q: 'q',
+ rp: 'rp',
+ rt: 'rt',
+ ruby: 'ruby',
+ s: 's',
+ samp: 'samp',
+ script: 'script',
+ section: 'section',
+ select: 'select',
+ small: 'small',
+ source: 'source',
+ span: 'span',
+ strong: 'strong',
+ style: 'style',
+ sub: 'sub',
+ summary: 'summary',
+ sup: 'sup',
+ table: 'table',
+ tbody: 'tbody',
+ td: 'td',
+ textarea: 'textarea',
+ tfoot: 'tfoot',
+ th: 'th',
+ thead: 'thead',
+ time: 'time',
+ title: 'title',
+ tr: 'tr',
+ track: 'track',
+ u: 'u',
+ ul: 'ul',
+ 'var': 'var',
+ video: 'video',
+ wbr: 'wbr',
// SVG
- circle: false,
- defs: false,
- ellipse: false,
- g: false,
- line: false,
- linearGradient: false,
- mask: false,
- path: false,
- pattern: false,
- polygon: false,
- polyline: false,
- radialGradient: false,
- rect: false,
- stop: false,
- svg: false,
- text: false,
- tspan: false
-}, createDOMComponentClass);
-
-var injection = {
- injectComponentClasses: function(componentClasses) {
- mergeInto(ReactDOM, componentClasses);
- }
-};
-
-ReactDOM.injection = injection;
+ circle: 'circle',
+ defs: 'defs',
+ ellipse: 'ellipse',
+ g: 'g',
+ line: 'line',
+ linearGradient: 'linearGradient',
+ mask: 'mask',
+ path: 'path',
+ pattern: 'pattern',
+ polygon: 'polygon',
+ polyline: 'polyline',
+ radialGradient: 'radialGradient',
+ rect: 'rect',
+ stop: 'stop',
+ svg: 'svg',
+ text: 'text',
+ tspan: 'tspan'
+
+}, createDOMFactory);
module.exports = ReactDOM;
-},{"./ReactDOMComponent":43,"./ReactDescriptor":56,"./ReactDescriptorValidator":57,"./mapObject":142,"./mergeInto":146}],42:[function(_dereq_,module,exports){
+},{"./ReactElement":58,"./ReactElementValidator":59,"./ReactLegacyElement":67,"./mapObject":148}],44:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDOMButton
*/
@@ -7545,12 +7490,13 @@ module.exports = ReactDOM;
var AutoFocusMixin = _dereq_("./AutoFocusMixin");
var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
+var ReactElement = _dereq_("./ReactElement");
var ReactDOM = _dereq_("./ReactDOM");
var keyMirror = _dereq_("./keyMirror");
-// Store a reference to the <button> `ReactDOMComponent`.
-var button = ReactDOM.button;
+// Store a reference to the <button> `ReactDOMComponent`. TODO: use string
+var button = ReactElement.createFactory(ReactDOM.button.type);
var mouseListenerNames = keyMirror({
onClick: true,
@@ -7592,21 +7538,14 @@ var ReactDOMButton = ReactCompositeComponent.createClass({
module.exports = ReactDOMButton;
-},{"./AutoFocusMixin":1,"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41,"./keyMirror":140}],43:[function(_dereq_,module,exports){
+},{"./AutoFocusMixin":2,"./ReactBrowserComponentMixin":32,"./ReactCompositeComponent":40,"./ReactDOM":43,"./ReactElement":58,"./keyMirror":146}],45:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDOMComponent
* @typechecks static-only
@@ -7624,11 +7563,12 @@ var ReactMount = _dereq_("./ReactMount");
var ReactMultiChild = _dereq_("./ReactMultiChild");
var ReactPerf = _dereq_("./ReactPerf");
+var assign = _dereq_("./Object.assign");
var escapeTextForBrowser = _dereq_("./escapeTextForBrowser");
var invariant = _dereq_("./invariant");
+var isEventSupported = _dereq_("./isEventSupported");
var keyOf = _dereq_("./keyOf");
-var merge = _dereq_("./merge");
-var mixInto = _dereq_("./mixInto");
+var monitorCodeUse = _dereq_("./monitorCodeUse");
var deleteListener = ReactBrowserEventEmitter.deleteListener;
var listenTo = ReactBrowserEventEmitter.listenTo;
@@ -7653,6 +7593,16 @@ function assertValidProps(props) {
props.children == null || props.dangerouslySetInnerHTML == null,
'Can only set one of `children` or `props.dangerouslySetInnerHTML`.'
) : invariant(props.children == null || props.dangerouslySetInnerHTML == null));
+ if ("production" !== "development") {
+ if (props.contentEditable && props.children != null) {
+ console.warn(
+ 'A component is `contentEditable` and contains `children` managed by ' +
+ 'React. It is now your responsibility to guarantee that none of those '+
+ 'nodes are unexpectedly modified or duplicated. This is probably not ' +
+ 'intentional.'
+ );
+ }
+ }
("production" !== "development" ? invariant(
props.style == null || typeof props.style === 'object',
'The `style` prop expects a mapping from style properties to values, ' +
@@ -7661,6 +7611,15 @@ function assertValidProps(props) {
}
function putListener(id, registrationName, listener, transaction) {
+ if ("production" !== "development") {
+ // IE8 has no API for event capturing and the `onScroll` event doesn't
+ // bubble.
+ if (registrationName === 'onScroll' &&
+ !isEventSupported('scroll', true)) {
+ monitorCodeUse('react_no_scroll_event');
+ console.warn('This browser doesn\'t support the `onScroll` event');
+ }
+ }
var container = ReactMount.findReactContainerForID(id);
if (container) {
var doc = container.nodeType === ELEMENT_NODE_TYPE ?
@@ -7675,18 +7634,66 @@ function putListener(id, registrationName, listener, transaction) {
);
}
+// For HTML, certain tags should omit their close tag. We keep a whitelist for
+// those special cased tags.
+
+var omittedCloseTags = {
+ 'area': true,
+ 'base': true,
+ 'br': true,
+ 'col': true,
+ 'embed': true,
+ 'hr': true,
+ 'img': true,
+ 'input': true,
+ 'keygen': true,
+ 'link': true,
+ 'meta': true,
+ 'param': true,
+ 'source': true,
+ 'track': true,
+ 'wbr': true
+ // NOTE: menuitem's close tag should be omitted, but that causes problems.
+};
+
+// We accept any tag to be rendered but since this gets injected into abitrary
+// HTML, we want to make sure that it's a safe tag.
+// http://www.w3.org/TR/REC-xml/#NT-Name
+
+var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
+var validatedTagCache = {};
+var hasOwnProperty = {}.hasOwnProperty;
+
+function validateDangerousTag(tag) {
+ if (!hasOwnProperty.call(validatedTagCache, tag)) {
+ ("production" !== "development" ? invariant(VALID_TAG_REGEX.test(tag), 'Invalid tag: %s', tag) : invariant(VALID_TAG_REGEX.test(tag)));
+ validatedTagCache[tag] = true;
+ }
+}
/**
+ * Creates a new React class that is idempotent and capable of containing other
+ * React components. It accepts event listeners and DOM properties that are
+ * valid according to `DOMProperty`.
+ *
+ * - Event listeners: `onClick`, `onMouseDown`, etc.
+ * - DOM properties: `className`, `name`, `title`, etc.
+ *
+ * The `style` property functions differently from the DOM API. It accepts an
+ * object mapping of style properties to values.
+ *
* @constructor ReactDOMComponent
* @extends ReactComponent
* @extends ReactMultiChild
*/
-function ReactDOMComponent(tag, omitClose) {
- this._tagOpen = '<' + tag;
- this._tagClose = omitClose ? '' : '</' + tag + '>';
+function ReactDOMComponent(tag) {
+ validateDangerousTag(tag);
+ this._tag = tag;
this.tagName = tag.toUpperCase();
}
+ReactDOMComponent.displayName = 'ReactDOMComponent';
+
ReactDOMComponent.Mixin = {
/**
@@ -7710,10 +7717,11 @@ ReactDOMComponent.Mixin = {
mountDepth
);
assertValidProps(this.props);
+ var closeTag = omittedCloseTags[this._tag] ? '' : '</' + this._tag + '>';
return (
this._createOpenTagMarkupAndPutListeners(transaction) +
this._createContentMarkup(transaction) +
- this._tagClose
+ closeTag
);
}
),
@@ -7732,7 +7740,7 @@ ReactDOMComponent.Mixin = {
*/
_createOpenTagMarkupAndPutListeners: function(transaction) {
var props = this.props;
- var ret = this._tagOpen;
+ var ret = '<' + this._tag;
for (var propKey in props) {
if (!props.hasOwnProperty(propKey)) {
@@ -7747,7 +7755,7 @@ ReactDOMComponent.Mixin = {
} else {
if (propKey === STYLE) {
if (propValue) {
- propValue = props.style = merge(props.style);
+ propValue = props.style = assign({}, props.style);
}
propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
}
@@ -7800,22 +7808,22 @@ ReactDOMComponent.Mixin = {
return '';
},
- receiveComponent: function(nextDescriptor, transaction) {
- if (nextDescriptor === this._descriptor &&
- nextDescriptor._owner != null) {
- // Since descriptors are immutable after the owner is rendered,
+ receiveComponent: function(nextElement, transaction) {
+ if (nextElement === this._currentElement &&
+ nextElement._owner != null) {
+ // Since elements are immutable after the owner is rendered,
// we can do a cheap identity compare here to determine if this is a
// superfluous reconcile. It's possible for state to be mutable but such
// change should trigger an update of the owner which would recreate
- // the descriptor. We explicitly check for the existence of an owner since
- // it's possible for a descriptor created outside a composite to be
+ // the element. We explicitly check for the existence of an owner since
+ // it's possible for a element created outside a composite to be
// deeply mutated and reused.
return;
}
ReactComponent.Mixin.receiveComponent.call(
this,
- nextDescriptor,
+ nextElement,
transaction
);
},
@@ -7825,22 +7833,22 @@ ReactDOMComponent.Mixin = {
* attached to the DOM. Reconciles the root DOM node, then recurses.
*
* @param {ReactReconcileTransaction} transaction
- * @param {ReactDescriptor} prevDescriptor
+ * @param {ReactElement} prevElement
* @internal
* @overridable
*/
updateComponent: ReactPerf.measure(
'ReactDOMComponent',
'updateComponent',
- function(transaction, prevDescriptor) {
- assertValidProps(this._descriptor.props);
+ function(transaction, prevElement) {
+ assertValidProps(this._currentElement.props);
ReactComponent.Mixin.updateComponent.call(
this,
transaction,
- prevDescriptor
+ prevElement
);
- this._updateDOMProperties(prevDescriptor.props, transaction);
- this._updateDOMChildren(prevDescriptor.props, transaction);
+ this._updateDOMProperties(prevElement.props, transaction);
+ this._updateDOMChildren(prevElement.props, transaction);
}
),
@@ -7896,7 +7904,7 @@ ReactDOMComponent.Mixin = {
}
if (propKey === STYLE) {
if (nextProp) {
- nextProp = nextProps.style = merge(nextProp);
+ nextProp = nextProps.style = assign({}, nextProp);
}
if (lastProp) {
// Unset styles on `lastProp` but not on `nextProp`.
@@ -8005,28 +8013,24 @@ ReactDOMComponent.Mixin = {
};
-mixInto(ReactDOMComponent, ReactComponent.Mixin);
-mixInto(ReactDOMComponent, ReactDOMComponent.Mixin);
-mixInto(ReactDOMComponent, ReactMultiChild.Mixin);
-mixInto(ReactDOMComponent, ReactBrowserComponentMixin);
+assign(
+ ReactDOMComponent.prototype,
+ ReactComponent.Mixin,
+ ReactDOMComponent.Mixin,
+ ReactMultiChild.Mixin,
+ ReactBrowserComponentMixin
+);
module.exports = ReactDOMComponent;
-},{"./CSSPropertyOperations":5,"./DOMProperty":11,"./DOMPropertyOperations":12,"./ReactBrowserComponentMixin":30,"./ReactBrowserEventEmitter":31,"./ReactComponent":35,"./ReactMount":67,"./ReactMultiChild":68,"./ReactPerf":71,"./escapeTextForBrowser":118,"./invariant":134,"./keyOf":141,"./merge":144,"./mixInto":147}],44:[function(_dereq_,module,exports){
+},{"./CSSPropertyOperations":6,"./DOMProperty":12,"./DOMPropertyOperations":13,"./Object.assign":29,"./ReactBrowserComponentMixin":32,"./ReactBrowserEventEmitter":33,"./ReactComponent":37,"./ReactMount":70,"./ReactMultiChild":71,"./ReactPerf":75,"./escapeTextForBrowser":123,"./invariant":140,"./isEventSupported":141,"./keyOf":147,"./monitorCodeUse":150}],46:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDOMForm
*/
@@ -8037,10 +8041,11 @@ var EventConstants = _dereq_("./EventConstants");
var LocalEventTrapMixin = _dereq_("./LocalEventTrapMixin");
var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
+var ReactElement = _dereq_("./ReactElement");
var ReactDOM = _dereq_("./ReactDOM");
-// Store a reference to the <form> `ReactDOMComponent`.
-var form = ReactDOM.form;
+// Store a reference to the <form> `ReactDOMComponent`. TODO: use string
+var form = ReactElement.createFactory(ReactDOM.form.type);
/**
* Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
@@ -8057,7 +8062,7 @@ var ReactDOMForm = ReactCompositeComponent.createClass({
// TODO: Instead of using `ReactDOM` directly, we should use JSX. However,
// `jshint` fails to parse JSX so in order for linting to work in the open
// source repo, we need to just use `ReactDOM.form`.
- return this.transferPropsTo(form(null, this.props.children));
+ return form(this.props);
},
componentDidMount: function() {
@@ -8068,21 +8073,14 @@ var ReactDOMForm = ReactCompositeComponent.createClass({
module.exports = ReactDOMForm;
-},{"./EventConstants":16,"./LocalEventTrapMixin":26,"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41}],45:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./LocalEventTrapMixin":27,"./ReactBrowserComponentMixin":32,"./ReactCompositeComponent":40,"./ReactDOM":43,"./ReactElement":58}],47:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDOMIDOperations
* @typechecks static-only
@@ -8259,21 +8257,14 @@ var ReactDOMIDOperations = {
module.exports = ReactDOMIDOperations;
-},{"./CSSPropertyOperations":5,"./DOMChildrenOperations":10,"./DOMPropertyOperations":12,"./ReactMount":67,"./ReactPerf":71,"./invariant":134,"./setInnerHTML":152}],46:[function(_dereq_,module,exports){
+},{"./CSSPropertyOperations":6,"./DOMChildrenOperations":11,"./DOMPropertyOperations":13,"./ReactMount":70,"./ReactPerf":75,"./invariant":140,"./setInnerHTML":154}],48:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDOMImg
*/
@@ -8284,10 +8275,11 @@ var EventConstants = _dereq_("./EventConstants");
var LocalEventTrapMixin = _dereq_("./LocalEventTrapMixin");
var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
+var ReactElement = _dereq_("./ReactElement");
var ReactDOM = _dereq_("./ReactDOM");
-// Store a reference to the <img> `ReactDOMComponent`.
-var img = ReactDOM.img;
+// Store a reference to the <img> `ReactDOMComponent`. TODO: use string
+var img = ReactElement.createFactory(ReactDOM.img.type);
/**
* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
@@ -8313,21 +8305,14 @@ var ReactDOMImg = ReactCompositeComponent.createClass({
module.exports = ReactDOMImg;
-},{"./EventConstants":16,"./LocalEventTrapMixin":26,"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41}],47:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./LocalEventTrapMixin":27,"./ReactBrowserComponentMixin":32,"./ReactCompositeComponent":40,"./ReactDOM":43,"./ReactElement":58}],49:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDOMInput
*/
@@ -8339,17 +8324,26 @@ var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
var LinkedValueUtils = _dereq_("./LinkedValueUtils");
var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
+var ReactElement = _dereq_("./ReactElement");
var ReactDOM = _dereq_("./ReactDOM");
var ReactMount = _dereq_("./ReactMount");
+var ReactUpdates = _dereq_("./ReactUpdates");
+var assign = _dereq_("./Object.assign");
var invariant = _dereq_("./invariant");
-var merge = _dereq_("./merge");
-// Store a reference to the <input> `ReactDOMComponent`.
-var input = ReactDOM.input;
+// Store a reference to the <input> `ReactDOMComponent`. TODO: use string
+var input = ReactElement.createFactory(ReactDOM.input.type);
var instancesByReactID = {};
+function forceUpdateIfMounted() {
+ /*jshint validthis:true */
+ if (this.isMounted()) {
+ this.forceUpdate();
+ }
+}
+
/**
* Implements an <input> native component that allows setting these optional
* props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
@@ -8374,28 +8368,23 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
getInitialState: function() {
var defaultValue = this.props.defaultValue;
return {
- checked: this.props.defaultChecked || false,
- value: defaultValue != null ? defaultValue : null
+ initialChecked: this.props.defaultChecked || false,
+ initialValue: defaultValue != null ? defaultValue : null
};
},
- shouldComponentUpdate: function() {
- // Defer any updates to this component during the `onChange` handler.
- return !this._isChanging;
- },
-
render: function() {
// Clone `this.props` so we don't mutate the input.
- var props = merge(this.props);
+ var props = assign({}, this.props);
props.defaultChecked = null;
props.defaultValue = null;
var value = LinkedValueUtils.getValue(this);
- props.value = value != null ? value : this.state.value;
+ props.value = value != null ? value : this.state.initialValue;
var checked = LinkedValueUtils.getChecked(this);
- props.checked = checked != null ? checked : this.state.checked;
+ props.checked = checked != null ? checked : this.state.initialChecked;
props.onChange = this._handleChange;
@@ -8435,14 +8424,12 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
var returnValue;
var onChange = LinkedValueUtils.getOnChange(this);
if (onChange) {
- this._isChanging = true;
returnValue = onChange.call(this, event);
- this._isChanging = false;
}
- this.setState({
- checked: event.target.checked,
- value: event.target.value
- });
+ // Here we use asap to wait until all updates have propagated, which
+ // is important when using controlled components within layers:
+ // https://github.com/facebook/react/issues/1698
+ ReactUpdates.asap(forceUpdateIfMounted, this);
var name = this.props.name;
if (this.props.type === 'radio' && name != null) {
@@ -8480,13 +8467,10 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
'ReactDOMInput: Unknown radio button ID %s.',
otherID
) : invariant(otherInstance));
- // In some cases, this will actually change the `checked` state value.
- // In other cases, there's no change but this forces a reconcile upon
- // which componentDidUpdate will reset the DOM property to whatever it
- // should be.
- otherInstance.setState({
- checked: false
- });
+ // If this is a controlled radio button group, forcing the input that
+ // was previously checked to update will cause it to be come re-checked
+ // as appropriate.
+ ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
}
}
@@ -8497,21 +8481,14 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
module.exports = ReactDOMInput;
-},{"./AutoFocusMixin":1,"./DOMPropertyOperations":12,"./LinkedValueUtils":25,"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41,"./ReactMount":67,"./invariant":134,"./merge":144}],48:[function(_dereq_,module,exports){
+},{"./AutoFocusMixin":2,"./DOMPropertyOperations":13,"./LinkedValueUtils":26,"./Object.assign":29,"./ReactBrowserComponentMixin":32,"./ReactCompositeComponent":40,"./ReactDOM":43,"./ReactElement":58,"./ReactMount":70,"./ReactUpdates":91,"./invariant":140}],50:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDOMOption
*/
@@ -8520,12 +8497,13 @@ module.exports = ReactDOMInput;
var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
+var ReactElement = _dereq_("./ReactElement");
var ReactDOM = _dereq_("./ReactDOM");
var warning = _dereq_("./warning");
-// Store a reference to the <option> `ReactDOMComponent`.
-var option = ReactDOM.option;
+// Store a reference to the <option> `ReactDOMComponent`. TODO: use string
+var option = ReactElement.createFactory(ReactDOM.option.type);
/**
* Implements an <option> native component that warns when `selected` is set.
@@ -8554,21 +8532,14 @@ var ReactDOMOption = ReactCompositeComponent.createClass({
module.exports = ReactDOMOption;
-},{"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41,"./warning":158}],49:[function(_dereq_,module,exports){
+},{"./ReactBrowserComponentMixin":32,"./ReactCompositeComponent":40,"./ReactDOM":43,"./ReactElement":58,"./warning":160}],51:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDOMSelect
*/
@@ -8579,12 +8550,22 @@ var AutoFocusMixin = _dereq_("./AutoFocusMixin");
var LinkedValueUtils = _dereq_("./LinkedValueUtils");
var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
+var ReactElement = _dereq_("./ReactElement");
var ReactDOM = _dereq_("./ReactDOM");
+var ReactUpdates = _dereq_("./ReactUpdates");
-var merge = _dereq_("./merge");
+var assign = _dereq_("./Object.assign");
-// Store a reference to the <select> `ReactDOMComponent`.
-var select = ReactDOM.select;
+// Store a reference to the <select> `ReactDOMComponent`. TODO: use string
+var select = ReactElement.createFactory(ReactDOM.select.type);
+
+function updateWithPendingValueIfMounted() {
+ /*jshint validthis:true */
+ if (this.isMounted()) {
+ this.setState({value: this._pendingValue});
+ this._pendingValue = 0;
+ }
+}
/**
* Validation function for `value` and `defaultValue`.
@@ -8671,6 +8652,10 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
return {value: this.props.defaultValue || (this.props.multiple ? [] : '')};
},
+ componentWillMount: function() {
+ this._pendingValue = null;
+ },
+
componentWillReceiveProps: function(nextProps) {
if (!this.props.multiple && nextProps.multiple) {
this.setState({value: [this.state.value]});
@@ -8679,14 +8664,9 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
}
},
- shouldComponentUpdate: function() {
- // Defer any updates to this component during the `onChange` handler.
- return !this._isChanging;
- },
-
render: function() {
// Clone `this.props` so we don't mutate the input.
- var props = merge(this.props);
+ var props = assign({}, this.props);
props.onChange = this._handleChange;
props.value = null;
@@ -8711,9 +8691,7 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
var returnValue;
var onChange = LinkedValueUtils.getOnChange(this);
if (onChange) {
- this._isChanging = true;
returnValue = onChange.call(this, event);
- this._isChanging = false;
}
var selectedValue;
@@ -8729,7 +8707,8 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
selectedValue = event.target.value;
}
- this.setState({value: selectedValue});
+ this._pendingValue = selectedValue;
+ ReactUpdates.asap(updateWithPendingValueIfMounted, this);
return returnValue;
}
@@ -8737,21 +8716,14 @@ var ReactDOMSelect = ReactCompositeComponent.createClass({
module.exports = ReactDOMSelect;
-},{"./AutoFocusMixin":1,"./LinkedValueUtils":25,"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41,"./merge":144}],50:[function(_dereq_,module,exports){
+},{"./AutoFocusMixin":2,"./LinkedValueUtils":26,"./Object.assign":29,"./ReactBrowserComponentMixin":32,"./ReactCompositeComponent":40,"./ReactDOM":43,"./ReactElement":58,"./ReactUpdates":91}],52:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDOMSelection
*/
@@ -8810,9 +8782,9 @@ function getIEOffsets(node) {
* @return {?object}
*/
function getModernOffsets(node) {
- var selection = window.getSelection();
+ var selection = window.getSelection && window.getSelection();
- if (selection.rangeCount === 0) {
+ if (!selection || selection.rangeCount === 0) {
return null;
}
@@ -8854,7 +8826,6 @@ function getModernOffsets(node) {
detectionRange.setStart(anchorNode, anchorOffset);
detectionRange.setEnd(focusNode, focusOffset);
var isBackward = detectionRange.collapsed;
- detectionRange.detach();
return {
start: isBackward ? end : start,
@@ -8901,8 +8872,11 @@ function setIEOffsets(node, offsets) {
* @param {object} offsets
*/
function setModernOffsets(node, offsets) {
- var selection = window.getSelection();
+ if (!window.getSelection) {
+ return;
+ }
+ var selection = window.getSelection();
var length = node[getTextContentAccessor()].length;
var start = Math.min(offsets.start, length);
var end = typeof offsets.end === 'undefined' ?
@@ -8931,8 +8905,6 @@ function setModernOffsets(node, offsets) {
range.setEnd(endMarker.node, endMarker.offset);
selection.addRange(range);
}
-
- range.detach();
}
}
@@ -8953,21 +8925,14 @@ var ReactDOMSelection = {
module.exports = ReactDOMSelection;
-},{"./ExecutionEnvironment":22,"./getNodeForCharacterOffset":127,"./getTextContentAccessor":129}],51:[function(_dereq_,module,exports){
+},{"./ExecutionEnvironment":23,"./getNodeForCharacterOffset":133,"./getTextContentAccessor":135}],53:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDOMTextarea
*/
@@ -8979,15 +8944,24 @@ var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
var LinkedValueUtils = _dereq_("./LinkedValueUtils");
var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
+var ReactElement = _dereq_("./ReactElement");
var ReactDOM = _dereq_("./ReactDOM");
+var ReactUpdates = _dereq_("./ReactUpdates");
+var assign = _dereq_("./Object.assign");
var invariant = _dereq_("./invariant");
-var merge = _dereq_("./merge");
var warning = _dereq_("./warning");
-// Store a reference to the <textarea> `ReactDOMComponent`.
-var textarea = ReactDOM.textarea;
+// Store a reference to the <textarea> `ReactDOMComponent`. TODO: use string
+var textarea = ReactElement.createFactory(ReactDOM.textarea.type);
+
+function forceUpdateIfMounted() {
+ /*jshint validthis:true */
+ if (this.isMounted()) {
+ this.forceUpdate();
+ }
+}
/**
* Implements a <textarea> native component that allows setting `value`, and
@@ -9048,14 +9022,9 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
};
},
- shouldComponentUpdate: function() {
- // Defer any updates to this component during the `onChange` handler.
- return !this._isChanging;
- },
-
render: function() {
// Clone `this.props` so we don't mutate the input.
- var props = merge(this.props);
+ var props = assign({}, this.props);
("production" !== "development" ? invariant(
props.dangerouslySetInnerHTML == null,
@@ -9085,11 +9054,9 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
var returnValue;
var onChange = LinkedValueUtils.getOnChange(this);
if (onChange) {
- this._isChanging = true;
returnValue = onChange.call(this, event);
- this._isChanging = false;
}
- this.setState({value: event.target.value});
+ ReactUpdates.asap(forceUpdateIfMounted, this);
return returnValue;
}
@@ -9097,21 +9064,14 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
module.exports = ReactDOMTextarea;
-},{"./AutoFocusMixin":1,"./DOMPropertyOperations":12,"./LinkedValueUtils":25,"./ReactBrowserComponentMixin":30,"./ReactCompositeComponent":38,"./ReactDOM":41,"./invariant":134,"./merge":144,"./warning":158}],52:[function(_dereq_,module,exports){
+},{"./AutoFocusMixin":2,"./DOMPropertyOperations":13,"./LinkedValueUtils":26,"./Object.assign":29,"./ReactBrowserComponentMixin":32,"./ReactCompositeComponent":40,"./ReactDOM":43,"./ReactElement":58,"./ReactUpdates":91,"./invariant":140,"./warning":160}],54:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDefaultBatchingStrategy
*/
@@ -9121,8 +9081,8 @@ module.exports = ReactDOMTextarea;
var ReactUpdates = _dereq_("./ReactUpdates");
var Transaction = _dereq_("./Transaction");
+var assign = _dereq_("./Object.assign");
var emptyFunction = _dereq_("./emptyFunction");
-var mixInto = _dereq_("./mixInto");
var RESET_BATCHED_UPDATES = {
initialize: emptyFunction,
@@ -9142,12 +9102,15 @@ function ReactDefaultBatchingStrategyTransaction() {
this.reinitializeTransaction();
}
-mixInto(ReactDefaultBatchingStrategyTransaction, Transaction.Mixin);
-mixInto(ReactDefaultBatchingStrategyTransaction, {
- getTransactionWrappers: function() {
- return TRANSACTION_WRAPPERS;
+assign(
+ ReactDefaultBatchingStrategyTransaction.prototype,
+ Transaction.Mixin,
+ {
+ getTransactionWrappers: function() {
+ return TRANSACTION_WRAPPERS;
+ }
}
-});
+);
var transaction = new ReactDefaultBatchingStrategyTransaction();
@@ -9174,21 +9137,14 @@ var ReactDefaultBatchingStrategy = {
module.exports = ReactDefaultBatchingStrategy;
-},{"./ReactUpdates":87,"./Transaction":104,"./emptyFunction":116,"./mixInto":147}],53:[function(_dereq_,module,exports){
+},{"./Object.assign":29,"./ReactUpdates":91,"./Transaction":107,"./emptyFunction":121}],55:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDefaultInjection
*/
@@ -9208,7 +9164,7 @@ var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
var ReactComponentBrowserEnvironment =
_dereq_("./ReactComponentBrowserEnvironment");
var ReactDefaultBatchingStrategy = _dereq_("./ReactDefaultBatchingStrategy");
-var ReactDOM = _dereq_("./ReactDOM");
+var ReactDOMComponent = _dereq_("./ReactDOMComponent");
var ReactDOMButton = _dereq_("./ReactDOMButton");
var ReactDOMForm = _dereq_("./ReactDOMForm");
var ReactDOMImg = _dereq_("./ReactDOMImg");
@@ -9253,18 +9209,22 @@ function inject() {
BeforeInputEventPlugin: BeforeInputEventPlugin
});
- ReactInjection.DOM.injectComponentClasses({
- button: ReactDOMButton,
- form: ReactDOMForm,
- img: ReactDOMImg,
- input: ReactDOMInput,
- option: ReactDOMOption,
- select: ReactDOMSelect,
- textarea: ReactDOMTextarea,
-
- html: createFullPageComponent(ReactDOM.html),
- head: createFullPageComponent(ReactDOM.head),
- body: createFullPageComponent(ReactDOM.body)
+ ReactInjection.NativeComponent.injectGenericComponentClass(
+ ReactDOMComponent
+ );
+
+ ReactInjection.NativeComponent.injectComponentClasses({
+ 'button': ReactDOMButton,
+ 'form': ReactDOMForm,
+ 'img': ReactDOMImg,
+ 'input': ReactDOMInput,
+ 'option': ReactDOMOption,
+ 'select': ReactDOMSelect,
+ 'textarea': ReactDOMTextarea,
+
+ 'html': createFullPageComponent('html'),
+ 'head': createFullPageComponent('head'),
+ 'body': createFullPageComponent('body')
});
// This needs to happen after createFullPageComponent() otherwise the mixin
@@ -9274,7 +9234,7 @@ function inject() {
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
- ReactInjection.EmptyComponent.injectEmptyComponent(ReactDOM.noscript);
+ ReactInjection.EmptyComponent.injectEmptyComponent('noscript');
ReactInjection.Updates.injectReconcileTransaction(
ReactComponentBrowserEnvironment.ReactReconcileTransaction
@@ -9304,21 +9264,14 @@ module.exports = {
inject: inject
};
-},{"./BeforeInputEventPlugin":2,"./ChangeEventPlugin":7,"./ClientReactRootIndex":8,"./CompositionEventPlugin":9,"./DefaultEventPluginOrder":14,"./EnterLeaveEventPlugin":15,"./ExecutionEnvironment":22,"./HTMLDOMPropertyConfig":23,"./MobileSafariClickEventPlugin":27,"./ReactBrowserComponentMixin":30,"./ReactComponentBrowserEnvironment":36,"./ReactDOM":41,"./ReactDOMButton":42,"./ReactDOMForm":44,"./ReactDOMImg":46,"./ReactDOMInput":47,"./ReactDOMOption":48,"./ReactDOMSelect":49,"./ReactDOMTextarea":51,"./ReactDefaultBatchingStrategy":52,"./ReactDefaultPerf":54,"./ReactEventListener":61,"./ReactInjection":62,"./ReactInstanceHandles":64,"./ReactMount":67,"./SVGDOMPropertyConfig":89,"./SelectEventPlugin":90,"./ServerReactRootIndex":91,"./SimpleEventPlugin":92,"./createFullPageComponent":112}],54:[function(_dereq_,module,exports){
+},{"./BeforeInputEventPlugin":3,"./ChangeEventPlugin":8,"./ClientReactRootIndex":9,"./CompositionEventPlugin":10,"./DefaultEventPluginOrder":15,"./EnterLeaveEventPlugin":16,"./ExecutionEnvironment":23,"./HTMLDOMPropertyConfig":24,"./MobileSafariClickEventPlugin":28,"./ReactBrowserComponentMixin":32,"./ReactComponentBrowserEnvironment":38,"./ReactDOMButton":44,"./ReactDOMComponent":45,"./ReactDOMForm":46,"./ReactDOMImg":48,"./ReactDOMInput":49,"./ReactDOMOption":50,"./ReactDOMSelect":51,"./ReactDOMTextarea":53,"./ReactDefaultBatchingStrategy":54,"./ReactDefaultPerf":56,"./ReactEventListener":63,"./ReactInjection":64,"./ReactInstanceHandles":66,"./ReactMount":70,"./SVGDOMPropertyConfig":92,"./SelectEventPlugin":93,"./ServerReactRootIndex":94,"./SimpleEventPlugin":95,"./createFullPageComponent":116}],56:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDefaultPerf
* @typechecks static-only
@@ -9397,19 +9350,23 @@ var ReactDefaultPerf = {
);
},
- printWasted: function(measurements) {
- measurements = measurements || ReactDefaultPerf._allMeasurements;
+ getMeasurementsSummaryMap: function(measurements) {
var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(
measurements,
true
);
- console.table(summary.map(function(item) {
+ return summary.map(function(item) {
return {
'Owner > component': item.componentName,
'Wasted time (ms)': item.time,
'Instances': item.count
};
- }));
+ });
+ },
+
+ printWasted: function(measurements) {
+ measurements = measurements || ReactDefaultPerf._allMeasurements;
+ console.table(ReactDefaultPerf.getMeasurementsSummaryMap(measurements));
console.log(
'Total time:',
ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms'
@@ -9447,7 +9404,7 @@ var ReactDefaultPerf = {
},
measure: function(moduleName, fnName, func) {
- return function() {var args=Array.prototype.slice.call(arguments,0);
+ return function() {for (var args=[],$__0=0,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
var totalTime;
var rv;
var start;
@@ -9567,26 +9524,19 @@ var ReactDefaultPerf = {
module.exports = ReactDefaultPerf;
-},{"./DOMProperty":11,"./ReactDefaultPerfAnalysis":55,"./ReactMount":67,"./ReactPerf":71,"./performanceNow":151}],55:[function(_dereq_,module,exports){
+},{"./DOMProperty":12,"./ReactDefaultPerfAnalysis":57,"./ReactMount":70,"./ReactPerf":75,"./performanceNow":153}],57:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDefaultPerfAnalysis
*/
-var merge = _dereq_("./merge");
+var assign = _dereq_("./Object.assign");
// Don't try to save users less than 1.2ms (a number I made up)
var DONT_CARE_THRESHOLD = 1.2;
@@ -9641,7 +9591,11 @@ function getExclusiveSummary(measurements) {
for (var i = 0; i < measurements.length; i++) {
var measurement = measurements[i];
- var allIDs = merge(measurement.exclusive, measurement.inclusive);
+ var allIDs = assign(
+ {},
+ measurement.exclusive,
+ measurement.inclusive
+ );
for (var id in allIDs) {
displayName = measurement.displayNames[id].current;
@@ -9689,7 +9643,11 @@ function getInclusiveSummary(measurements, onlyClean) {
for (var i = 0; i < measurements.length; i++) {
var measurement = measurements[i];
- var allIDs = merge(measurement.exclusive, measurement.inclusive);
+ var allIDs = assign(
+ {},
+ measurement.exclusive,
+ measurement.inclusive
+ );
var cleanComponents;
if (onlyClean) {
@@ -9744,11 +9702,11 @@ function getUnchangedComponents(measurement) {
// the amount of time it took to render the entire subtree.
var cleanComponents = {};
var dirtyLeafIDs = Object.keys(measurement.writes);
- var allIDs = merge(measurement.exclusive, measurement.inclusive);
+ var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
for (var id in allIDs) {
var isDirty = false;
- // For each component that rendered, see if a component that triggerd
+ // For each component that rendered, see if a component that triggered
// a DOM op is in its subtree.
for (var i = 0; i < dirtyLeafIDs.length; i++) {
if (dirtyLeafIDs[i].indexOf(id) === 0) {
@@ -9772,23 +9730,16 @@ var ReactDefaultPerfAnalysis = {
module.exports = ReactDefaultPerfAnalysis;
-},{"./merge":144}],56:[function(_dereq_,module,exports){
+},{"./Object.assign":29}],58:[function(_dereq_,module,exports){
/**
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDescriptor
+ * @providesModule ReactElement
*/
"use strict";
@@ -9796,9 +9747,13 @@ module.exports = ReactDefaultPerfAnalysis;
var ReactContext = _dereq_("./ReactContext");
var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
-var merge = _dereq_("./merge");
var warning = _dereq_("./warning");
+var RESERVED_PROPS = {
+ key: true,
+ ref: true
+};
+
/**
* Warn for mutations.
*
@@ -9840,7 +9795,7 @@ var useMutationMembrane = false;
* Warn for mutations.
*
* @internal
- * @param {object} descriptor
+ * @param {object} element
*/
function defineMutationMembrane(prototype) {
try {
@@ -9857,161 +9812,145 @@ function defineMutationMembrane(prototype) {
}
/**
- * Transfer static properties from the source to the target. Functions are
- * rebound to have this reflect the original source.
- */
-function proxyStaticMethods(target, source) {
- if (typeof source !== 'function') {
- return;
- }
- for (var key in source) {
- if (source.hasOwnProperty(key)) {
- var value = source[key];
- if (typeof value === 'function') {
- var bound = value.bind(source);
- // Copy any properties defined on the function, such as `isRequired` on
- // a PropTypes validator. (mergeInto refuses to work on functions.)
- for (var k in value) {
- if (value.hasOwnProperty(k)) {
- bound[k] = value[k];
- }
- }
- target[key] = bound;
- } else {
- target[key] = value;
- }
- }
- }
-}
-
-/**
- * Base constructor for all React descriptors. This is only used to make this
+ * Base constructor for all React elements. This is only used to make this
* work with a dynamic instanceof check. Nothing should live on this prototype.
*
* @param {*} type
+ * @param {string|object} ref
+ * @param {*} key
+ * @param {*} props
* @internal
*/
-var ReactDescriptor = function() {};
+var ReactElement = function(type, key, ref, owner, context, props) {
+ // Built-in properties that belong on the element
+ this.type = type;
+ this.key = key;
+ this.ref = ref;
-if ("production" !== "development") {
- defineMutationMembrane(ReactDescriptor.prototype);
-}
-
-ReactDescriptor.createFactory = function(type) {
-
- var descriptorPrototype = Object.create(ReactDescriptor.prototype);
-
- var factory = function(props, children) {
- // For consistency we currently allocate a new object for every descriptor.
- // This protects the descriptor from being mutated by the original props
- // object being mutated. It also protects the original props object from
- // being mutated by children arguments and default props. This behavior
- // comes with a performance cost and could be deprecated in the future.
- // It could also be optimized with a smarter JSX transform.
- if (props == null) {
- props = {};
- } else if (typeof props === 'object') {
- props = merge(props);
- }
-
- // Children can be more than one argument, and those are transferred onto
- // the newly allocated props object.
- var childrenLength = arguments.length - 1;
- if (childrenLength === 1) {
- props.children = children;
- } else if (childrenLength > 1) {
- var childArray = Array(childrenLength);
- for (var i = 0; i < childrenLength; i++) {
- childArray[i] = arguments[i + 1];
- }
- props.children = childArray;
+ // Record the component responsible for creating this element.
+ this._owner = owner;
+
+ // TODO: Deprecate withContext, and then the context becomes accessible
+ // through the owner.
+ this._context = context;
+
+ if ("production" !== "development") {
+ // The validation flag and props are currently mutative. We put them on
+ // an external backing store so that we can freeze the whole object.
+ // This can be replaced with a WeakMap once they are implemented in
+ // commonly used development environments.
+ this._store = { validated: false, props: props };
+
+ // We're not allowed to set props directly on the object so we early
+ // return and rely on the prototype membrane to forward to the backing
+ // store.
+ if (useMutationMembrane) {
+ Object.freeze(this);
+ return;
}
+ }
+
+ this.props = props;
+};
+
+// We intentionally don't expose the function on the constructor property.
+// ReactElement should be indistinguishable from a plain object.
+ReactElement.prototype = {
+ _isReactElement: true
+};
- // Initialize the descriptor object
- var descriptor = Object.create(descriptorPrototype);
+if ("production" !== "development") {
+ defineMutationMembrane(ReactElement.prototype);
+}
+
+ReactElement.createElement = function(type, config, children) {
+ var propName;
- // Record the component responsible for creating this descriptor.
- descriptor._owner = ReactCurrentOwner.current;
+ // Reserved names are extracted
+ var props = {};
- // TODO: Deprecate withContext, and then the context becomes accessible
- // through the owner.
- descriptor._context = ReactContext.current;
+ var key = null;
+ var ref = null;
+ if (config != null) {
+ ref = config.ref === undefined ? null : config.ref;
if ("production" !== "development") {
- // The validation flag and props are currently mutative. We put them on
- // an external backing store so that we can freeze the whole object.
- // This can be replaced with a WeakMap once they are implemented in
- // commonly used development environments.
- descriptor._store = { validated: false, props: props };
-
- // We're not allowed to set props directly on the object so we early
- // return and rely on the prototype membrane to forward to the backing
- // store.
- if (useMutationMembrane) {
- Object.freeze(descriptor);
- return descriptor;
+ ("production" !== "development" ? warning(
+ config.key !== null,
+ 'createElement(...): Encountered component with a `key` of null. In ' +
+ 'a future version, this will be treated as equivalent to the string ' +
+ '\'null\'; instead, provide an explicit key or use undefined.'
+ ) : null);
+ }
+ // TODO: Change this back to `config.key === undefined`
+ key = config.key == null ? null : '' + config.key;
+ // Remaining properties are added to a new props object
+ for (propName in config) {
+ if (config.hasOwnProperty(propName) &&
+ !RESERVED_PROPS.hasOwnProperty(propName)) {
+ props[propName] = config[propName];
}
}
+ }
- descriptor.props = props;
- return descriptor;
- };
+ // Children can be more than one argument, and those are transferred onto
+ // the newly allocated props object.
+ var childrenLength = arguments.length - 2;
+ if (childrenLength === 1) {
+ props.children = children;
+ } else if (childrenLength > 1) {
+ var childArray = Array(childrenLength);
+ for (var i = 0; i < childrenLength; i++) {
+ childArray[i] = arguments[i + 2];
+ }
+ props.children = childArray;
+ }
+
+ // Resolve default props
+ if (type.defaultProps) {
+ var defaultProps = type.defaultProps;
+ for (propName in defaultProps) {
+ if (typeof props[propName] === 'undefined') {
+ props[propName] = defaultProps[propName];
+ }
+ }
+ }
- // Currently we expose the prototype of the descriptor so that
- // <Foo /> instanceof Foo works. This is controversial pattern.
- factory.prototype = descriptorPrototype;
+ return new ReactElement(
+ type,
+ key,
+ ref,
+ ReactCurrentOwner.current,
+ ReactContext.current,
+ props
+ );
+};
+ReactElement.createFactory = function(type) {
+ var factory = ReactElement.createElement.bind(null, type);
// Expose the type on the factory and the prototype so that it can be
- // easily accessed on descriptors. E.g. <Foo />.type === Foo.type and for
- // static methods like <Foo />.type.staticMethod();
- // This should not be named constructor since this may not be the function
- // that created the descriptor, and it may not even be a constructor.
+ // easily accessed on elements. E.g. <Foo />.type === Foo.type.
+ // This should not be named `constructor` since this may not be the function
+ // that created the element, and it may not even be a constructor.
factory.type = type;
- descriptorPrototype.type = type;
-
- proxyStaticMethods(factory, type);
-
- // Expose a unique constructor on the prototype is that this works with type
- // systems that compare constructor properties: <Foo />.constructor === Foo
- // This may be controversial since it requires a known factory function.
- descriptorPrototype.constructor = factory;
-
return factory;
-
};
-ReactDescriptor.cloneAndReplaceProps = function(oldDescriptor, newProps) {
- var newDescriptor = Object.create(oldDescriptor.constructor.prototype);
- // It's important that this property order matches the hidden class of the
- // original descriptor to maintain perf.
- newDescriptor._owner = oldDescriptor._owner;
- newDescriptor._context = oldDescriptor._context;
+ReactElement.cloneAndReplaceProps = function(oldElement, newProps) {
+ var newElement = new ReactElement(
+ oldElement.type,
+ oldElement.key,
+ oldElement.ref,
+ oldElement._owner,
+ oldElement._context,
+ newProps
+ );
if ("production" !== "development") {
- newDescriptor._store = {
- validated: oldDescriptor._store.validated,
- props: newProps
- };
- if (useMutationMembrane) {
- Object.freeze(newDescriptor);
- return newDescriptor;
- }
+ // If the key on the original is valid, then the clone is valid
+ newElement._store.validated = oldElement._store.validated;
}
-
- newDescriptor.props = newProps;
- return newDescriptor;
-};
-
-/**
- * Checks if a value is a valid descriptor constructor.
- *
- * @param {*}
- * @return {boolean}
- * @public
- */
-ReactDescriptor.isValidFactory = function(factory) {
- return typeof factory === 'function' &&
- factory.prototype instanceof ReactDescriptor;
+ return newElement;
};
/**
@@ -10019,41 +9958,44 @@ ReactDescriptor.isValidFactory = function(factory) {
* @return {boolean} True if `object` is a valid component.
* @final
*/
-ReactDescriptor.isValidDescriptor = function(object) {
- return object instanceof ReactDescriptor;
+ReactElement.isValidElement = function(object) {
+ // ReactTestUtils is often used outside of beforeEach where as React is
+ // within it. This leads to two different instances of React on the same
+ // page. To identify a element from a different React instance we use
+ // a flag instead of an instanceof check.
+ var isElement = !!(object && object._isReactElement);
+ // if (isElement && !(object instanceof ReactElement)) {
+ // This is an indicator that you're using multiple versions of React at the
+ // same time. This will screw with ownership and stuff. Fix it, please.
+ // TODO: We could possibly warn here.
+ // }
+ return isElement;
};
-module.exports = ReactDescriptor;
+module.exports = ReactElement;
-},{"./ReactContext":39,"./ReactCurrentOwner":40,"./merge":144,"./warning":158}],57:[function(_dereq_,module,exports){
+},{"./ReactContext":41,"./ReactCurrentOwner":42,"./warning":160}],59:[function(_dereq_,module,exports){
/**
- * Copyright 2014 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
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactDescriptorValidator
+ * @providesModule ReactElementValidator
*/
/**
- * ReactDescriptorValidator provides a wrapper around a descriptor factory
- * which validates the props passed to the descriptor. This is intended to be
+ * ReactElementValidator provides a wrapper around a element factory
+ * which validates the props passed to the element. This is intended to be
* used only in DEV and could be replaced by a static type checker for languages
* that support it.
*/
"use strict";
-var ReactDescriptor = _dereq_("./ReactDescriptor");
+var ReactElement = _dereq_("./ReactElement");
var ReactPropTypeLocations = _dereq_("./ReactPropTypeLocations");
var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
@@ -10096,7 +10038,7 @@ function getCurrentOwnerDisplayName() {
* @param {*} parentType component's parent's type.
*/
function validateExplicitKey(component, parentType) {
- if (component._store.validated || component.props.key != null) {
+ if (component._store.validated || component.key != null) {
return;
}
component._store.validated = true;
@@ -10202,11 +10144,11 @@ function validateChildKeys(component, parentType) {
if (Array.isArray(component)) {
for (var i = 0; i < component.length; i++) {
var child = component[i];
- if (ReactDescriptor.isValidDescriptor(child)) {
+ if (ReactElement.isValidElement(child)) {
validateExplicitKey(child, parentType);
}
}
- } else if (ReactDescriptor.isValidDescriptor(component)) {
+ } else if (ReactElement.isValidElement(component)) {
// This component was passed in a valid location.
component._store.validated = true;
} else if (component && typeof component === 'object') {
@@ -10252,85 +10194,70 @@ function checkPropTypes(componentName, propTypes, props, location) {
}
}
-var ReactDescriptorValidator = {
+var ReactElementValidator = {
- /**
- * Wraps a descriptor factory function in another function which validates
- * the props and context of the descriptor and warns about any failed type
- * checks.
- *
- * @param {function} factory The original descriptor factory
- * @param {object?} propTypes A prop type definition set
- * @param {object?} contextTypes A context type definition set
- * @return {object} The component descriptor, which may be invalid.
- * @private
- */
- createFactory: function(factory, propTypes, contextTypes) {
- var validatedFactory = function(props, children) {
- var descriptor = factory.apply(this, arguments);
+ createElement: function(type, props, children) {
+ var element = ReactElement.createElement.apply(this, arguments);
- for (var i = 1; i < arguments.length; i++) {
- validateChildKeys(arguments[i], descriptor.type);
- }
-
- var name = descriptor.type.displayName;
- if (propTypes) {
- checkPropTypes(
- name,
- propTypes,
- descriptor.props,
- ReactPropTypeLocations.prop
- );
- }
- if (contextTypes) {
- checkPropTypes(
- name,
- contextTypes,
- descriptor._context,
- ReactPropTypeLocations.context
- );
- }
- return descriptor;
- };
+ // The result can be nullish if a mock or a custom function is used.
+ // TODO: Drop this when these are no longer allowed as the type argument.
+ if (element == null) {
+ return element;
+ }
- validatedFactory.prototype = factory.prototype;
- validatedFactory.type = factory.type;
+ for (var i = 2; i < arguments.length; i++) {
+ validateChildKeys(arguments[i], type);
+ }
- // Copy static properties
- for (var key in factory) {
- if (factory.hasOwnProperty(key)) {
- validatedFactory[key] = factory[key];
- }
+ var name = type.displayName;
+ if (type.propTypes) {
+ checkPropTypes(
+ name,
+ type.propTypes,
+ element.props,
+ ReactPropTypeLocations.prop
+ );
}
+ if (type.contextTypes) {
+ checkPropTypes(
+ name,
+ type.contextTypes,
+ element._context,
+ ReactPropTypeLocations.context
+ );
+ }
+ return element;
+ },
+ createFactory: function(type) {
+ var validatedFactory = ReactElementValidator.createElement.bind(
+ null,
+ type
+ );
+ validatedFactory.type = type;
return validatedFactory;
}
};
-module.exports = ReactDescriptorValidator;
+module.exports = ReactElementValidator;
-},{"./ReactCurrentOwner":40,"./ReactDescriptor":56,"./ReactPropTypeLocations":74,"./monitorCodeUse":148}],58:[function(_dereq_,module,exports){
+},{"./ReactCurrentOwner":42,"./ReactElement":58,"./ReactPropTypeLocations":78,"./monitorCodeUse":150}],60:[function(_dereq_,module,exports){
/**
- * Copyright 2014 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
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactEmptyComponent
*/
"use strict";
+var ReactElement = _dereq_("./ReactElement");
+
var invariant = _dereq_("./invariant");
var component;
@@ -10340,7 +10267,7 @@ var nullComponentIdsRegistry = {};
var ReactEmptyComponentInjection = {
injectEmptyComponent: function(emptyComponent) {
- component = emptyComponent;
+ component = ReactElement.createFactory(emptyComponent);
}
};
@@ -10390,21 +10317,14 @@ var ReactEmptyComponent = {
module.exports = ReactEmptyComponent;
-},{"./invariant":134}],59:[function(_dereq_,module,exports){
+},{"./ReactElement":58,"./invariant":140}],61:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactErrorUtils
* @typechecks
@@ -10429,21 +10349,14 @@ var ReactErrorUtils = {
module.exports = ReactErrorUtils;
-},{}],60:[function(_dereq_,module,exports){
+},{}],62:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactEventEmitterMixin
*/
@@ -10486,21 +10399,14 @@ var ReactEventEmitterMixin = {
module.exports = ReactEventEmitterMixin;
-},{"./EventPluginHub":18}],61:[function(_dereq_,module,exports){
+},{"./EventPluginHub":19}],63:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactEventListener
* @typechecks static-only
@@ -10515,9 +10421,9 @@ var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
var ReactMount = _dereq_("./ReactMount");
var ReactUpdates = _dereq_("./ReactUpdates");
+var assign = _dereq_("./Object.assign");
var getEventTarget = _dereq_("./getEventTarget");
var getUnboundedScrollPosition = _dereq_("./getUnboundedScrollPosition");
-var mixInto = _dereq_("./mixInto");
/**
* Finds the parent React component of `node`.
@@ -10543,7 +10449,7 @@ function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
this.nativeEvent = nativeEvent;
this.ancestors = [];
}
-mixInto(TopLevelCallbackBookKeeping, {
+assign(TopLevelCallbackBookKeeping.prototype, {
destructor: function() {
this.topLevelType = null;
this.nativeEvent = null;
@@ -10677,21 +10583,14 @@ var ReactEventListener = {
module.exports = ReactEventListener;
-},{"./EventListener":17,"./ExecutionEnvironment":22,"./PooledClass":28,"./ReactInstanceHandles":64,"./ReactMount":67,"./ReactUpdates":87,"./getEventTarget":125,"./getUnboundedScrollPosition":130,"./mixInto":147}],62:[function(_dereq_,module,exports){
+},{"./EventListener":18,"./ExecutionEnvironment":23,"./Object.assign":29,"./PooledClass":30,"./ReactInstanceHandles":66,"./ReactMount":70,"./ReactUpdates":91,"./getEventTarget":131,"./getUnboundedScrollPosition":136}],64:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactInjection
*/
@@ -10702,9 +10601,9 @@ var DOMProperty = _dereq_("./DOMProperty");
var EventPluginHub = _dereq_("./EventPluginHub");
var ReactComponent = _dereq_("./ReactComponent");
var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
-var ReactDOM = _dereq_("./ReactDOM");
var ReactEmptyComponent = _dereq_("./ReactEmptyComponent");
var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
+var ReactNativeComponent = _dereq_("./ReactNativeComponent");
var ReactPerf = _dereq_("./ReactPerf");
var ReactRootIndex = _dereq_("./ReactRootIndex");
var ReactUpdates = _dereq_("./ReactUpdates");
@@ -10715,8 +10614,8 @@ var ReactInjection = {
DOMProperty: DOMProperty.injection,
EmptyComponent: ReactEmptyComponent.injection,
EventPluginHub: EventPluginHub.injection,
- DOM: ReactDOM.injection,
EventEmitter: ReactBrowserEventEmitter.injection,
+ NativeComponent: ReactNativeComponent.injection,
Perf: ReactPerf.injection,
RootIndex: ReactRootIndex.injection,
Updates: ReactUpdates.injection
@@ -10724,21 +10623,14 @@ var ReactInjection = {
module.exports = ReactInjection;
-},{"./DOMProperty":11,"./EventPluginHub":18,"./ReactBrowserEventEmitter":31,"./ReactComponent":35,"./ReactCompositeComponent":38,"./ReactDOM":41,"./ReactEmptyComponent":58,"./ReactPerf":71,"./ReactRootIndex":78,"./ReactUpdates":87}],63:[function(_dereq_,module,exports){
+},{"./DOMProperty":12,"./EventPluginHub":19,"./ReactBrowserEventEmitter":33,"./ReactComponent":37,"./ReactCompositeComponent":40,"./ReactEmptyComponent":60,"./ReactNativeComponent":73,"./ReactPerf":75,"./ReactRootIndex":82,"./ReactUpdates":91}],65:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactInputSelection
*/
@@ -10867,21 +10759,14 @@ var ReactInputSelection = {
module.exports = ReactInputSelection;
-},{"./ReactDOMSelection":50,"./containsNode":109,"./focusNode":120,"./getActiveElement":122}],64:[function(_dereq_,module,exports){
+},{"./ReactDOMSelection":52,"./containsNode":114,"./focusNode":125,"./getActiveElement":127}],66:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactInstanceHandles
* @typechecks static-only
@@ -11207,21 +11092,259 @@ var ReactInstanceHandles = {
module.exports = ReactInstanceHandles;
-},{"./ReactRootIndex":78,"./invariant":134}],65:[function(_dereq_,module,exports){
+},{"./ReactRootIndex":82,"./invariant":140}],67:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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
+ * 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.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * @providesModule ReactLegacyElement
+ */
+
+"use strict";
+
+var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
+
+var invariant = _dereq_("./invariant");
+var monitorCodeUse = _dereq_("./monitorCodeUse");
+var warning = _dereq_("./warning");
+
+var legacyFactoryLogs = {};
+function warnForLegacyFactoryCall() {
+ if (!ReactLegacyElementFactory._isLegacyCallWarningEnabled) {
+ return;
+ }
+ var owner = ReactCurrentOwner.current;
+ var name = owner && owner.constructor ? owner.constructor.displayName : '';
+ if (!name) {
+ name = 'Something';
+ }
+ if (legacyFactoryLogs.hasOwnProperty(name)) {
+ return;
+ }
+ legacyFactoryLogs[name] = true;
+ ("production" !== "development" ? warning(
+ false,
+ name + ' is calling a React component directly. ' +
+ 'Use a factory or JSX instead. See: http://fb.me/react-legacyfactory'
+ ) : null);
+ monitorCodeUse('react_legacy_factory_call', { version: 3, name: name });
+}
+
+function warnForPlainFunctionType(type) {
+ var isReactClass =
+ type.prototype &&
+ typeof type.prototype.mountComponent === 'function' &&
+ typeof type.prototype.receiveComponent === 'function';
+ if (isReactClass) {
+ ("production" !== "development" ? warning(
+ false,
+ 'Did not expect to get a React class here. Use `Component` instead ' +
+ 'of `Component.type` or `this.constructor`.'
+ ) : null);
+ } else {
+ if (!type._reactWarnedForThisType) {
+ try {
+ type._reactWarnedForThisType = true;
+ } catch (x) {
+ // just incase this is a frozen object or some special object
+ }
+ monitorCodeUse(
+ 'react_non_component_in_jsx',
+ { version: 3, name: type.name }
+ );
+ }
+ ("production" !== "development" ? warning(
+ false,
+ 'This JSX uses a plain function. Only React components are ' +
+ 'valid in React\'s JSX transform.'
+ ) : null);
+ }
+}
+
+function warnForNonLegacyFactory(type) {
+ ("production" !== "development" ? warning(
+ false,
+ 'Do not pass React.DOM.' + type.type + ' to JSX or createFactory. ' +
+ 'Use the string "' + type.type + '" instead.'
+ ) : null);
+}
+
+/**
+ * Transfer static properties from the source to the target. Functions are
+ * rebound to have this reflect the original source.
+ */
+function proxyStaticMethods(target, source) {
+ if (typeof source !== 'function') {
+ return;
+ }
+ for (var key in source) {
+ if (source.hasOwnProperty(key)) {
+ var value = source[key];
+ if (typeof value === 'function') {
+ var bound = value.bind(source);
+ // Copy any properties defined on the function, such as `isRequired` on
+ // a PropTypes validator.
+ for (var k in value) {
+ if (value.hasOwnProperty(k)) {
+ bound[k] = value[k];
+ }
+ }
+ target[key] = bound;
+ } else {
+ target[key] = value;
+ }
+ }
+ }
+}
+
+// We use an object instead of a boolean because booleans are ignored by our
+// mocking libraries when these factories gets mocked.
+var LEGACY_MARKER = {};
+var NON_LEGACY_MARKER = {};
+
+var ReactLegacyElementFactory = {};
+
+ReactLegacyElementFactory.wrapCreateFactory = function(createFactory) {
+ var legacyCreateFactory = function(type) {
+ if (typeof type !== 'function') {
+ // Non-function types cannot be legacy factories
+ return createFactory(type);
+ }
+
+ if (type.isReactNonLegacyFactory) {
+ // This is probably a factory created by ReactDOM we unwrap it to get to
+ // the underlying string type. It shouldn't have been passed here so we
+ // warn.
+ if ("production" !== "development") {
+ warnForNonLegacyFactory(type);
+ }
+ return createFactory(type.type);
+ }
+
+ if (type.isReactLegacyFactory) {
+ // This is probably a legacy factory created by ReactCompositeComponent.
+ // We unwrap it to get to the underlying class.
+ return createFactory(type.type);
+ }
+
+ if ("production" !== "development") {
+ warnForPlainFunctionType(type);
+ }
+
+ // Unless it's a legacy factory, then this is probably a plain function,
+ // that is expecting to be invoked by JSX. We can just return it as is.
+ return type;
+ };
+ return legacyCreateFactory;
+};
+
+ReactLegacyElementFactory.wrapCreateElement = function(createElement) {
+ var legacyCreateElement = function(type, props, children) {
+ if (typeof type !== 'function') {
+ // Non-function types cannot be legacy factories
+ return createElement.apply(this, arguments);
+ }
+
+ var args;
+
+ if (type.isReactNonLegacyFactory) {
+ // This is probably a factory created by ReactDOM we unwrap it to get to
+ // the underlying string type. It shouldn't have been passed here so we
+ // warn.
+ if ("production" !== "development") {
+ warnForNonLegacyFactory(type);
+ }
+ args = Array.prototype.slice.call(arguments, 0);
+ args[0] = type.type;
+ return createElement.apply(this, args);
+ }
+
+ if (type.isReactLegacyFactory) {
+ // This is probably a legacy factory created by ReactCompositeComponent.
+ // We unwrap it to get to the underlying class.
+ if (type._isMockFunction) {
+ // If this is a mock function, people will expect it to be called. We
+ // will actually call the original mock factory function instead. This
+ // future proofs unit testing that assume that these are classes.
+ type.type._mockedReactClassConstructor = type;
+ }
+ args = Array.prototype.slice.call(arguments, 0);
+ args[0] = type.type;
+ return createElement.apply(this, args);
+ }
+
+ if ("production" !== "development") {
+ warnForPlainFunctionType(type);
+ }
+
+ // This is being called with a plain function we should invoke it
+ // immediately as if this was used with legacy JSX.
+ return type.apply(null, Array.prototype.slice.call(arguments, 1));
+ };
+ return legacyCreateElement;
+};
+
+ReactLegacyElementFactory.wrapFactory = function(factory) {
+ ("production" !== "development" ? invariant(
+ typeof factory === 'function',
+ 'This is suppose to accept a element factory'
+ ) : invariant(typeof factory === 'function'));
+ var legacyElementFactory = function(config, children) {
+ // This factory should not be called when JSX is used. Use JSX instead.
+ if ("production" !== "development") {
+ warnForLegacyFactoryCall();
+ }
+ return factory.apply(this, arguments);
+ };
+ proxyStaticMethods(legacyElementFactory, factory.type);
+ legacyElementFactory.isReactLegacyFactory = LEGACY_MARKER;
+ legacyElementFactory.type = factory.type;
+ return legacyElementFactory;
+};
+
+// This is used to mark a factory that will remain. E.g. we're allowed to call
+// it as a function. However, you're not suppose to pass it to createElement
+// or createFactory, so it will warn you if you do.
+ReactLegacyElementFactory.markNonLegacyFactory = function(factory) {
+ factory.isReactNonLegacyFactory = NON_LEGACY_MARKER;
+ return factory;
+};
+
+// Checks if a factory function is actually a legacy factory pretending to
+// be a class.
+ReactLegacyElementFactory.isValidFactory = function(factory) {
+ // TODO: This will be removed and moved into a class validator or something.
+ return typeof factory === 'function' &&
+ factory.isReactLegacyFactory === LEGACY_MARKER;
+};
+
+ReactLegacyElementFactory.isValidClass = function(factory) {
+ if ("production" !== "development") {
+ ("production" !== "development" ? warning(
+ false,
+ 'isValidClass is deprecated and will be removed in a future release. ' +
+ 'Use a more specific validator instead.'
+ ) : null);
+ }
+ return ReactLegacyElementFactory.isValidFactory(factory);
+};
+
+ReactLegacyElementFactory._isLegacyCallWarningEnabled = true;
+
+module.exports = ReactLegacyElementFactory;
+
+},{"./ReactCurrentOwner":42,"./invariant":140,"./monitorCodeUse":150,"./warning":160}],68:[function(_dereq_,module,exports){
+/**
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactLink
* @typechecks static-only
@@ -11287,21 +11410,14 @@ ReactLink.PropTypes = {
module.exports = ReactLink;
-},{"./React":29}],66:[function(_dereq_,module,exports){
+},{"./React":31}],69:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactMarkupChecksum
*/
@@ -11342,21 +11458,14 @@ var ReactMarkupChecksum = {
module.exports = ReactMarkupChecksum;
-},{"./adler32":107}],67:[function(_dereq_,module,exports){
+},{"./adler32":110}],70:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactMount
*/
@@ -11366,17 +11475,23 @@ module.exports = ReactMarkupChecksum;
var DOMProperty = _dereq_("./DOMProperty");
var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
-var ReactDescriptor = _dereq_("./ReactDescriptor");
+var ReactElement = _dereq_("./ReactElement");
+var ReactLegacyElement = _dereq_("./ReactLegacyElement");
var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
var ReactPerf = _dereq_("./ReactPerf");
var containsNode = _dereq_("./containsNode");
+var deprecated = _dereq_("./deprecated");
var getReactRootElementInContainer = _dereq_("./getReactRootElementInContainer");
var instantiateReactComponent = _dereq_("./instantiateReactComponent");
var invariant = _dereq_("./invariant");
var shouldUpdateReactComponent = _dereq_("./shouldUpdateReactComponent");
var warning = _dereq_("./warning");
+var createElement = ReactLegacyElement.wrapCreateElement(
+ ReactElement.createElement
+);
+
var SEPARATOR = ReactInstanceHandles.SEPARATOR;
var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
@@ -11544,7 +11659,7 @@ function findDeepestCachedAncestor(targetID) {
* representative DOM elements and inserting them into a supplied `container`.
* Any prior content inside `container` is destroyed in the process.
*
- * ReactMount.renderComponent(
+ * ReactMount.render(
* component,
* document.getElementById('container')
* );
@@ -11650,7 +11765,7 @@ var ReactMount = {
'componentDidUpdate.'
) : null);
- var componentInstance = instantiateReactComponent(nextComponent);
+ var componentInstance = instantiateReactComponent(nextComponent, null);
var reactRootID = ReactMount._registerComponent(
componentInstance,
container
@@ -11678,35 +11793,38 @@ var ReactMount = {
* perform an update on it and only mutate the DOM as necessary to reflect the
* latest React component.
*
- * @param {ReactDescriptor} nextDescriptor Component descriptor to render.
+ * @param {ReactElement} nextElement Component element to render.
* @param {DOMElement} container DOM element to render into.
* @param {?function} callback function triggered on completion
* @return {ReactComponent} Component instance rendered in `container`.
*/
- renderComponent: function(nextDescriptor, container, callback) {
+ render: function(nextElement, container, callback) {
("production" !== "development" ? invariant(
- ReactDescriptor.isValidDescriptor(nextDescriptor),
- 'renderComponent(): Invalid component descriptor.%s',
+ ReactElement.isValidElement(nextElement),
+ 'renderComponent(): Invalid component element.%s',
(
- ReactDescriptor.isValidFactory(nextDescriptor) ?
+ typeof nextElement === 'string' ?
+ ' Instead of passing an element string, make sure to instantiate ' +
+ 'it by passing it to React.createElement.' :
+ ReactLegacyElement.isValidFactory(nextElement) ?
' Instead of passing a component class, make sure to instantiate ' +
- 'it first by calling it with props.' :
- // Check if it quacks like a descriptor
- typeof nextDescriptor.props !== "undefined" ?
+ 'it by passing it to React.createElement.' :
+ // Check if it quacks like a element
+ typeof nextElement.props !== "undefined" ?
' This may be caused by unintentionally loading two independent ' +
'copies of React.' :
''
)
- ) : invariant(ReactDescriptor.isValidDescriptor(nextDescriptor)));
+ ) : invariant(ReactElement.isValidElement(nextElement)));
var prevComponent = instancesByReactRootID[getReactRootID(container)];
if (prevComponent) {
- var prevDescriptor = prevComponent._descriptor;
- if (shouldUpdateReactComponent(prevDescriptor, nextDescriptor)) {
+ var prevElement = prevComponent._currentElement;
+ if (shouldUpdateReactComponent(prevElement, nextElement)) {
return ReactMount._updateRootComponent(
prevComponent,
- nextDescriptor,
+ nextElement,
container,
callback
);
@@ -11722,7 +11840,7 @@ var ReactMount = {
var shouldReuseMarkup = containerHasReactMarkup && !prevComponent;
var component = ReactMount._renderNewRootComponent(
- nextDescriptor,
+ nextElement,
container,
shouldReuseMarkup
);
@@ -11740,7 +11858,8 @@ var ReactMount = {
* @return {ReactComponent} Component instance rendered in `container`.
*/
constructAndRenderComponent: function(constructor, props, container) {
- return ReactMount.renderComponent(constructor(props), container);
+ var element = createElement(constructor, props);
+ return ReactMount.render(element, container);
},
/**
@@ -11999,9 +12118,10 @@ var ReactMount = {
false,
'findComponentRoot(..., %s): Unable to find element. This probably ' +
'means the DOM was unexpectedly mutated (e.g., by the browser), ' +
- 'usually due to forgetting a <tbody> when using tables, nesting <p> ' +
- 'or <a> tags, or using non-SVG elements in an <svg> parent. Try ' +
- 'inspecting the child nodes of the element with React ID `%s`.',
+ 'usually due to forgetting a <tbody> when using tables, nesting tags ' +
+ 'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' +
+ 'parent. ' +
+ 'Try inspecting the child nodes of the element with React ID `%s`.',
targetID,
ReactMount.getID(ancestorNode)
) : invariant(false));
@@ -12023,23 +12143,25 @@ var ReactMount = {
purgeID: purgeID
};
+// Deprecations (remove for 0.13)
+ReactMount.renderComponent = deprecated(
+ 'ReactMount',
+ 'renderComponent',
+ 'render',
+ this,
+ ReactMount.render
+);
+
module.exports = ReactMount;
-},{"./DOMProperty":11,"./ReactBrowserEventEmitter":31,"./ReactCurrentOwner":40,"./ReactDescriptor":56,"./ReactInstanceHandles":64,"./ReactPerf":71,"./containsNode":109,"./getReactRootElementInContainer":128,"./instantiateReactComponent":133,"./invariant":134,"./shouldUpdateReactComponent":154,"./warning":158}],68:[function(_dereq_,module,exports){
+},{"./DOMProperty":12,"./ReactBrowserEventEmitter":33,"./ReactCurrentOwner":42,"./ReactElement":58,"./ReactInstanceHandles":66,"./ReactLegacyElement":67,"./ReactPerf":75,"./containsNode":114,"./deprecated":120,"./getReactRootElementInContainer":134,"./instantiateReactComponent":139,"./invariant":140,"./shouldUpdateReactComponent":156,"./warning":160}],71:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactMultiChild
* @typechecks static-only
@@ -12223,7 +12345,7 @@ var ReactMultiChild = {
if (children.hasOwnProperty(name)) {
// The rendered children must be turned into instances as they're
// mounted.
- var childInstance = instantiateReactComponent(child);
+ var childInstance = instantiateReactComponent(child, null);
children[name] = childInstance;
// Inlined for performance, see `ReactInstanceHandles.createReactID`.
var rootID = this._rootNodeID + name;
@@ -12314,12 +12436,12 @@ var ReactMultiChild = {
continue;
}
var prevChild = prevChildren && prevChildren[name];
- var prevDescriptor = prevChild && prevChild._descriptor;
- var nextDescriptor = nextChildren[name];
- if (shouldUpdateReactComponent(prevDescriptor, nextDescriptor)) {
+ var prevElement = prevChild && prevChild._currentElement;
+ var nextElement = nextChildren[name];
+ if (shouldUpdateReactComponent(prevElement, nextElement)) {
this.moveChild(prevChild, nextIndex, lastIndex);
lastIndex = Math.max(prevChild._mountIndex, lastIndex);
- prevChild.receiveComponent(nextDescriptor, transaction);
+ prevChild.receiveComponent(nextElement, transaction);
prevChild._mountIndex = nextIndex;
} else {
if (prevChild) {
@@ -12328,7 +12450,10 @@ var ReactMultiChild = {
this._unmountChildByName(prevChild, name);
}
// The child must be instantiated before it's mounted.
- var nextChildInstance = instantiateReactComponent(nextDescriptor);
+ var nextChildInstance = instantiateReactComponent(
+ nextElement,
+ null
+ );
this._mountChildByNameAtIndex(
nextChildInstance, name, nextIndex, transaction
);
@@ -12457,21 +12582,14 @@ var ReactMultiChild = {
module.exports = ReactMultiChild;
-},{"./ReactComponent":35,"./ReactMultiChildUpdateTypes":69,"./flattenChildren":119,"./instantiateReactComponent":133,"./shouldUpdateReactComponent":154}],69:[function(_dereq_,module,exports){
+},{"./ReactComponent":37,"./ReactMultiChildUpdateTypes":72,"./flattenChildren":124,"./instantiateReactComponent":139,"./shouldUpdateReactComponent":156}],72:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactMultiChildUpdateTypes
*/
@@ -12497,21 +12615,85 @@ var ReactMultiChildUpdateTypes = keyMirror({
module.exports = ReactMultiChildUpdateTypes;
-},{"./keyMirror":140}],70:[function(_dereq_,module,exports){
+},{"./keyMirror":146}],73:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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
+ * 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.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * @providesModule ReactNativeComponent
+ */
+
+"use strict";
+
+var assign = _dereq_("./Object.assign");
+var invariant = _dereq_("./invariant");
+
+var genericComponentClass = null;
+// This registry keeps track of wrapper classes around native tags
+var tagToComponentClass = {};
+
+var ReactNativeComponentInjection = {
+ // This accepts a class that receives the tag string. This is a catch all
+ // that can render any kind of tag.
+ injectGenericComponentClass: function(componentClass) {
+ genericComponentClass = componentClass;
+ },
+ // This accepts a keyed object with classes as values. Each key represents a
+ // tag. That particular tag will use this class instead of the generic one.
+ injectComponentClasses: function(componentClasses) {
+ assign(tagToComponentClass, componentClasses);
+ }
+};
+
+/**
+ * Create an internal class for a specific tag.
*
- * 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.
+ * @param {string} tag The tag for which to create an internal instance.
+ * @param {any} props The props passed to the instance constructor.
+ * @return {ReactComponent} component The injected empty component.
+ */
+function createInstanceForTag(tag, props, parentType) {
+ var componentClass = tagToComponentClass[tag];
+ if (componentClass == null) {
+ ("production" !== "development" ? invariant(
+ genericComponentClass,
+ 'There is no registered component for the tag %s',
+ tag
+ ) : invariant(genericComponentClass));
+ return new genericComponentClass(tag, props);
+ }
+ if (parentType === tag) {
+ // Avoid recursion
+ ("production" !== "development" ? invariant(
+ genericComponentClass,
+ 'There is no registered component for the tag %s',
+ tag
+ ) : invariant(genericComponentClass));
+ return new genericComponentClass(tag, props);
+ }
+ // Unwrap legacy factories
+ return new componentClass.type(props);
+}
+
+var ReactNativeComponent = {
+ createInstanceForTag: createInstanceForTag,
+ injection: ReactNativeComponentInjection
+};
+
+module.exports = ReactNativeComponent;
+
+},{"./Object.assign":29,"./invariant":140}],74:[function(_dereq_,module,exports){
+/**
+ * Copyright 2013-2014, 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 ReactOwner
*/
@@ -12658,21 +12840,14 @@ var ReactOwner = {
module.exports = ReactOwner;
-},{"./emptyObject":117,"./invariant":134}],71:[function(_dereq_,module,exports){
+},{"./emptyObject":122,"./invariant":140}],75:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactPerf
* @typechecks static-only
@@ -12708,7 +12883,7 @@ var ReactPerf = {
measure: function(objName, fnName, func) {
if ("production" !== "development") {
var measuredFunc = null;
- return function() {
+ var wrapper = function() {
if (ReactPerf.enableMeasure) {
if (!measuredFunc) {
measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
@@ -12717,6 +12892,8 @@ var ReactPerf = {
}
return func.apply(this, arguments);
};
+ wrapper.displayName = objName + '_' + fnName;
+ return wrapper;
}
return func;
},
@@ -12745,31 +12922,27 @@ function _noMeasure(objName, fnName, func) {
module.exports = ReactPerf;
-},{}],72:[function(_dereq_,module,exports){
+},{}],76:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactPropTransferer
*/
"use strict";
+var assign = _dereq_("./Object.assign");
var emptyFunction = _dereq_("./emptyFunction");
var invariant = _dereq_("./invariant");
var joinClasses = _dereq_("./joinClasses");
-var merge = _dereq_("./merge");
+var warning = _dereq_("./warning");
+
+var didWarn = false;
/**
* Creates a transfer strategy that will merge prop values using the supplied
@@ -12792,7 +12965,7 @@ var transferStrategyMerge = createTransferStrategy(function(a, b) {
// `merge` overrides the first object's (`props[key]` above) keys using the
// second object's (`value`) keys. An object's style's existing `propA` would
// get overridden. Flip the order here.
- return merge(b, a);
+ return assign({}, b, a);
});
/**
@@ -12810,14 +12983,6 @@ var TransferStrategies = {
*/
className: createTransferStrategy(joinClasses),
/**
- * Never transfer the `key` prop.
- */
- key: emptyFunction,
- /**
- * Never transfer the `ref` prop.
- */
- ref: emptyFunction,
- /**
* Transfer the `style` prop (which is an object) by merging them.
*/
style: transferStrategyMerge
@@ -12866,7 +13031,7 @@ var ReactPropTransferer = {
* @return {object} a new object containing both sets of props merged.
*/
mergeProps: function(oldProps, newProps) {
- return transferInto(merge(oldProps), newProps);
+ return transferInto(assign({}, oldProps), newProps);
},
/**
@@ -12882,26 +13047,39 @@ var ReactPropTransferer = {
*
* This is usually used to pass down props to a returned root component.
*
- * @param {ReactDescriptor} descriptor Component receiving the properties.
- * @return {ReactDescriptor} The supplied `component`.
+ * @param {ReactElement} element Component receiving the properties.
+ * @return {ReactElement} The supplied `component`.
* @final
* @protected
*/
- transferPropsTo: function(descriptor) {
+ transferPropsTo: function(element) {
("production" !== "development" ? invariant(
- descriptor._owner === this,
+ element._owner === this,
'%s: You can\'t call transferPropsTo() on a component that you ' +
'don\'t own, %s. This usually means you are calling ' +
'transferPropsTo() on a component passed in as props or children.',
this.constructor.displayName,
- descriptor.type.displayName
- ) : invariant(descriptor._owner === this));
+ typeof element.type === 'string' ?
+ element.type :
+ element.type.displayName
+ ) : invariant(element._owner === this));
+
+ if ("production" !== "development") {
+ if (!didWarn) {
+ didWarn = true;
+ ("production" !== "development" ? warning(
+ false,
+ 'transferPropsTo is deprecated. ' +
+ 'See http://fb.me/react-transferpropsto for more information.'
+ ) : null);
+ }
+ }
- // Because descriptors are immutable we have to merge into the existing
+ // Because elements are immutable we have to merge into the existing
// props object rather than clone it.
- transferInto(descriptor.props, this.props);
+ transferInto(element.props, this.props);
- return descriptor;
+ return element;
}
}
@@ -12909,21 +13087,14 @@ var ReactPropTransferer = {
module.exports = ReactPropTransferer;
-},{"./emptyFunction":116,"./invariant":134,"./joinClasses":139,"./merge":144}],73:[function(_dereq_,module,exports){
+},{"./Object.assign":29,"./emptyFunction":121,"./invariant":140,"./joinClasses":145,"./warning":160}],77:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactPropTypeLocationNames
*/
@@ -12942,21 +13113,14 @@ if ("production" !== "development") {
module.exports = ReactPropTypeLocationNames;
-},{}],74:[function(_dereq_,module,exports){
+},{}],78:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactPropTypeLocations
*/
@@ -12973,30 +13137,24 @@ var ReactPropTypeLocations = keyMirror({
module.exports = ReactPropTypeLocations;
-},{"./keyMirror":140}],75:[function(_dereq_,module,exports){
+},{"./keyMirror":146}],79:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactPropTypes
*/
"use strict";
-var ReactDescriptor = _dereq_("./ReactDescriptor");
+var ReactElement = _dereq_("./ReactElement");
var ReactPropTypeLocationNames = _dereq_("./ReactPropTypeLocationNames");
+var deprecated = _dereq_("./deprecated");
var emptyFunction = _dereq_("./emptyFunction");
/**
@@ -13048,6 +13206,9 @@ var emptyFunction = _dereq_("./emptyFunction");
var ANONYMOUS = '<<anonymous>>';
+var elementTypeChecker = createElementTypeChecker();
+var nodeTypeChecker = createNodeChecker();
+
var ReactPropTypes = {
array: createPrimitiveTypeChecker('array'),
bool: createPrimitiveTypeChecker('boolean'),
@@ -13058,13 +13219,28 @@ var ReactPropTypes = {
any: createAnyTypeChecker(),
arrayOf: createArrayOfTypeChecker,
- component: createComponentTypeChecker(),
+ element: elementTypeChecker,
instanceOf: createInstanceTypeChecker,
+ node: nodeTypeChecker,
objectOf: createObjectOfTypeChecker,
oneOf: createEnumTypeChecker,
oneOfType: createUnionTypeChecker,
- renderable: createRenderableTypeChecker(),
- shape: createShapeTypeChecker
+ shape: createShapeTypeChecker,
+
+ component: deprecated(
+ 'React.PropTypes',
+ 'component',
+ 'element',
+ this,
+ elementTypeChecker
+ ),
+ renderable: deprecated(
+ 'React.PropTypes',
+ 'renderable',
+ 'node',
+ this,
+ nodeTypeChecker
+ )
};
function createChainableTypeChecker(validate) {
@@ -13134,13 +13310,13 @@ function createArrayOfTypeChecker(typeChecker) {
return createChainableTypeChecker(validate);
}
-function createComponentTypeChecker() {
+function createElementTypeChecker() {
function validate(props, propName, componentName, location) {
- if (!ReactDescriptor.isValidDescriptor(props[propName])) {
+ if (!ReactElement.isValidElement(props[propName])) {
var locationName = ReactPropTypeLocationNames[location];
return new Error(
("Invalid " + locationName + " `" + propName + "` supplied to ") +
- ("`" + componentName + "`, expected a React component.")
+ ("`" + componentName + "`, expected a ReactElement.")
);
}
}
@@ -13221,13 +13397,13 @@ function createUnionTypeChecker(arrayOfTypeCheckers) {
return createChainableTypeChecker(validate);
}
-function createRenderableTypeChecker() {
+function createNodeChecker() {
function validate(props, propName, componentName, location) {
- if (!isRenderable(props[propName])) {
+ if (!isNode(props[propName])) {
var locationName = ReactPropTypeLocationNames[location];
return new Error(
("Invalid " + locationName + " `" + propName + "` supplied to ") +
- ("`" + componentName + "`, expected a renderable prop.")
+ ("`" + componentName + "`, expected a ReactNode.")
);
}
}
@@ -13259,11 +13435,8 @@ function createShapeTypeChecker(shapeTypes) {
return createChainableTypeChecker(validate, 'expected `object`');
}
-function isRenderable(propValue) {
+function isNode(propValue) {
switch(typeof propValue) {
- // TODO: this was probably written with the assumption that we're not
- // returning `this.props.component` directly from `render`. This is
- // currently not supported but we should, to make it consistent.
case 'number':
case 'string':
return true;
@@ -13271,13 +13444,13 @@ function isRenderable(propValue) {
return !propValue;
case 'object':
if (Array.isArray(propValue)) {
- return propValue.every(isRenderable);
+ return propValue.every(isNode);
}
- if (ReactDescriptor.isValidDescriptor(propValue)) {
+ if (ReactElement.isValidElement(propValue)) {
return true;
}
for (var k in propValue) {
- if (!isRenderable(propValue[k])) {
+ if (!isNode(propValue[k])) {
return false;
}
}
@@ -13318,21 +13491,14 @@ function getPreciseType(propValue) {
module.exports = ReactPropTypes;
-},{"./ReactDescriptor":56,"./ReactPropTypeLocationNames":73,"./emptyFunction":116}],76:[function(_dereq_,module,exports){
+},{"./ReactElement":58,"./ReactPropTypeLocationNames":77,"./deprecated":120,"./emptyFunction":121}],80:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactPutListenerQueue
*/
@@ -13342,13 +13508,13 @@ module.exports = ReactPropTypes;
var PooledClass = _dereq_("./PooledClass");
var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
-var mixInto = _dereq_("./mixInto");
+var assign = _dereq_("./Object.assign");
function ReactPutListenerQueue() {
this.listenersToPut = [];
}
-mixInto(ReactPutListenerQueue, {
+assign(ReactPutListenerQueue.prototype, {
enqueuePutListener: function(rootNodeID, propKey, propValue) {
this.listenersToPut.push({
rootNodeID: rootNodeID,
@@ -13381,21 +13547,14 @@ PooledClass.addPoolingTo(ReactPutListenerQueue);
module.exports = ReactPutListenerQueue;
-},{"./PooledClass":28,"./ReactBrowserEventEmitter":31,"./mixInto":147}],77:[function(_dereq_,module,exports){
+},{"./Object.assign":29,"./PooledClass":30,"./ReactBrowserEventEmitter":33}],81:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactReconcileTransaction
* @typechecks static-only
@@ -13410,7 +13569,7 @@ var ReactInputSelection = _dereq_("./ReactInputSelection");
var ReactPutListenerQueue = _dereq_("./ReactPutListenerQueue");
var Transaction = _dereq_("./Transaction");
-var mixInto = _dereq_("./mixInto");
+var assign = _dereq_("./Object.assign");
/**
* Ensures that, when possible, the selection range (currently selected text
@@ -13558,28 +13717,20 @@ var Mixin = {
};
-mixInto(ReactReconcileTransaction, Transaction.Mixin);
-mixInto(ReactReconcileTransaction, Mixin);
+assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
PooledClass.addPoolingTo(ReactReconcileTransaction);
module.exports = ReactReconcileTransaction;
-},{"./CallbackQueue":6,"./PooledClass":28,"./ReactBrowserEventEmitter":31,"./ReactInputSelection":63,"./ReactPutListenerQueue":76,"./Transaction":104,"./mixInto":147}],78:[function(_dereq_,module,exports){
+},{"./CallbackQueue":7,"./Object.assign":29,"./PooledClass":30,"./ReactBrowserEventEmitter":33,"./ReactInputSelection":65,"./ReactPutListenerQueue":80,"./Transaction":107}],82:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactRootIndex
* @typechecks
@@ -13603,28 +13754,21 @@ var ReactRootIndex = {
module.exports = ReactRootIndex;
-},{}],79:[function(_dereq_,module,exports){
+},{}],83:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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.
*
* @typechecks static-only
* @providesModule ReactServerRendering
*/
"use strict";
-var ReactDescriptor = _dereq_("./ReactDescriptor");
+var ReactElement = _dereq_("./ReactElement");
var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
var ReactMarkupChecksum = _dereq_("./ReactMarkupChecksum");
var ReactServerRenderingTransaction =
@@ -13634,20 +13778,14 @@ var instantiateReactComponent = _dereq_("./instantiateReactComponent");
var invariant = _dereq_("./invariant");
/**
- * @param {ReactComponent} component
+ * @param {ReactElement} element
* @return {string} the HTML markup
*/
-function renderComponentToString(component) {
+function renderToString(element) {
("production" !== "development" ? invariant(
- ReactDescriptor.isValidDescriptor(component),
- 'renderComponentToString(): You must pass a valid ReactComponent.'
- ) : invariant(ReactDescriptor.isValidDescriptor(component)));
-
- ("production" !== "development" ? invariant(
- !(arguments.length === 2 && typeof arguments[1] === 'function'),
- 'renderComponentToString(): This function became synchronous and now ' +
- 'returns the generated markup. Please remove the second parameter.'
- ) : invariant(!(arguments.length === 2 && typeof arguments[1] === 'function')));
+ ReactElement.isValidElement(element),
+ 'renderToString(): You must pass a valid ReactElement.'
+ ) : invariant(ReactElement.isValidElement(element)));
var transaction;
try {
@@ -13655,7 +13793,7 @@ function renderComponentToString(component) {
transaction = ReactServerRenderingTransaction.getPooled(false);
return transaction.perform(function() {
- var componentInstance = instantiateReactComponent(component);
+ var componentInstance = instantiateReactComponent(element, null);
var markup = componentInstance.mountComponent(id, transaction, 0);
return ReactMarkupChecksum.addChecksumToMarkup(markup);
}, null);
@@ -13665,15 +13803,15 @@ function renderComponentToString(component) {
}
/**
- * @param {ReactComponent} component
+ * @param {ReactElement} element
* @return {string} the HTML markup, without the extra React ID and checksum
-* (for generating static pages)
+ * (for generating static pages)
*/
-function renderComponentToStaticMarkup(component) {
+function renderToStaticMarkup(element) {
("production" !== "development" ? invariant(
- ReactDescriptor.isValidDescriptor(component),
- 'renderComponentToStaticMarkup(): You must pass a valid ReactComponent.'
- ) : invariant(ReactDescriptor.isValidDescriptor(component)));
+ ReactElement.isValidElement(element),
+ 'renderToStaticMarkup(): You must pass a valid ReactElement.'
+ ) : invariant(ReactElement.isValidElement(element)));
var transaction;
try {
@@ -13681,7 +13819,7 @@ function renderComponentToStaticMarkup(component) {
transaction = ReactServerRenderingTransaction.getPooled(true);
return transaction.perform(function() {
- var componentInstance = instantiateReactComponent(component);
+ var componentInstance = instantiateReactComponent(element, null);
return componentInstance.mountComponent(id, transaction, 0);
}, null);
} finally {
@@ -13690,25 +13828,18 @@ function renderComponentToStaticMarkup(component) {
}
module.exports = {
- renderComponentToString: renderComponentToString,
- renderComponentToStaticMarkup: renderComponentToStaticMarkup
+ renderToString: renderToString,
+ renderToStaticMarkup: renderToStaticMarkup
};
-},{"./ReactDescriptor":56,"./ReactInstanceHandles":64,"./ReactMarkupChecksum":66,"./ReactServerRenderingTransaction":80,"./instantiateReactComponent":133,"./invariant":134}],80:[function(_dereq_,module,exports){
+},{"./ReactElement":58,"./ReactInstanceHandles":66,"./ReactMarkupChecksum":69,"./ReactServerRenderingTransaction":84,"./instantiateReactComponent":139,"./invariant":140}],84:[function(_dereq_,module,exports){
/**
- * Copyright 2014 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
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactServerRenderingTransaction
* @typechecks
@@ -13721,8 +13852,8 @@ var CallbackQueue = _dereq_("./CallbackQueue");
var ReactPutListenerQueue = _dereq_("./ReactPutListenerQueue");
var Transaction = _dereq_("./Transaction");
+var assign = _dereq_("./Object.assign");
var emptyFunction = _dereq_("./emptyFunction");
-var mixInto = _dereq_("./mixInto");
/**
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
@@ -13804,28 +13935,24 @@ var Mixin = {
};
-mixInto(ReactServerRenderingTransaction, Transaction.Mixin);
-mixInto(ReactServerRenderingTransaction, Mixin);
+assign(
+ ReactServerRenderingTransaction.prototype,
+ Transaction.Mixin,
+ Mixin
+);
PooledClass.addPoolingTo(ReactServerRenderingTransaction);
module.exports = ReactServerRenderingTransaction;
-},{"./CallbackQueue":6,"./PooledClass":28,"./ReactPutListenerQueue":76,"./Transaction":104,"./emptyFunction":116,"./mixInto":147}],81:[function(_dereq_,module,exports){
+},{"./CallbackQueue":7,"./Object.assign":29,"./PooledClass":30,"./ReactPutListenerQueue":80,"./Transaction":107,"./emptyFunction":121}],85:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactStateSetters
*/
@@ -13924,21 +14051,14 @@ ReactStateSetters.Mixin = {
module.exports = ReactStateSetters;
-},{}],82:[function(_dereq_,module,exports){
+},{}],86:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactTestUtils
*/
@@ -13949,16 +14069,14 @@ var EventConstants = _dereq_("./EventConstants");
var EventPluginHub = _dereq_("./EventPluginHub");
var EventPropagators = _dereq_("./EventPropagators");
var React = _dereq_("./React");
-var ReactDescriptor = _dereq_("./ReactDescriptor");
-var ReactDOM = _dereq_("./ReactDOM");
+var ReactElement = _dereq_("./ReactElement");
var ReactBrowserEventEmitter = _dereq_("./ReactBrowserEventEmitter");
var ReactMount = _dereq_("./ReactMount");
var ReactTextComponent = _dereq_("./ReactTextComponent");
var ReactUpdates = _dereq_("./ReactUpdates");
var SyntheticEvent = _dereq_("./SyntheticEvent");
-var mergeInto = _dereq_("./mergeInto");
-var copyProperties = _dereq_("./copyProperties");
+var assign = _dereq_("./Object.assign");
var topLevelTypes = EventConstants.topLevelTypes;
@@ -13981,16 +14099,16 @@ var ReactTestUtils = {
// clean up, so we're going to stop honoring the name of this method
// (and probably rename it eventually) if no problems arise.
// document.documentElement.appendChild(div);
- return React.renderComponent(instance, div);
+ return React.render(instance, div);
},
- isDescriptor: function(descriptor) {
- return ReactDescriptor.isValidDescriptor(descriptor);
+ isElement: function(element) {
+ return ReactElement.isValidElement(element);
},
- isDescriptorOfType: function(inst, convenienceConstructor) {
+ isElementOfType: function(inst, convenienceConstructor) {
return (
- ReactDescriptor.isValidDescriptor(inst) &&
+ ReactElement.isValidElement(inst) &&
inst.type === convenienceConstructor.type
);
},
@@ -13999,9 +14117,9 @@ var ReactTestUtils = {
return !!(inst && inst.mountComponent && inst.tagName);
},
- isDOMComponentDescriptor: function(inst) {
+ isDOMComponentElement: function(inst) {
return !!(inst &&
- ReactDescriptor.isValidDescriptor(inst) &&
+ ReactElement.isValidElement(inst) &&
!!inst.tagName);
},
@@ -14015,8 +14133,8 @@ var ReactTestUtils = {
(inst.constructor === type.type));
},
- isCompositeComponentDescriptor: function(inst) {
- if (!ReactDescriptor.isValidDescriptor(inst)) {
+ isCompositeComponentElement: function(inst) {
+ if (!ReactElement.isValidElement(inst)) {
return false;
}
// We check the prototype of the type that will get mounted, not the
@@ -14028,8 +14146,8 @@ var ReactTestUtils = {
);
},
- isCompositeComponentDescriptorWithType: function(inst, type) {
- return !!(ReactTestUtils.isCompositeComponentDescriptor(inst) &&
+ isCompositeComponentElementWithType: function(inst, type) {
+ return !!(ReactTestUtils.isCompositeComponentElement(inst) &&
(inst.constructor === type));
},
@@ -14165,16 +14283,23 @@ var ReactTestUtils = {
* @return {object} the ReactTestUtils object (for chaining)
*/
mockComponent: function(module, mockTagName) {
- var ConvenienceConstructor = React.createClass({
+ mockTagName = mockTagName || module.mockTagName || "div";
+
+ var ConvenienceConstructor = React.createClass({displayName: 'ConvenienceConstructor',
render: function() {
- var mockTagName = mockTagName || module.mockTagName || "div";
- return ReactDOM[mockTagName](null, this.props.children);
+ return React.createElement(
+ mockTagName,
+ null,
+ this.props.children
+ );
}
});
- copyProperties(module, ConvenienceConstructor);
module.mockImplementation(ConvenienceConstructor);
+ module.type = ConvenienceConstructor.type;
+ module.isReactLegacyFactory = true;
+
return this;
},
@@ -14249,7 +14374,7 @@ function makeSimulator(eventType) {
ReactMount.getID(node),
fakeNativeEvent
);
- mergeInto(event, eventData);
+ assign(event, eventData);
EventPropagators.accumulateTwoPhaseDispatches(event);
ReactUpdates.batchedUpdates(function() {
@@ -14305,7 +14430,7 @@ buildSimulators();
function makeNativeSimulator(eventType) {
return function(domComponentOrNode, nativeEventData) {
var fakeNativeEvent = new Event(eventType);
- mergeInto(fakeNativeEvent, nativeEventData);
+ assign(fakeNativeEvent, nativeEventData);
if (ReactTestUtils.isDOMComponent(domComponentOrNode)) {
ReactTestUtils.simulateNativeEventOnDOMComponent(
eventType,
@@ -14338,21 +14463,14 @@ for (eventType in topLevelTypes) {
module.exports = ReactTestUtils;
-},{"./EventConstants":16,"./EventPluginHub":18,"./EventPropagators":21,"./React":29,"./ReactBrowserEventEmitter":31,"./ReactDOM":41,"./ReactDescriptor":56,"./ReactMount":67,"./ReactTextComponent":83,"./ReactUpdates":87,"./SyntheticEvent":96,"./copyProperties":110,"./mergeInto":146}],83:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./EventPluginHub":19,"./EventPropagators":22,"./Object.assign":29,"./React":31,"./ReactBrowserEventEmitter":33,"./ReactElement":58,"./ReactMount":70,"./ReactTextComponent":87,"./ReactUpdates":91,"./SyntheticEvent":99}],87:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactTextComponent
* @typechecks static-only
@@ -14361,12 +14479,11 @@ module.exports = ReactTestUtils;
"use strict";
var DOMPropertyOperations = _dereq_("./DOMPropertyOperations");
-var ReactBrowserComponentMixin = _dereq_("./ReactBrowserComponentMixin");
var ReactComponent = _dereq_("./ReactComponent");
-var ReactDescriptor = _dereq_("./ReactDescriptor");
+var ReactElement = _dereq_("./ReactElement");
+var assign = _dereq_("./Object.assign");
var escapeTextForBrowser = _dereq_("./escapeTextForBrowser");
-var mixInto = _dereq_("./mixInto");
/**
* Text nodes violate a couple assumptions that React makes about components:
@@ -14383,13 +14500,11 @@ var mixInto = _dereq_("./mixInto");
* @extends ReactComponent
* @internal
*/
-var ReactTextComponent = function(descriptor) {
- this.construct(descriptor);
+var ReactTextComponent = function(props) {
+ // This constructor and it's argument is currently used by mocks.
};
-mixInto(ReactTextComponent, ReactComponent.Mixin);
-mixInto(ReactTextComponent, ReactBrowserComponentMixin);
-mixInto(ReactTextComponent, {
+assign(ReactTextComponent.prototype, ReactComponent.Mixin, {
/**
* Creates the markup for this text node. This node is not intended to have
@@ -14445,23 +14560,23 @@ mixInto(ReactTextComponent, {
});
-module.exports = ReactDescriptor.createFactory(ReactTextComponent);
+var ReactTextComponentFactory = function(text) {
+ // Bypass validation and configuration
+ return new ReactElement(ReactTextComponent, null, null, null, null, text);
+};
+
+ReactTextComponentFactory.type = ReactTextComponent;
+
+module.exports = ReactTextComponentFactory;
-},{"./DOMPropertyOperations":12,"./ReactBrowserComponentMixin":30,"./ReactComponent":35,"./ReactDescriptor":56,"./escapeTextForBrowser":118,"./mixInto":147}],84:[function(_dereq_,module,exports){
+},{"./DOMPropertyOperations":13,"./Object.assign":29,"./ReactComponent":37,"./ReactElement":58,"./escapeTextForBrowser":123}],88:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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.
*
* @typechecks static-only
* @providesModule ReactTransitionChildMapping
@@ -14487,7 +14602,7 @@ var ReactTransitionChildMapping = {
/**
* When you're adding or removing children some may be added or removed in the
- * same render pass. We want ot show *both* since we want to simultaneously
+ * same render pass. We want to show *both* since we want to simultaneously
* animate elements in and out. This function takes a previous set of keys
* and a new set of keys and merges them with its best guess of the correct
* ordering. In the future we may expose some of the utilities in
@@ -14555,21 +14670,14 @@ var ReactTransitionChildMapping = {
module.exports = ReactTransitionChildMapping;
-},{"./ReactChildren":34}],85:[function(_dereq_,module,exports){
+},{"./ReactChildren":36}],89:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactTransitionEvents
*/
@@ -14673,21 +14781,14 @@ var ReactTransitionEvents = {
module.exports = ReactTransitionEvents;
-},{"./ExecutionEnvironment":22}],86:[function(_dereq_,module,exports){
+},{"./ExecutionEnvironment":23}],90:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactTransitionGroup
*/
@@ -14697,21 +14798,21 @@ module.exports = ReactTransitionEvents;
var React = _dereq_("./React");
var ReactTransitionChildMapping = _dereq_("./ReactTransitionChildMapping");
+var assign = _dereq_("./Object.assign");
var cloneWithProps = _dereq_("./cloneWithProps");
var emptyFunction = _dereq_("./emptyFunction");
-var merge = _dereq_("./merge");
var ReactTransitionGroup = React.createClass({
displayName: 'ReactTransitionGroup',
propTypes: {
- component: React.PropTypes.func,
+ component: React.PropTypes.any,
childFactory: React.PropTypes.func
},
getDefaultProps: function() {
return {
- component: React.DOM.span,
+ component: 'span',
childFactory: emptyFunction.thatReturnsArgument
};
},
@@ -14835,7 +14936,7 @@ var ReactTransitionGroup = React.createClass({
// This entered again before it fully left. Add it again.
this.performEnter(key);
} else {
- var newChildren = merge(this.state.children);
+ var newChildren = assign({}, this.state.children);
delete newChildren[key];
this.setState({children: newChildren});
}
@@ -14859,27 +14960,24 @@ var ReactTransitionGroup = React.createClass({
);
}
}
- return this.transferPropsTo(this.props.component(null, childrenToRender));
+ return React.createElement(
+ this.props.component,
+ this.props,
+ childrenToRender
+ );
}
});
module.exports = ReactTransitionGroup;
-},{"./React":29,"./ReactTransitionChildMapping":84,"./cloneWithProps":108,"./emptyFunction":116,"./merge":144}],87:[function(_dereq_,module,exports){
+},{"./Object.assign":29,"./React":31,"./ReactTransitionChildMapping":88,"./cloneWithProps":113,"./emptyFunction":121}],91:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ReactUpdates
*/
@@ -14892,11 +14990,13 @@ var ReactCurrentOwner = _dereq_("./ReactCurrentOwner");
var ReactPerf = _dereq_("./ReactPerf");
var Transaction = _dereq_("./Transaction");
+var assign = _dereq_("./Object.assign");
var invariant = _dereq_("./invariant");
-var mixInto = _dereq_("./mixInto");
var warning = _dereq_("./warning");
var dirtyComponents = [];
+var asapCallbackQueue = CallbackQueue.getPooled();
+var asapEnqueued = false;
var batchingStrategy = null;
@@ -14941,13 +15041,14 @@ var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
function ReactUpdatesFlushTransaction() {
this.reinitializeTransaction();
this.dirtyComponentsLength = null;
- this.callbackQueue = CallbackQueue.getPooled(null);
+ this.callbackQueue = CallbackQueue.getPooled();
this.reconcileTransaction =
ReactUpdates.ReactReconcileTransaction.getPooled();
}
-mixInto(ReactUpdatesFlushTransaction, Transaction.Mixin);
-mixInto(ReactUpdatesFlushTransaction, {
+assign(
+ ReactUpdatesFlushTransaction.prototype,
+ Transaction.Mixin, {
getTransactionWrappers: function() {
return TRANSACTION_WRAPPERS;
},
@@ -15038,11 +15139,21 @@ var flushBatchedUpdates = ReactPerf.measure(
// ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
// array and perform any updates enqueued by mount-ready handlers (i.e.,
// componentDidUpdate) but we need to check here too in order to catch
- // updates enqueued by setState callbacks.
- while (dirtyComponents.length) {
- var transaction = ReactUpdatesFlushTransaction.getPooled();
- transaction.perform(runBatchedUpdates, null, transaction);
- ReactUpdatesFlushTransaction.release(transaction);
+ // updates enqueued by setState callbacks and asap calls.
+ while (dirtyComponents.length || asapEnqueued) {
+ if (dirtyComponents.length) {
+ var transaction = ReactUpdatesFlushTransaction.getPooled();
+ transaction.perform(runBatchedUpdates, null, transaction);
+ ReactUpdatesFlushTransaction.release(transaction);
+ }
+
+ if (asapEnqueued) {
+ asapEnqueued = false;
+ var queue = asapCallbackQueue;
+ asapCallbackQueue = CallbackQueue.getPooled();
+ queue.notifyAll();
+ CallbackQueue.release(queue);
+ }
}
}
);
@@ -15089,6 +15200,20 @@ function enqueueUpdate(component, callback) {
}
}
+/**
+ * Enqueue a callback to be run at the end of the current batching cycle. Throws
+ * if no updates are currently being performed.
+ */
+function asap(callback, context) {
+ ("production" !== "development" ? invariant(
+ batchingStrategy.isBatchingUpdates,
+ 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' +
+ 'updates are not being batched.'
+ ) : invariant(batchingStrategy.isBatchingUpdates));
+ asapCallbackQueue.enqueue(callback, context);
+ asapEnqueued = true;
+}
+
var ReactUpdatesInjection = {
injectReconcileTransaction: function(ReconcileTransaction) {
("production" !== "development" ? invariant(
@@ -15127,84 +15252,20 @@ var ReactUpdates = {
batchedUpdates: batchedUpdates,
enqueueUpdate: enqueueUpdate,
flushBatchedUpdates: flushBatchedUpdates,
- injection: ReactUpdatesInjection
+ injection: ReactUpdatesInjection,
+ asap: asap
};
module.exports = ReactUpdates;
-},{"./CallbackQueue":6,"./PooledClass":28,"./ReactCurrentOwner":40,"./ReactPerf":71,"./Transaction":104,"./invariant":134,"./mixInto":147,"./warning":158}],88:[function(_dereq_,module,exports){
+},{"./CallbackQueue":7,"./Object.assign":29,"./PooledClass":30,"./ReactCurrentOwner":42,"./ReactPerf":75,"./Transaction":107,"./invariant":140,"./warning":160}],92:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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 ReactWithAddons
- */
-
-/**
- * This module exists purely in the open source project, and is meant as a way
- * to create a separate standalone build of React. This build has "addons", or
- * functionality we've built and think might be useful but doesn't have a good
- * place to live inside React core.
- */
-
-"use strict";
-
-var LinkedStateMixin = _dereq_("./LinkedStateMixin");
-var React = _dereq_("./React");
-var ReactComponentWithPureRenderMixin =
- _dereq_("./ReactComponentWithPureRenderMixin");
-var ReactCSSTransitionGroup = _dereq_("./ReactCSSTransitionGroup");
-var ReactTransitionGroup = _dereq_("./ReactTransitionGroup");
-
-var cx = _dereq_("./cx");
-var cloneWithProps = _dereq_("./cloneWithProps");
-var update = _dereq_("./update");
-
-React.addons = {
- CSSTransitionGroup: ReactCSSTransitionGroup,
- LinkedStateMixin: LinkedStateMixin,
- PureRenderMixin: ReactComponentWithPureRenderMixin,
- TransitionGroup: ReactTransitionGroup,
-
- classSet: cx,
- cloneWithProps: cloneWithProps,
- update: update
-};
-
-if ("production" !== "development") {
- React.addons.Perf = _dereq_("./ReactDefaultPerf");
- React.addons.TestUtils = _dereq_("./ReactTestUtils");
-}
-
-module.exports = React;
-
-
-},{"./LinkedStateMixin":24,"./React":29,"./ReactCSSTransitionGroup":32,"./ReactComponentWithPureRenderMixin":37,"./ReactDefaultPerf":54,"./ReactTestUtils":82,"./ReactTransitionGroup":86,"./cloneWithProps":108,"./cx":114,"./update":157}],89:[function(_dereq_,module,exports){
-/**
- * Copyright 2013-2014 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.
+ * 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 SVGDOMPropertyConfig
*/
@@ -15289,21 +15350,14 @@ var SVGDOMPropertyConfig = {
module.exports = SVGDOMPropertyConfig;
-},{"./DOMProperty":11}],90:[function(_dereq_,module,exports){
+},{"./DOMProperty":12}],93:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SelectEventPlugin
*/
@@ -15361,6 +15415,14 @@ function getSelection(node) {
start: node.selectionStart,
end: node.selectionEnd
};
+ } else if (window.getSelection) {
+ var selection = window.getSelection();
+ return {
+ anchorNode: selection.anchorNode,
+ anchorOffset: selection.anchorOffset,
+ focusNode: selection.focusNode,
+ focusOffset: selection.focusOffset
+ };
} else if (document.selection) {
var range = document.selection.createRange();
return {
@@ -15369,14 +15431,6 @@ function getSelection(node) {
top: range.boundingTop,
left: range.boundingLeft
};
- } else {
- var selection = window.getSelection();
- return {
- anchorNode: selection.anchorNode,
- anchorOffset: selection.anchorOffset,
- focusNode: selection.focusNode,
- focusOffset: selection.focusOffset
- };
}
}
@@ -15491,21 +15545,14 @@ var SelectEventPlugin = {
module.exports = SelectEventPlugin;
-},{"./EventConstants":16,"./EventPropagators":21,"./ReactInputSelection":63,"./SyntheticEvent":96,"./getActiveElement":122,"./isTextInputElement":137,"./keyOf":141,"./shallowEqual":153}],91:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./EventPropagators":22,"./ReactInputSelection":65,"./SyntheticEvent":99,"./getActiveElement":127,"./isTextInputElement":143,"./keyOf":147,"./shallowEqual":155}],94:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ServerReactRootIndex
* @typechecks
@@ -15529,21 +15576,14 @@ var ServerReactRootIndex = {
module.exports = ServerReactRootIndex;
-},{}],92:[function(_dereq_,module,exports){
+},{}],95:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SimpleEventPlugin
*/
@@ -15563,8 +15603,11 @@ var SyntheticTouchEvent = _dereq_("./SyntheticTouchEvent");
var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
var SyntheticWheelEvent = _dereq_("./SyntheticWheelEvent");
+var getEventCharCode = _dereq_("./getEventCharCode");
+
var invariant = _dereq_("./invariant");
var keyOf = _dereq_("./keyOf");
+var warning = _dereq_("./warning");
var topLevelTypes = EventConstants.topLevelTypes;
@@ -15831,7 +15874,7 @@ var SimpleEventPlugin = {
/**
* Same as the default implementation, except cancels the event when return
- * value is false.
+ * value is false. This behavior will be disabled in a future release.
*
* @param {object} Event to be dispatched.
* @param {function} Application-level callback.
@@ -15839,6 +15882,14 @@ var SimpleEventPlugin = {
*/
executeDispatch: function(event, listener, domID) {
var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
+
+ ("production" !== "development" ? warning(
+ typeof returnValue !== 'boolean',
+ 'Returning `false` from an event handler is deprecated and will be ' +
+ 'ignored in a future release. Instead, manually call ' +
+ 'e.stopPropagation() or e.preventDefault(), as appropriate.'
+ ) : null);
+
if (returnValue === false) {
event.stopPropagation();
event.preventDefault();
@@ -15875,8 +15926,9 @@ var SimpleEventPlugin = {
break;
case topLevelTypes.topKeyPress:
// FireFox creates a keypress event for function keys too. This removes
- // the unwanted keypress events.
- if (nativeEvent.charCode === 0) {
+ // the unwanted keypress events. Enter is however both printable and
+ // non-printable. One would expect Tab to be as well (but it isn't).
+ if (getEventCharCode(nativeEvent) === 0) {
return null;
}
/* falls through */
@@ -15950,21 +16002,14 @@ var SimpleEventPlugin = {
module.exports = SimpleEventPlugin;
-},{"./EventConstants":16,"./EventPluginUtils":20,"./EventPropagators":21,"./SyntheticClipboardEvent":93,"./SyntheticDragEvent":95,"./SyntheticEvent":96,"./SyntheticFocusEvent":97,"./SyntheticKeyboardEvent":99,"./SyntheticMouseEvent":100,"./SyntheticTouchEvent":101,"./SyntheticUIEvent":102,"./SyntheticWheelEvent":103,"./invariant":134,"./keyOf":141}],93:[function(_dereq_,module,exports){
+},{"./EventConstants":17,"./EventPluginUtils":21,"./EventPropagators":22,"./SyntheticClipboardEvent":96,"./SyntheticDragEvent":98,"./SyntheticEvent":99,"./SyntheticFocusEvent":100,"./SyntheticKeyboardEvent":102,"./SyntheticMouseEvent":103,"./SyntheticTouchEvent":104,"./SyntheticUIEvent":105,"./SyntheticWheelEvent":106,"./getEventCharCode":128,"./invariant":140,"./keyOf":147,"./warning":160}],96:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SyntheticClipboardEvent
* @typechecks static-only
@@ -16003,21 +16048,14 @@ SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
module.exports = SyntheticClipboardEvent;
-},{"./SyntheticEvent":96}],94:[function(_dereq_,module,exports){
+},{"./SyntheticEvent":99}],97:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SyntheticCompositionEvent
* @typechecks static-only
@@ -16056,21 +16094,14 @@ SyntheticEvent.augmentClass(
module.exports = SyntheticCompositionEvent;
-},{"./SyntheticEvent":96}],95:[function(_dereq_,module,exports){
+},{"./SyntheticEvent":99}],98:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SyntheticDragEvent
* @typechecks static-only
@@ -16102,21 +16133,14 @@ SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
module.exports = SyntheticDragEvent;
-},{"./SyntheticMouseEvent":100}],96:[function(_dereq_,module,exports){
+},{"./SyntheticMouseEvent":103}],99:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SyntheticEvent
* @typechecks static-only
@@ -16126,10 +16150,9 @@ module.exports = SyntheticDragEvent;
var PooledClass = _dereq_("./PooledClass");
+var assign = _dereq_("./Object.assign");
var emptyFunction = _dereq_("./emptyFunction");
var getEventTarget = _dereq_("./getEventTarget");
-var merge = _dereq_("./merge");
-var mergeInto = _dereq_("./mergeInto");
/**
* @interface Event
@@ -16196,7 +16219,7 @@ function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent) {
this.isPropagationStopped = emptyFunction.thatReturnsFalse;
}
-mergeInto(SyntheticEvent.prototype, {
+assign(SyntheticEvent.prototype, {
preventDefault: function() {
this.defaultPrevented = true;
@@ -16254,11 +16277,11 @@ SyntheticEvent.augmentClass = function(Class, Interface) {
var Super = this;
var prototype = Object.create(Super.prototype);
- mergeInto(prototype, Class.prototype);
+ assign(prototype, Class.prototype);
Class.prototype = prototype;
Class.prototype.constructor = Class;
- Class.Interface = merge(Super.Interface, Interface);
+ Class.Interface = assign({}, Super.Interface, Interface);
Class.augmentClass = Super.augmentClass;
PooledClass.addPoolingTo(Class, PooledClass.threeArgumentPooler);
@@ -16268,21 +16291,14 @@ PooledClass.addPoolingTo(SyntheticEvent, PooledClass.threeArgumentPooler);
module.exports = SyntheticEvent;
-},{"./PooledClass":28,"./emptyFunction":116,"./getEventTarget":125,"./merge":144,"./mergeInto":146}],97:[function(_dereq_,module,exports){
+},{"./Object.assign":29,"./PooledClass":30,"./emptyFunction":121,"./getEventTarget":131}],100:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SyntheticFocusEvent
* @typechecks static-only
@@ -16314,21 +16330,14 @@ SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
module.exports = SyntheticFocusEvent;
-},{"./SyntheticUIEvent":102}],98:[function(_dereq_,module,exports){
+},{"./SyntheticUIEvent":105}],101:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SyntheticInputEvent
* @typechecks static-only
@@ -16368,21 +16377,14 @@ SyntheticEvent.augmentClass(
module.exports = SyntheticInputEvent;
-},{"./SyntheticEvent":96}],99:[function(_dereq_,module,exports){
+},{"./SyntheticEvent":99}],102:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SyntheticKeyboardEvent
* @typechecks static-only
@@ -16392,6 +16394,7 @@ module.exports = SyntheticInputEvent;
var SyntheticUIEvent = _dereq_("./SyntheticUIEvent");
+var getEventCharCode = _dereq_("./getEventCharCode");
var getEventKey = _dereq_("./getEventKey");
var getEventModifierState = _dereq_("./getEventModifierState");
@@ -16414,11 +16417,10 @@ var KeyboardEventInterface = {
// `charCode` is the result of a KeyPress event and represents the value of
// the actual printable character.
- // KeyPress is deprecated but its replacement is not yet final and not
- // implemented in any major browser.
+ // KeyPress is deprecated, but its replacement is not yet final and not
+ // implemented in any major browser. Only KeyPress has charCode.
if (event.type === 'keypress') {
- // IE8 does not implement "charCode", but "keyCode" has the correct value.
- return 'charCode' in event ? event.charCode : event.keyCode;
+ return getEventCharCode(event);
}
return 0;
},
@@ -16437,9 +16439,14 @@ var KeyboardEventInterface = {
},
which: function(event) {
// `which` is an alias for either `keyCode` or `charCode` depending on the
- // type of the event. There is no need to determine the type of the event
- // as `keyCode` and `charCode` are either aliased or default to zero.
- return event.keyCode || event.charCode;
+ // type of the event.
+ if (event.type === 'keypress') {
+ return getEventCharCode(event);
+ }
+ if (event.type === 'keydown' || event.type === 'keyup') {
+ return event.keyCode;
+ }
+ return 0;
}
};
@@ -16457,21 +16464,14 @@ SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
module.exports = SyntheticKeyboardEvent;
-},{"./SyntheticUIEvent":102,"./getEventKey":123,"./getEventModifierState":124}],100:[function(_dereq_,module,exports){
+},{"./SyntheticUIEvent":105,"./getEventCharCode":128,"./getEventKey":129,"./getEventModifierState":130}],103:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SyntheticMouseEvent
* @typechecks static-only
@@ -16547,21 +16547,14 @@ SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
module.exports = SyntheticMouseEvent;
-},{"./SyntheticUIEvent":102,"./ViewportMetrics":105,"./getEventModifierState":124}],101:[function(_dereq_,module,exports){
+},{"./SyntheticUIEvent":105,"./ViewportMetrics":108,"./getEventModifierState":130}],104:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SyntheticTouchEvent
* @typechecks static-only
@@ -16602,21 +16595,14 @@ SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
module.exports = SyntheticTouchEvent;
-},{"./SyntheticUIEvent":102,"./getEventModifierState":124}],102:[function(_dereq_,module,exports){
+},{"./SyntheticUIEvent":105,"./getEventModifierState":130}],105:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SyntheticUIEvent
* @typechecks static-only
@@ -16671,21 +16657,14 @@ SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
module.exports = SyntheticUIEvent;
-},{"./SyntheticEvent":96,"./getEventTarget":125}],103:[function(_dereq_,module,exports){
+},{"./SyntheticEvent":99,"./getEventTarget":131}],106:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 SyntheticWheelEvent
* @typechecks static-only
@@ -16739,21 +16718,14 @@ SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
module.exports = SyntheticWheelEvent;
-},{"./SyntheticMouseEvent":100}],104:[function(_dereq_,module,exports){
+},{"./SyntheticMouseEvent":103}],107:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 Transaction
*/
@@ -16985,21 +16957,14 @@ var Transaction = {
module.exports = Transaction;
-},{"./invariant":134}],105:[function(_dereq_,module,exports){
+},{"./invariant":140}],108:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 ViewportMetrics
*/
@@ -17024,23 +16989,16 @@ var ViewportMetrics = {
module.exports = ViewportMetrics;
-},{"./getUnboundedScrollPosition":130}],106:[function(_dereq_,module,exports){
+},{"./getUnboundedScrollPosition":136}],109:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 accumulate
+ * @providesModule accumulateInto
*/
"use strict";
@@ -17048,53 +17006,61 @@ module.exports = ViewportMetrics;
var invariant = _dereq_("./invariant");
/**
- * Accumulates items that must not be null or undefined.
*
- * This is used to conserve memory by avoiding array allocations.
+ * Accumulates items that must not be null or undefined into the first one. This
+ * is used to conserve memory by avoiding array allocations, and thus sacrifices
+ * API cleanness. Since `current` can be null before being passed in and not
+ * null after this function, make sure to assign it back to `current`:
+ *
+ * `a = accumulateInto(a, b);`
+ *
+ * This API should be sparingly used. Try `accumulate` for something cleaner.
*
* @return {*|array<*>} An accumulation of items.
*/
-function accumulate(current, next) {
+
+function accumulateInto(current, next) {
("production" !== "development" ? invariant(
next != null,
- 'accumulate(...): Accumulated items must be not be null or undefined.'
+ 'accumulateInto(...): Accumulated items must not be null or undefined.'
) : invariant(next != null));
if (current == null) {
return next;
- } else {
- // Both are not empty. Warning: Never call x.concat(y) when you are not
- // certain that x is an Array (x could be a string with concat method).
- var currentIsArray = Array.isArray(current);
- var nextIsArray = Array.isArray(next);
- if (currentIsArray) {
- return current.concat(next);
- } else {
- if (nextIsArray) {
- return [current].concat(next);
- } else {
- return [current, next];
- }
- }
}
+
+ // Both are not empty. Warning: Never call x.concat(y) when you are not
+ // certain that x is an Array (x could be a string with concat method).
+ var currentIsArray = Array.isArray(current);
+ var nextIsArray = Array.isArray(next);
+
+ if (currentIsArray && nextIsArray) {
+ current.push.apply(current, next);
+ return current;
+ }
+
+ if (currentIsArray) {
+ current.push(next);
+ return current;
+ }
+
+ if (nextIsArray) {
+ // A bit too dangerous to mutate `next`.
+ return [current].concat(next);
+ }
+
+ return [current, next];
}
-module.exports = accumulate;
+module.exports = accumulateInto;
-},{"./invariant":134}],107:[function(_dereq_,module,exports){
+},{"./invariant":140}],110:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 adler32
*/
@@ -17107,7 +17073,7 @@ var MOD = 65521;
// This is a clean-room implementation of adler32 designed for detecting
// if markup is not what we expect it to be. It does not need to be
-// cryptographically strong, only reasonable good at detecting if markup
+// cryptographically strong, only reasonably good at detecting if markup
// generated on the server is different than that on the client.
function adler32(data) {
var a = 1;
@@ -17121,21 +17087,88 @@ function adler32(data) {
module.exports = adler32;
-},{}],108:[function(_dereq_,module,exports){
+},{}],111:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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
+ * 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.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * @providesModule camelize
+ * @typechecks
+ */
+
+var _hyphenPattern = /-(.)/g;
+
+/**
+ * Camelcases a hyphenated string, for example:
*
- * 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.
+ * > camelize('background-color')
+ * < "backgroundColor"
+ *
+ * @param {string} string
+ * @return {string}
+ */
+function camelize(string) {
+ return string.replace(_hyphenPattern, function(_, character) {
+ return character.toUpperCase();
+ });
+}
+
+module.exports = camelize;
+
+},{}],112:[function(_dereq_,module,exports){
+/**
+ * Copyright 2014, 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
+ */
+
+"use strict";
+
+var camelize = _dereq_("./camelize");
+
+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-'));
+}
+
+module.exports = camelizeStyleName;
+
+},{"./camelize":111}],113:[function(_dereq_,module,exports){
+/**
+ * Copyright 2013-2014, 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.
*
* @typechecks
* @providesModule cloneWithProps
@@ -17143,6 +17176,7 @@ module.exports = adler32;
"use strict";
+var ReactElement = _dereq_("./ReactElement");
var ReactPropTransferer = _dereq_("./ReactPropTransferer");
var keyOf = _dereq_("./keyOf");
@@ -17162,7 +17196,7 @@ var CHILDREN_PROP = keyOf({children: null});
function cloneWithProps(child, props) {
if ("production" !== "development") {
("production" !== "development" ? warning(
- !child.props.ref,
+ !child.ref,
'You are calling cloneWithProps() on a child with a ref. This is ' +
'dangerous because you\'re creating a new child which will not be ' +
'added as a ref to its parent.'
@@ -17178,27 +17212,20 @@ function cloneWithProps(child, props) {
}
// The current API doesn't retain _owner and _context, which is why this
- // doesn't use ReactDescriptor.cloneAndReplaceProps.
- return child.constructor(newProps);
+ // doesn't use ReactElement.cloneAndReplaceProps.
+ return ReactElement.createElement(child.type, newProps);
}
module.exports = cloneWithProps;
-},{"./ReactPropTransferer":72,"./keyOf":141,"./warning":158}],109:[function(_dereq_,module,exports){
+},{"./ReactElement":58,"./ReactPropTransferer":76,"./keyOf":147,"./warning":160}],114:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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
@@ -17235,77 +17262,14 @@ function containsNode(outerNode, innerNode) {
module.exports = containsNode;
-},{"./isTextNode":138}],110:[function(_dereq_,module,exports){
+},{"./isTextNode":144}],115:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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 copyProperties
- */
-
-/**
- * Copy properties from one or more objects (up to 5) into the first object.
- * This is a shallow copy. It mutates the first object and also returns it.
- *
- * NOTE: `arguments` has a very significant performance penalty, which is why
- * we don't support unlimited arguments.
- */
-function copyProperties(obj, a, b, c, d, e, f) {
- obj = obj || {};
-
- if ("production" !== "development") {
- if (f) {
- throw new Error('Too many arguments passed to copyProperties');
- }
- }
-
- var args = [a, b, c, d, e];
- var ii = 0, v;
- while (args[ii]) {
- v = args[ii++];
- for (var k in v) {
- obj[k] = v[k];
- }
-
- // IE ignores toString in object iteration.. See:
- // webreflection.blogspot.com/2007/07/quick-fix-internet-explorer-and.html
- if (v.hasOwnProperty && v.hasOwnProperty('toString') &&
- (typeof v.toString != 'undefined') && (obj.toString !== v.toString)) {
- obj.toString = v.toString;
- }
- }
-
- return obj;
-}
-
-module.exports = copyProperties;
-
-},{}],111:[function(_dereq_,module,exports){
-/**
- * Copyright 2013-2014 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.
+ * 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 createArrayFrom
* @typechecks
@@ -17384,21 +17348,14 @@ function createArrayFrom(obj) {
module.exports = createArrayFrom;
-},{"./toArray":155}],112:[function(_dereq_,module,exports){
+},{"./toArray":157}],116:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 createFullPageComponent
* @typechecks
@@ -17408,6 +17365,7 @@ module.exports = createArrayFrom;
// Defeat circular references by requiring this directly.
var ReactCompositeComponent = _dereq_("./ReactCompositeComponent");
+var ReactElement = _dereq_("./ReactElement");
var invariant = _dereq_("./invariant");
@@ -17419,14 +17377,14 @@ var invariant = _dereq_("./invariant");
* take advantage of React's reconciliation for styling and <title>
* management. So we just document it and throw in dangerous cases.
*
- * @param {function} componentClass convenience constructor to wrap
+ * @param {string} tag The tag to wrap
* @return {function} convenience constructor of new component
*/
-function createFullPageComponent(componentClass) {
+function createFullPageComponent(tag) {
+ var elementFactory = ReactElement.createFactory(tag);
+
var FullPageComponent = ReactCompositeComponent.createClass({
- displayName: 'ReactFullPageComponent' + (
- componentClass.type.displayName || ''
- ),
+ displayName: 'ReactFullPageComponent' + tag,
componentWillUnmount: function() {
("production" !== "development" ? invariant(
@@ -17440,7 +17398,7 @@ function createFullPageComponent(componentClass) {
},
render: function() {
- return this.transferPropsTo(componentClass(null, this.props.children));
+ return elementFactory(this.props);
}
});
@@ -17449,21 +17407,14 @@ function createFullPageComponent(componentClass) {
module.exports = createFullPageComponent;
-},{"./ReactCompositeComponent":38,"./invariant":134}],113:[function(_dereq_,module,exports){
+},{"./ReactCompositeComponent":40,"./ReactElement":58,"./invariant":140}],117:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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
@@ -17544,21 +17495,14 @@ function createNodesFromMarkup(markup, handleScript) {
module.exports = createNodesFromMarkup;
-},{"./ExecutionEnvironment":22,"./createArrayFrom":111,"./getMarkupWrap":126,"./invariant":134}],114:[function(_dereq_,module,exports){
+},{"./ExecutionEnvironment":23,"./createArrayFrom":115,"./getMarkupWrap":132,"./invariant":140}],118:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 cx
*/
@@ -17590,21 +17534,14 @@ function cx(classNames) {
module.exports = cx;
-},{}],115:[function(_dereq_,module,exports){
+},{}],119:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 dangerousStyleValue
* @typechecks static-only
@@ -17655,27 +17592,67 @@ function dangerousStyleValue(name, value) {
module.exports = dangerousStyleValue;
-},{"./CSSProperty":4}],116:[function(_dereq_,module,exports){
+},{"./CSSProperty":5}],120:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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
+ * 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.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * @providesModule deprecated
+ */
+
+var assign = _dereq_("./Object.assign");
+var warning = _dereq_("./warning");
+
+/**
+ * This will log a single deprecation notice per function and forward the call
+ * on to the new API.
*
- * 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.
+ * @param {string} namespace The namespace of the call, eg 'React'
+ * @param {string} oldName The old function name, eg 'renderComponent'
+ * @param {string} newName The new function name, eg 'render'
+ * @param {*} ctx The context this forwarded call should run in
+ * @param {function} fn The function to forward on to
+ * @return {*} Will be the value as returned from `fn`
+ */
+function deprecated(namespace, oldName, newName, ctx, fn) {
+ var warned = false;
+ if ("production" !== "development") {
+ var newFn = function() {
+ ("production" !== "development" ? warning(
+ warned,
+ (namespace + "." + oldName + " will be deprecated in a future version. ") +
+ ("Use " + namespace + "." + newName + " instead.")
+ ) : null);
+ warned = true;
+ return fn.apply(ctx, arguments);
+ };
+ newFn.displayName = (namespace + "_" + oldName);
+ // We need to make sure all properties of the original fn are copied over.
+ // In particular, this is needed to support PropTypes
+ return assign(newFn, fn);
+ }
+
+ return fn;
+}
+
+module.exports = deprecated;
+
+},{"./Object.assign":29,"./warning":160}],121:[function(_dereq_,module,exports){
+/**
+ * Copyright 2013-2014, 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 emptyFunction
*/
-var copyProperties = _dereq_("./copyProperties");
-
function makeEmptyFunction(arg) {
return function() {
return arg;
@@ -17689,32 +17666,23 @@ function makeEmptyFunction(arg) {
*/
function emptyFunction() {}
-copyProperties(emptyFunction, {
- thatReturns: makeEmptyFunction,
- thatReturnsFalse: makeEmptyFunction(false),
- thatReturnsTrue: makeEmptyFunction(true),
- thatReturnsNull: makeEmptyFunction(null),
- thatReturnsThis: function() { return this; },
- thatReturnsArgument: function(arg) { return arg; }
-});
+emptyFunction.thatReturns = makeEmptyFunction;
+emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
+emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
+emptyFunction.thatReturnsNull = makeEmptyFunction(null);
+emptyFunction.thatReturnsThis = function() { return this; };
+emptyFunction.thatReturnsArgument = function(arg) { return arg; };
module.exports = emptyFunction;
-},{"./copyProperties":110}],117:[function(_dereq_,module,exports){
+},{}],122:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 emptyObject
*/
@@ -17729,21 +17697,14 @@ if ("production" !== "development") {
module.exports = emptyObject;
-},{}],118:[function(_dereq_,module,exports){
+},{}],123:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 escapeTextForBrowser
* @typechecks static-only
@@ -17777,27 +17738,22 @@ function escapeTextForBrowser(text) {
module.exports = escapeTextForBrowser;
-},{}],119:[function(_dereq_,module,exports){
+},{}],124:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 flattenChildren
*/
"use strict";
+var ReactTextComponent = _dereq_("./ReactTextComponent");
+
var traverseAllChildren = _dereq_("./traverseAllChildren");
var warning = _dereq_("./warning");
@@ -17818,7 +17774,18 @@ function flattenSingleChildIntoContext(traverseContext, child, name) {
name
) : null);
if (keyUnique && child != null) {
- result[name] = child;
+ var type = typeof child;
+ var normalizedValue;
+
+ if (type === 'string') {
+ normalizedValue = ReactTextComponent(child);
+ } else if (type === 'number') {
+ normalizedValue = ReactTextComponent('' + child);
+ } else {
+ normalizedValue = child;
+ }
+
+ result[name] = normalizedValue;
}
}
@@ -17838,21 +17805,14 @@ function flattenChildren(children) {
module.exports = flattenChildren;
-},{"./traverseAllChildren":156,"./warning":158}],120:[function(_dereq_,module,exports){
+},{"./ReactTextComponent":87,"./traverseAllChildren":158,"./warning":160}],125:[function(_dereq_,module,exports){
/**
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 focusNode
*/
@@ -17860,34 +17820,28 @@ module.exports = flattenChildren;
"use strict";
/**
- * IE8 throws if an input/textarea is disabled and we try to focus it.
- * Focus only when necessary.
- *
* @param {DOMElement} node input/textarea to focus
*/
function focusNode(node) {
- if (!node.disabled) {
+ // IE8 can throw "Can't move focus to the control because it is invisible,
+ // not enabled, or of a type that does not accept the focus." for all kinds of
+ // reasons that are too expensive and fragile to test.
+ try {
node.focus();
+ } catch(e) {
}
}
module.exports = focusNode;
-},{}],121:[function(_dereq_,module,exports){
+},{}],126:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 forEachAccumulated
*/
@@ -17911,21 +17865,14 @@ var forEachAccumulated = function(arr, cb, scope) {
module.exports = forEachAccumulated;
-},{}],122:[function(_dereq_,module,exports){
+},{}],127:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 getActiveElement
* @typechecks
@@ -17947,21 +17894,66 @@ function getActiveElement() /*?DOMElement*/ {
module.exports = getActiveElement;
-},{}],123:[function(_dereq_,module,exports){
+},{}],128:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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
+ * 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.
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * @providesModule getEventCharCode
+ * @typechecks static-only
+ */
+
+"use strict";
+
+/**
+ * `charCode` represents the actual "character code" and is safe to use with
+ * `String.fromCharCode`. As such, only keys that correspond to printable
+ * characters produce a valid `charCode`, the only exception to this is Enter.
+ * The Tab-key is considered non-printable and does not have a `charCode`,
+ * presumably because it does not produce a tab-character in browsers.
*
- * 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.
+ * @param {object} nativeEvent Native browser event.
+ * @return {string} Normalized `charCode` property.
+ */
+function getEventCharCode(nativeEvent) {
+ var charCode;
+ var keyCode = nativeEvent.keyCode;
+
+ if ('charCode' in nativeEvent) {
+ charCode = nativeEvent.charCode;
+
+ // FF does not set `charCode` for the Enter-key, check against `keyCode`.
+ if (charCode === 0 && keyCode === 13) {
+ charCode = 13;
+ }
+ } else {
+ // IE8 does not implement `charCode`, but `keyCode` has the correct value.
+ charCode = keyCode;
+ }
+
+ // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
+ // Must not discard the (non-)printable Enter-key.
+ if (charCode >= 32 || charCode === 13) {
+ return charCode;
+ }
+
+ return 0;
+}
+
+module.exports = getEventCharCode;
+
+},{}],129:[function(_dereq_,module,exports){
+/**
+ * Copyright 2013-2014, 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 getEventKey
* @typechecks static-only
@@ -17969,7 +17961,7 @@ module.exports = getActiveElement;
"use strict";
-var invariant = _dereq_("./invariant");
+var getEventCharCode = _dereq_("./getEventCharCode");
/**
* Normalization of deprecated HTML5 `key` values
@@ -17991,7 +17983,7 @@ var normalizeKey = {
};
/**
- * Translation from legacy `which`/`keyCode` to HTML5 `key`
+ * Translation from legacy `keyCode` to HTML5 `key`
* Only special keys supported, all others depend on keyboard layout or browser
* @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
*/
@@ -18043,11 +18035,7 @@ function getEventKey(nativeEvent) {
// Browser does not implement `key`, polyfill as much of it as we can.
if (nativeEvent.type === 'keypress') {
- // Create the character from the `charCode` ourselves and use as an almost
- // perfect replacement.
- var charCode = 'charCode' in nativeEvent ?
- nativeEvent.charCode :
- nativeEvent.keyCode;
+ var charCode = getEventCharCode(nativeEvent);
// The enter-key is technically both printable and non-printable and can
// thus be captured by `keypress`, no other non-printable key should.
@@ -18058,27 +18046,19 @@ function getEventKey(nativeEvent) {
// `keyCode` value, almost all function keys have a universal value.
return translateToKey[nativeEvent.keyCode] || 'Unidentified';
}
-
- ("production" !== "development" ? invariant(false, "Unexpected keyboard event type: %s", nativeEvent.type) : invariant(false));
+ return '';
}
module.exports = getEventKey;
-},{"./invariant":134}],124:[function(_dereq_,module,exports){
+},{"./getEventCharCode":128}],130:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 getEventModifierState
* @typechecks static-only
@@ -18118,21 +18098,14 @@ function getEventModifierState(nativeEvent) {
module.exports = getEventModifierState;
-},{}],125:[function(_dereq_,module,exports){
+},{}],131:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 getEventTarget
* @typechecks static-only
@@ -18156,21 +18129,14 @@ function getEventTarget(nativeEvent) {
module.exports = getEventTarget;
-},{}],126:[function(_dereq_,module,exports){
+},{}],132:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 getMarkupWrap
*/
@@ -18278,21 +18244,14 @@ function getMarkupWrap(nodeName) {
module.exports = getMarkupWrap;
-},{"./ExecutionEnvironment":22,"./invariant":134}],127:[function(_dereq_,module,exports){
+},{"./ExecutionEnvironment":23,"./invariant":140}],133:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 getNodeForCharacterOffset
*/
@@ -18360,21 +18319,14 @@ function getNodeForCharacterOffset(root, offset) {
module.exports = getNodeForCharacterOffset;
-},{}],128:[function(_dereq_,module,exports){
+},{}],134:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 getReactRootElementInContainer
*/
@@ -18402,21 +18354,14 @@ function getReactRootElementInContainer(container) {
module.exports = getReactRootElementInContainer;
-},{}],129:[function(_dereq_,module,exports){
+},{}],135:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 getTextContentAccessor
*/
@@ -18446,21 +18391,14 @@ function getTextContentAccessor() {
module.exports = getTextContentAccessor;
-},{"./ExecutionEnvironment":22}],130:[function(_dereq_,module,exports){
+},{"./ExecutionEnvironment":23}],136:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 getUnboundedScrollPosition
* @typechecks
@@ -18493,21 +18431,14 @@ function getUnboundedScrollPosition(scrollable) {
module.exports = getUnboundedScrollPosition;
-},{}],131:[function(_dereq_,module,exports){
+},{}],137:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 hyphenate
* @typechecks
@@ -18533,21 +18464,14 @@ function hyphenate(string) {
module.exports = hyphenate;
-},{}],132:[function(_dereq_,module,exports){
+},{}],138:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 hyphenateStyleName
* @typechecks
@@ -18562,11 +18486,11 @@ var msPattern = /^ms-/;
/**
* Hyphenates a camelcased CSS property name, for example:
*
- * > hyphenate('backgroundColor')
+ * > hyphenateStyleName('backgroundColor')
* < "background-color"
- * > hyphenate('MozTransition')
+ * > hyphenateStyleName('MozTransition')
* < "-moz-transition"
- * > hyphenate('msTransition')
+ * > hyphenateStyleName('msTransition')
* < "-ms-transition"
*
* As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
@@ -18581,21 +18505,14 @@ function hyphenateStyleName(string) {
module.exports = hyphenateStyleName;
-},{"./hyphenate":131}],133:[function(_dereq_,module,exports){
+},{"./hyphenate":137}],139:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 instantiateReactComponent
* @typechecks static-only
@@ -18603,63 +18520,111 @@ module.exports = hyphenateStyleName;
"use strict";
-var invariant = _dereq_("./invariant");
+var warning = _dereq_("./warning");
-/**
- * Validate a `componentDescriptor`. This should be exposed publicly in a follow
- * up diff.
- *
- * @param {object} descriptor
- * @return {boolean} Returns true if this is a valid descriptor of a Component.
- */
-function isValidComponentDescriptor(descriptor) {
- return (
- descriptor &&
- typeof descriptor.type === 'function' &&
- typeof descriptor.type.prototype.mountComponent === 'function' &&
- typeof descriptor.type.prototype.receiveComponent === 'function'
- );
-}
+var ReactElement = _dereq_("./ReactElement");
+var ReactLegacyElement = _dereq_("./ReactLegacyElement");
+var ReactNativeComponent = _dereq_("./ReactNativeComponent");
+var ReactEmptyComponent = _dereq_("./ReactEmptyComponent");
/**
- * Given a `componentDescriptor` create an instance that will actually be
- * mounted. Currently it just extracts an existing clone from composite
- * components but this is an implementation detail which will change.
+ * Given an `element` create an instance that will actually be mounted.
*
- * @param {object} descriptor
- * @return {object} A new instance of componentDescriptor's constructor.
+ * @param {object} element
+ * @param {*} parentCompositeType The composite type that resolved this.
+ * @return {object} A new instance of the element's constructor.
* @protected
*/
-function instantiateReactComponent(descriptor) {
+function instantiateReactComponent(element, parentCompositeType) {
+ var instance;
- // TODO: Make warning
- // if (__DEV__) {
- ("production" !== "development" ? invariant(
- isValidComponentDescriptor(descriptor),
- 'Only React Components are valid for mounting.'
- ) : invariant(isValidComponentDescriptor(descriptor)));
- // }
+ if ("production" !== "development") {
+ ("production" !== "development" ? warning(
+ element && (typeof element.type === 'function' ||
+ typeof element.type === 'string'),
+ 'Only functions or strings can be mounted as React components.'
+ ) : null);
+
+ // Resolve mock instances
+ if (element.type._mockedReactClassConstructor) {
+ // If this is a mocked class, we treat the legacy factory as if it was the
+ // class constructor for future proofing unit tests. Because this might
+ // be mocked as a legacy factory, we ignore any warnings triggerd by
+ // this temporary hack.
+ ReactLegacyElement._isLegacyCallWarningEnabled = false;
+ try {
+ instance = new element.type._mockedReactClassConstructor(
+ element.props
+ );
+ } finally {
+ ReactLegacyElement._isLegacyCallWarningEnabled = true;
+ }
+
+ // If the mock implementation was a legacy factory, then it returns a
+ // element. We need to turn this into a real component instance.
+ if (ReactElement.isValidElement(instance)) {
+ instance = new instance.type(instance.props);
+ }
+
+ var render = instance.render;
+ if (!render) {
+ // For auto-mocked factories, the prototype isn't shimmed and therefore
+ // there is no render function on the instance. We replace the whole
+ // component with an empty component instance instead.
+ element = ReactEmptyComponent.getEmptyComponent();
+ } else {
+ if (render._isMockFunction && !render._getMockImplementation()) {
+ // Auto-mocked components may have a prototype with a mocked render
+ // function. For those, we'll need to mock the result of the render
+ // since we consider undefined to be invalid results from render.
+ render.mockImplementation(
+ ReactEmptyComponent.getEmptyComponent
+ );
+ }
+ instance.construct(element);
+ return instance;
+ }
+ }
+ }
- return new descriptor.type(descriptor);
+ // Special case string values
+ if (typeof element.type === 'string') {
+ instance = ReactNativeComponent.createInstanceForTag(
+ element.type,
+ element.props,
+ parentCompositeType
+ );
+ } else {
+ // Normal case for non-mocks and non-strings
+ instance = new element.type(element.props);
+ }
+
+ if ("production" !== "development") {
+ ("production" !== "development" ? warning(
+ typeof instance.construct === 'function' &&
+ typeof instance.mountComponent === 'function' &&
+ typeof instance.receiveComponent === 'function',
+ 'Only React Components can be mounted.'
+ ) : null);
+ }
+
+ // This actually sets up the internal instance. This will become decoupled
+ // from the public instance in a future diff.
+ instance.construct(element);
+
+ return instance;
}
module.exports = instantiateReactComponent;
-},{"./invariant":134}],134:[function(_dereq_,module,exports){
+},{"./ReactElement":58,"./ReactEmptyComponent":60,"./ReactLegacyElement":67,"./ReactNativeComponent":73,"./warning":160}],140:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 invariant
*/
@@ -18707,21 +18672,14 @@ var invariant = function(condition, format, a, b, c, d, e, f) {
module.exports = invariant;
-},{}],135:[function(_dereq_,module,exports){
+},{}],141:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 isEventSupported
*/
@@ -18779,21 +18737,14 @@ function isEventSupported(eventNameSuffix, capture) {
module.exports = isEventSupported;
-},{"./ExecutionEnvironment":22}],136:[function(_dereq_,module,exports){
+},{"./ExecutionEnvironment":23}],142:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 isNode
* @typechecks
@@ -18814,21 +18765,14 @@ function isNode(object) {
module.exports = isNode;
-},{}],137:[function(_dereq_,module,exports){
+},{}],143:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 isTextInputElement
*/
@@ -18865,21 +18809,14 @@ function isTextInputElement(elem) {
module.exports = isTextInputElement;
-},{}],138:[function(_dereq_,module,exports){
+},{}],144:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 isTextNode
* @typechecks
@@ -18897,21 +18834,14 @@ function isTextNode(object) {
module.exports = isTextNode;
-},{"./isNode":136}],139:[function(_dereq_,module,exports){
+},{"./isNode":142}],145:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 joinClasses
* @typechecks static-only
@@ -18935,7 +18865,9 @@ function joinClasses(className/*, ... */) {
if (argLength > 1) {
for (var ii = 1; ii < argLength; ii++) {
nextClass = arguments[ii];
- nextClass && (className += ' ' + nextClass);
+ if (nextClass) {
+ className = (className ? className + ' ' : '') + nextClass;
+ }
}
}
return className;
@@ -18943,21 +18875,14 @@ function joinClasses(className/*, ... */) {
module.exports = joinClasses;
-},{}],140:[function(_dereq_,module,exports){
+},{}],146:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 keyMirror
* @typechecks static-only
@@ -19003,21 +18928,14 @@ var keyMirror = function(obj) {
module.exports = keyMirror;
-},{"./invariant":134}],141:[function(_dereq_,module,exports){
+},{"./invariant":140}],147:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 keyOf
*/
@@ -19046,75 +18964,67 @@ var keyOf = function(oneKeyObj) {
module.exports = keyOf;
-},{}],142:[function(_dereq_,module,exports){
+},{}],148:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 mapObject
*/
-"use strict";
+'use strict';
+
+var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
- * For each key/value pair, invokes callback func and constructs a resulting
- * object which contains, for every key in obj, values that are the result of
- * of invoking the function:
+ * Executes the provided `callback` once for each enumerable own property in the
+ * object and constructs a new object from the results. The `callback` is
+ * invoked with three arguments:
*
- * func(value, key, iteration)
+ * - the property value
+ * - the property name
+ * - the object being traversed
*
- * Grepable names:
+ * Properties that are added after the call to `mapObject` will not be visited
+ * by `callback`. If the values of existing properties are changed, the value
+ * passed to `callback` will be the value at the time `mapObject` visits them.
+ * Properties that are deleted before being visited are not visited.
*
- * function objectMap()
- * function objMap()
+ * @grep function objectMap()
+ * @grep function objMap()
*
- * @param {?object} obj Object to map keys over
- * @param {function} func Invoked for each key/val pair.
- * @param {?*} context
- * @return {?object} Result of mapping or null if obj is falsey
+ * @param {?object} object
+ * @param {function} callback
+ * @param {*} context
+ * @return {?object}
*/
-function mapObject(obj, func, context) {
- if (!obj) {
+function mapObject(object, callback, context) {
+ if (!object) {
return null;
}
- var i = 0;
- var ret = {};
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- ret[key] = func.call(context, obj[key], key, i++);
+ var result = {};
+ for (var name in object) {
+ if (hasOwnProperty.call(object, name)) {
+ result[name] = callback.call(context, object[name], name, object);
}
}
- return ret;
+ return result;
}
module.exports = mapObject;
-},{}],143:[function(_dereq_,module,exports){
+},{}],149:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 memoizeStringOnly
* @typechecks static-only
@@ -19141,293 +19051,14 @@ function memoizeStringOnly(callback) {
module.exports = memoizeStringOnly;
-},{}],144:[function(_dereq_,module,exports){
-/**
- * Copyright 2013-2014 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 merge
- */
-
-"use strict";
-
-var mergeInto = _dereq_("./mergeInto");
-
-/**
- * Shallow merges two structures into a return value, without mutating either.
- *
- * @param {?object} one Optional object with properties to merge from.
- * @param {?object} two Optional object with properties to merge from.
- * @return {object} The shallow extension of one by two.
- */
-var merge = function(one, two) {
- var result = {};
- mergeInto(result, one);
- mergeInto(result, two);
- return result;
-};
-
-module.exports = merge;
-
-},{"./mergeInto":146}],145:[function(_dereq_,module,exports){
-/**
- * Copyright 2013-2014 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 mergeHelpers
- *
- * requiresPolyfills: Array.isArray
- */
-
-"use strict";
-
-var invariant = _dereq_("./invariant");
-var keyMirror = _dereq_("./keyMirror");
-
+},{}],150:[function(_dereq_,module,exports){
/**
- * Maximum number of levels to traverse. Will catch circular structures.
- * @const
- */
-var MAX_MERGE_DEPTH = 36;
-
-/**
- * We won't worry about edge cases like new String('x') or new Boolean(true).
- * Functions are considered terminals, and arrays are not.
- * @param {*} o The item/object/value to test.
- * @return {boolean} true iff the argument is a terminal.
- */
-var isTerminal = function(o) {
- return typeof o !== 'object' || o === null;
-};
-
-var mergeHelpers = {
-
- MAX_MERGE_DEPTH: MAX_MERGE_DEPTH,
-
- isTerminal: isTerminal,
-
- /**
- * Converts null/undefined values into empty object.
- *
- * @param {?Object=} arg Argument to be normalized (nullable optional)
- * @return {!Object}
- */
- normalizeMergeArg: function(arg) {
- return arg === undefined || arg === null ? {} : arg;
- },
-
- /**
- * If merging Arrays, a merge strategy *must* be supplied. If not, it is
- * likely the caller's fault. If this function is ever called with anything
- * but `one` and `two` being `Array`s, it is the fault of the merge utilities.
- *
- * @param {*} one Array to merge into.
- * @param {*} two Array to merge from.
- */
- checkMergeArrayArgs: function(one, two) {
- ("production" !== "development" ? invariant(
- Array.isArray(one) && Array.isArray(two),
- 'Tried to merge arrays, instead got %s and %s.',
- one,
- two
- ) : invariant(Array.isArray(one) && Array.isArray(two)));
- },
-
- /**
- * @param {*} one Object to merge into.
- * @param {*} two Object to merge from.
- */
- checkMergeObjectArgs: function(one, two) {
- mergeHelpers.checkMergeObjectArg(one);
- mergeHelpers.checkMergeObjectArg(two);
- },
-
- /**
- * @param {*} arg
- */
- checkMergeObjectArg: function(arg) {
- ("production" !== "development" ? invariant(
- !isTerminal(arg) && !Array.isArray(arg),
- 'Tried to merge an object, instead got %s.',
- arg
- ) : invariant(!isTerminal(arg) && !Array.isArray(arg)));
- },
-
- /**
- * @param {*} arg
- */
- checkMergeIntoObjectArg: function(arg) {
- ("production" !== "development" ? invariant(
- (!isTerminal(arg) || typeof arg === 'function') && !Array.isArray(arg),
- 'Tried to merge into an object, instead got %s.',
- arg
- ) : invariant((!isTerminal(arg) || typeof arg === 'function') && !Array.isArray(arg)));
- },
-
- /**
- * Checks that a merge was not given a circular object or an object that had
- * too great of depth.
- *
- * @param {number} Level of recursion to validate against maximum.
- */
- checkMergeLevel: function(level) {
- ("production" !== "development" ? invariant(
- level < MAX_MERGE_DEPTH,
- 'Maximum deep merge depth exceeded. You may be attempting to merge ' +
- 'circular structures in an unsupported way.'
- ) : invariant(level < MAX_MERGE_DEPTH));
- },
-
- /**
- * Checks that the supplied merge strategy is valid.
- *
- * @param {string} Array merge strategy.
- */
- checkArrayStrategy: function(strategy) {
- ("production" !== "development" ? invariant(
- strategy === undefined || strategy in mergeHelpers.ArrayStrategies,
- 'You must provide an array strategy to deep merge functions to ' +
- 'instruct the deep merge how to resolve merging two arrays.'
- ) : invariant(strategy === undefined || strategy in mergeHelpers.ArrayStrategies));
- },
-
- /**
- * Set of possible behaviors of merge algorithms when encountering two Arrays
- * that must be merged together.
- * - `clobber`: The left `Array` is ignored.
- * - `indexByIndex`: The result is achieved by recursively deep merging at
- * each index. (not yet supported.)
- */
- ArrayStrategies: keyMirror({
- Clobber: true,
- IndexByIndex: true
- })
-
-};
-
-module.exports = mergeHelpers;
-
-},{"./invariant":134,"./keyMirror":140}],146:[function(_dereq_,module,exports){
-/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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 mergeInto
- * @typechecks static-only
- */
-
-"use strict";
-
-var mergeHelpers = _dereq_("./mergeHelpers");
-
-var checkMergeObjectArg = mergeHelpers.checkMergeObjectArg;
-var checkMergeIntoObjectArg = mergeHelpers.checkMergeIntoObjectArg;
-
-/**
- * Shallow merges two structures by mutating the first parameter.
- *
- * @param {object|function} one Object to be merged into.
- * @param {?object} two Optional object with properties to merge from.
- */
-function mergeInto(one, two) {
- checkMergeIntoObjectArg(one);
- if (two != null) {
- checkMergeObjectArg(two);
- for (var key in two) {
- if (!two.hasOwnProperty(key)) {
- continue;
- }
- one[key] = two[key];
- }
- }
-}
-
-module.exports = mergeInto;
-
-},{"./mergeHelpers":145}],147:[function(_dereq_,module,exports){
-/**
- * Copyright 2013-2014 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 mixInto
- */
-
-"use strict";
-
-/**
- * Simply copies properties to the prototype.
- */
-var mixInto = function(constructor, methodBag) {
- var methodName;
- for (methodName in methodBag) {
- if (!methodBag.hasOwnProperty(methodName)) {
- continue;
- }
- constructor.prototype[methodName] = methodBag[methodName];
- }
-};
-
-module.exports = mixInto;
-
-},{}],148:[function(_dereq_,module,exports){
-/**
- * Copyright 2014 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.
+ * 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 monitorCodeUse
*/
@@ -19452,27 +19083,20 @@ function monitorCodeUse(eventName, data) {
module.exports = monitorCodeUse;
-},{"./invariant":134}],149:[function(_dereq_,module,exports){
+},{"./invariant":140}],151:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 onlyChild
*/
"use strict";
-var ReactDescriptor = _dereq_("./ReactDescriptor");
+var ReactElement = _dereq_("./ReactElement");
var invariant = _dereq_("./invariant");
@@ -19489,29 +19113,22 @@ var invariant = _dereq_("./invariant");
*/
function onlyChild(children) {
("production" !== "development" ? invariant(
- ReactDescriptor.isValidDescriptor(children),
+ ReactElement.isValidElement(children),
'onlyChild must be passed a children with exactly one child.'
- ) : invariant(ReactDescriptor.isValidDescriptor(children)));
+ ) : invariant(ReactElement.isValidElement(children)));
return children;
}
module.exports = onlyChild;
-},{"./ReactDescriptor":56,"./invariant":134}],150:[function(_dereq_,module,exports){
+},{"./ReactElement":58,"./invariant":140}],152:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 performance
* @typechecks
@@ -19532,21 +19149,14 @@ if (ExecutionEnvironment.canUseDOM) {
module.exports = performance || {};
-},{"./ExecutionEnvironment":22}],151:[function(_dereq_,module,exports){
+},{"./ExecutionEnvironment":23}],153:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 performanceNow
* @typechecks
@@ -19567,21 +19177,14 @@ var performanceNow = performance.now.bind(performance);
module.exports = performanceNow;
-},{"./performance":150}],152:[function(_dereq_,module,exports){
+},{"./performance":152}],154:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 setInnerHTML
*/
@@ -19590,6 +19193,9 @@ module.exports = performanceNow;
var ExecutionEnvironment = _dereq_("./ExecutionEnvironment");
+var WHITESPACE_TEST = /^[ \r\n\t\f]/;
+var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
+
/**
* Set the innerHTML property of a node, ensuring that whitespace is preserved
* even in IE8.
@@ -19626,13 +19232,8 @@ if (ExecutionEnvironment.canUseDOM) {
// thin air on IE8, this only happens if there is no visible text
// in-front of the non-visible tags. Piggyback on the whitespace fix
// and simply check if any non-visible tags appear in the source.
- if (html.match(/^[ \r\n\t\f]/) ||
- html[0] === '<' && (
- html.indexOf('<noscript') !== -1 ||
- html.indexOf('<script') !== -1 ||
- html.indexOf('<style') !== -1 ||
- html.indexOf('<meta') !== -1 ||
- html.indexOf('<link') !== -1)) {
+ if (WHITESPACE_TEST.test(html) ||
+ html[0] === '<' && NONVISIBLE_TEST.test(html)) {
// Recover leading whitespace by temporarily prepending any character.
// \uFEFF has the potential advantage of being zero-width/invisible.
node.innerHTML = '\uFEFF' + html;
@@ -19654,21 +19255,14 @@ if (ExecutionEnvironment.canUseDOM) {
module.exports = setInnerHTML;
-},{"./ExecutionEnvironment":22}],153:[function(_dereq_,module,exports){
+},{"./ExecutionEnvironment":23}],155:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 shallowEqual
*/
@@ -19694,7 +19288,7 @@ function shallowEqual(objA, objB) {
return false;
}
}
- // Test for B'a keys missing from A.
+ // Test for B's keys missing from A.
for (key in objB) {
if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) {
return false;
@@ -19705,21 +19299,14 @@ function shallowEqual(objA, objB) {
module.exports = shallowEqual;
-},{}],154:[function(_dereq_,module,exports){
+},{}],156:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 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
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 shouldUpdateReactComponent
* @typechecks static-only
@@ -19728,22 +19315,21 @@ module.exports = shallowEqual;
"use strict";
/**
- * Given a `prevDescriptor` and `nextDescriptor`, determines if the existing
+ * Given a `prevElement` and `nextElement`, determines if the existing
* instance should be updated as opposed to being destroyed or replaced by a new
- * instance. Both arguments are descriptors. This ensures that this logic can
+ * instance. Both arguments are elements. This ensures that this logic can
* operate on stateless trees without any backing instance.
*
- * @param {?object} prevDescriptor
- * @param {?object} nextDescriptor
+ * @param {?object} prevElement
+ * @param {?object} nextElement
* @return {boolean} True if the existing instance should be updated.
* @protected
*/
-function shouldUpdateReactComponent(prevDescriptor, nextDescriptor) {
- if (prevDescriptor && nextDescriptor &&
- prevDescriptor.type === nextDescriptor.type && (
- (prevDescriptor.props && prevDescriptor.props.key) ===
- (nextDescriptor.props && nextDescriptor.props.key)
- ) && prevDescriptor._owner === nextDescriptor._owner) {
+function shouldUpdateReactComponent(prevElement, nextElement) {
+ if (prevElement && nextElement &&
+ prevElement.type === nextElement.type &&
+ prevElement.key === nextElement.key &&
+ prevElement._owner === nextElement._owner) {
return true;
}
return false;
@@ -19751,21 +19337,14 @@ function shouldUpdateReactComponent(prevDescriptor, nextDescriptor) {
module.exports = shouldUpdateReactComponent;
-},{}],155:[function(_dereq_,module,exports){
+},{}],157:[function(_dereq_,module,exports){
/**
- * Copyright 2014 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
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 toArray
* @typechecks
@@ -19828,29 +19407,22 @@ function toArray(obj) {
module.exports = toArray;
-},{"./invariant":134}],156:[function(_dereq_,module,exports){
+},{"./invariant":140}],158:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 traverseAllChildren
*/
"use strict";
+var ReactElement = _dereq_("./ReactElement");
var ReactInstanceHandles = _dereq_("./ReactInstanceHandles");
-var ReactTextComponent = _dereq_("./ReactTextComponent");
var invariant = _dereq_("./invariant");
@@ -19885,9 +19457,9 @@ function userProvidedKeyEscaper(match) {
* @return {string}
*/
function getComponentKey(component, index) {
- if (component && component.props && component.props.key != null) {
+ if (component && component.key != null) {
// Explicit key
- return wrapUserProvidedKey(component.props.key);
+ return wrapUserProvidedKey(component.key);
}
// Implicit key determined by the index in the set
return index.toString(36);
@@ -19928,16 +19500,17 @@ function wrapUserProvidedKey(key) {
*/
var traverseAllChildrenImpl =
function(children, nameSoFar, indexSoFar, callback, traverseContext) {
+ var nextName, nextIndex;
var subtreeCount = 0; // Count of children found in the current subtree.
if (Array.isArray(children)) {
for (var i = 0; i < children.length; i++) {
var child = children[i];
- var nextName = (
+ nextName = (
nameSoFar +
(nameSoFar ? SUBSEPARATOR : SEPARATOR) +
getComponentKey(child, i)
);
- var nextIndex = indexSoFar + subtreeCount;
+ nextIndex = indexSoFar + subtreeCount;
subtreeCount += traverseAllChildrenImpl(
child,
nextName,
@@ -19957,40 +19530,32 @@ var traverseAllChildrenImpl =
// All of the above are perceived as null.
callback(traverseContext, null, storageName, indexSoFar);
subtreeCount = 1;
- } else if (children.type && children.type.prototype &&
- children.type.prototype.mountComponentIntoNode) {
+ } else if (type === 'string' || type === 'number' ||
+ ReactElement.isValidElement(children)) {
callback(traverseContext, children, storageName, indexSoFar);
subtreeCount = 1;
- } else {
- if (type === 'object') {
- ("production" !== "development" ? invariant(
- !children || children.nodeType !== 1,
- 'traverseAllChildren(...): Encountered an invalid child; DOM ' +
- 'elements are not valid children of React components.'
- ) : invariant(!children || children.nodeType !== 1));
- for (var key in children) {
- if (children.hasOwnProperty(key)) {
- subtreeCount += traverseAllChildrenImpl(
- children[key],
- (
- nameSoFar + (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
- wrapUserProvidedKey(key) + SUBSEPARATOR +
- getComponentKey(children[key], 0)
- ),
- indexSoFar + subtreeCount,
- callback,
- traverseContext
- );
- }
+ } else if (type === 'object') {
+ ("production" !== "development" ? invariant(
+ !children || children.nodeType !== 1,
+ 'traverseAllChildren(...): Encountered an invalid child; DOM ' +
+ 'elements are not valid children of React components.'
+ ) : invariant(!children || children.nodeType !== 1));
+ for (var key in children) {
+ if (children.hasOwnProperty(key)) {
+ nextName = (
+ nameSoFar + (nameSoFar ? SUBSEPARATOR : SEPARATOR) +
+ wrapUserProvidedKey(key) + SUBSEPARATOR +
+ getComponentKey(children[key], 0)
+ );
+ nextIndex = indexSoFar + subtreeCount;
+ subtreeCount += traverseAllChildrenImpl(
+ children[key],
+ nextName,
+ nextIndex,
+ callback,
+ traverseContext
+ );
}
- } else if (type === 'string') {
- var normalizedText = ReactTextComponent(children);
- callback(traverseContext, normalizedText, storageName, indexSoFar);
- subtreeCount += 1;
- } else if (type === 'number') {
- var normalizedNumber = ReactTextComponent('' + children);
- callback(traverseContext, normalizedNumber, storageName, indexSoFar);
- subtreeCount += 1;
}
}
}
@@ -20023,28 +19588,21 @@ function traverseAllChildren(children, callback, traverseContext) {
module.exports = traverseAllChildren;
-},{"./ReactInstanceHandles":64,"./ReactTextComponent":83,"./invariant":134}],157:[function(_dereq_,module,exports){
+},{"./ReactElement":58,"./ReactInstanceHandles":66,"./invariant":140}],159:[function(_dereq_,module,exports){
/**
- * Copyright 2013-2014 Facebook, Inc.
+ * Copyright 2013-2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 update
*/
"use strict";
-var copyProperties = _dereq_("./copyProperties");
+var assign = _dereq_("./Object.assign");
var keyOf = _dereq_("./keyOf");
var invariant = _dereq_("./invariant");
@@ -20052,7 +19610,7 @@ function shallowCopy(x) {
if (Array.isArray(x)) {
return x.concat();
} else if (x && typeof x === 'object') {
- return copyProperties(new x.constructor(), x);
+ return assign(new x.constructor(), x);
} else {
return x;
}
@@ -20132,7 +19690,7 @@ function update(value, spec) {
COMMAND_MERGE,
nextValue
) : invariant(nextValue && typeof nextValue === 'object'));
- copyProperties(nextValue, spec[COMMAND_MERGE]);
+ assign(nextValue, spec[COMMAND_MERGE]);
}
if (spec.hasOwnProperty(COMMAND_PUSH)) {
@@ -20196,21 +19754,14 @@ function update(value, spec) {
module.exports = update;
-},{"./copyProperties":110,"./invariant":134,"./keyOf":141}],158:[function(_dereq_,module,exports){
+},{"./Object.assign":29,"./invariant":140,"./keyOf":147}],160:[function(_dereq_,module,exports){
/**
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2014, Facebook, Inc.
+ * All rights reserved.
*
- * 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.
+ * 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 warning
*/
@@ -20229,7 +19780,7 @@ var emptyFunction = _dereq_("./emptyFunction");
var warning = emptyFunction;
if ("production" !== "development") {
- warning = function(condition, format ) {var args=Array.prototype.slice.call(arguments,2);
+ warning = function(condition, format ) {for (var args=[],$__0=2,$__1=arguments.length;$__0<$__1;$__0++) args.push(arguments[$__0]);
if (format === undefined) {
throw new Error(
'`warning(condition, format, ...args)` requires a warning ' +
@@ -20246,6 +19797,5 @@ if ("production" !== "development") {
module.exports = warning;
-},{"./emptyFunction":116}]},{},[88])
-(88)
+},{"./emptyFunction":121}]},{},[1])(1)
}); \ No newline at end of file