aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/certinstall.rst12
-rw-r--r--docs/features/reverseproxy.rst5
-rw-r--r--examples/complex/dns_spoofing.py11
-rw-r--r--mitmproxy/options.py2
-rw-r--r--mitmproxy/proxy/protocol/http.py4
-rw-r--r--mitmproxy/tools/cmdline.py6
-rw-r--r--mitmproxy/tools/web/app.py1
-rw-r--r--mitmproxy/tools/web/static/app.css10
-rw-r--r--mitmproxy/tools/web/static/app.js697
-rw-r--r--mitmproxy/tools/web/static/vendor.css3
-rw-r--r--mitmproxy/tools/web/static/vendor.js34861
-rw-r--r--release/README.md2
-rw-r--r--test/mitmproxy/proxy/test_server.py20
-rw-r--r--test/mitmproxy/test_examples.py2
-rw-r--r--web/src/css/flowdetail.less3
-rw-r--r--web/src/css/header.less7
-rw-r--r--web/src/js/components/Header/FilterDocs.jsx2
-rw-r--r--web/src/js/components/Header/FilterInput.jsx8
-rw-r--r--web/src/js/flow/utils.js6
19 files changed, 18916 insertions, 16746 deletions
diff --git a/docs/certinstall.rst b/docs/certinstall.rst
index 5d97e92c..1bd6df99 100644
--- a/docs/certinstall.rst
+++ b/docs/certinstall.rst
@@ -42,7 +42,7 @@ iOS
See http://jasdev.me/intercepting-ios-traffic
-and http://web.archive.org/web/20150920082614/http://kb.mit.edu/confluence/pages/viewpage.action?pageId=152600377
+and https://web.archive.org/web/20150920082614/http://kb.mit.edu/confluence/pages/viewpage.action?pageId=152600377
iOS Simulator
^^^^^^^^^^^^^
@@ -52,7 +52,7 @@ See https://github.com/ADVTOOLS/ADVTrustStore#how-to-use-advtruststore
Java
^^^^
-See http://docs.oracle.com/cd/E19906-01/820-4916/geygn/index.html
+See https://docs.oracle.com/cd/E19906-01/820-4916/geygn/index.html
Android/Android Simulator
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -62,7 +62,7 @@ See http://wiki.cacert.org/FAQ/ImportRootCert#Android_Phones_.26_Tablets
Windows
^^^^^^^
-See http://windows.microsoft.com/en-ca/windows/import-export-certificates-private-keys#1TC=windows-7
+See https://web.archive.org/web/20160612045445/http://windows.microsoft.com/en-ca/windows/import-export-certificates-private-keys#1TC=windows-7
Windows (automated)
^^^^^^^^^^^^^^^^^^^
@@ -79,7 +79,7 @@ See https://support.apple.com/kb/PH7297?locale=en_US
Ubuntu/Debian
^^^^^^^^^^^^^
-See http://askubuntu.com/questions/73287/how-do-i-install-a-root-certificate/94861#94861
+See https://askubuntu.com/questions/73287/how-do-i-install-a-root-certificate/94861#94861
Mozilla Firefox
^^^^^^^^^^^^^^^
@@ -89,7 +89,7 @@ See https://wiki.mozilla.org/MozillaRootCertificate#Mozilla_Firefox
Chrome on Linux
^^^^^^^^^^^^^^^
-See https://code.google.com/p/chromium/wiki/LinuxCertManagement
+See https://stackoverflow.com/a/15076602/198996
The mitmproxy certificate authority
@@ -205,4 +205,4 @@ directory and uses this as the client cert.
-.. _Certificate Pinning: http://security.stackexchange.com/questions/29988/what-is-certificate-pinning/
+.. _Certificate Pinning: https://security.stackexchange.com/questions/29988/what-is-certificate-pinning/
diff --git a/docs/features/reverseproxy.rst b/docs/features/reverseproxy.rst
index 85ad33e8..57b353ae 100644
--- a/docs/features/reverseproxy.rst
+++ b/docs/features/reverseproxy.rst
@@ -31,7 +31,8 @@ Host Header
In reverse proxy mode, mitmproxy automatically rewrites the Host header to match the
upstream server. This allows mitmproxy to easily connect to existing endpoints on the
-open web (e.g. ``mitmproxy -R https://example.com``).
+open web (e.g. ``mitmproxy -R https://example.com``). You can disable this behaviour
+by passing ``--keep-host-header`` on the console.
However, keep in mind that absolute URLs within the returned document or HTTP redirects will
NOT be rewritten by mitmproxy. This means that if you click on a link for "http://example.com"
@@ -39,4 +40,4 @@ in the returned web page, you will be taken directly to that URL, bypassing mitm
One possible way to address this is to modify the hosts file of your OS so that "example.com"
resolves to your proxy's IP, and then access the proxy by going directly to example.com.
-Make sure that your proxy can still resolve the original IP, or specify an IP in mitmproxy. \ No newline at end of file
+Make sure that your proxy can still resolve the original IP, or specify an IP in mitmproxy.
diff --git a/examples/complex/dns_spoofing.py b/examples/complex/dns_spoofing.py
index acda303d..2fd6b699 100644
--- a/examples/complex/dns_spoofing.py
+++ b/examples/complex/dns_spoofing.py
@@ -13,6 +13,8 @@ Usage:
-s dns_spoofing.py
# Used as the target location if neither SNI nor host header are present.
-R http://example.com/
+ # To avoid auto rewriting of host header by the reverse proxy target.
+ --keep-host-header
mitmdump
-p 80
-R http://localhost:443/
@@ -29,13 +31,6 @@ parse_host_header = re.compile(r"^(?P<host>[^:]+|\[.+\])(?::(?P<port>\d+))?$")
class Rerouter:
- def requestheaders(self, flow):
- """
- The original host header is retrieved early
- before flow.request is replaced by mitmproxy new outgoing request
- """
- flow.metadata["original_host"] = flow.request.host_header
-
def request(self, flow):
if flow.client_conn.ssl_established:
flow.request.scheme = "https"
@@ -46,7 +41,7 @@ class Rerouter:
sni = None
port = 80
- host_header = flow.metadata["original_host"]
+ host_header = flow.request.host_header
m = parse_host_header.match(host_header)
if m:
host_header = m.group("host").strip("[]")
diff --git a/mitmproxy/options.py b/mitmproxy/options.py
index 2467b9dd..ff17fbbf 100644
--- a/mitmproxy/options.py
+++ b/mitmproxy/options.py
@@ -72,6 +72,7 @@ class Options(optmanager.OptManager):
upstream_bind_address: str = "",
mode: str = "regular",
no_upstream_cert: bool = False,
+ keep_host_header: bool = False,
http2: bool = True,
http2_priority: bool = False,
@@ -162,6 +163,7 @@ class Options(optmanager.OptManager):
self.upstream_bind_address = upstream_bind_address
self.mode = mode
self.no_upstream_cert = no_upstream_cert
+ self.keep_host_header = keep_host_header
self.http2 = http2
self.http2_priority = http2_priority
diff --git a/mitmproxy/proxy/protocol/http.py b/mitmproxy/proxy/protocol/http.py
index 16d04eeb..d2f6d374 100644
--- a/mitmproxy/proxy/protocol/http.py
+++ b/mitmproxy/proxy/protocol/http.py
@@ -276,6 +276,8 @@ class HttpLayer(base.Layer):
# We optimistically guess there might be an HTTP client on the
# other end
self.send_error_response(400, repr(e))
+ f.error = flow.Error(str(e))
+ self.channel.ask("error", f)
raise exceptions.ProtocolException(
"HTTP protocol error in client request: {}".format(e)
)
@@ -288,7 +290,7 @@ class HttpLayer(base.Layer):
request.first_line_format = "relative"
# update host header in reverse proxy mode
- if self.config.options.mode == "reverse":
+ if self.config.options.mode == "reverse" and not self.config.options.keep_host_header:
f.request.host_header = self.config.upstream_server.address[0]
# Determine .scheme, .host and .port attributes for inline scripts. For
diff --git a/mitmproxy/tools/cmdline.py b/mitmproxy/tools/cmdline.py
index bb0bb17a..11558cc3 100644
--- a/mitmproxy/tools/cmdline.py
+++ b/mitmproxy/tools/cmdline.py
@@ -112,6 +112,7 @@ def get_common_options(args):
replacements=args.replacements,
replacement_files=args.replacement_files,
setheaders=args.setheaders,
+ keep_host_header=args.keep_host_header,
server_replay=args.server_replay,
scripts=args.scripts,
stickycookie=stickycookie,
@@ -387,6 +388,11 @@ def proxy_options(parser):
action="store", type=str, dest="upstream_bind_address",
help="Address to bind upstream requests to (defaults to none)"
)
+ group.add_argument(
+ "--keep-host-header",
+ action="store_true", dest="keep_host_header",
+ help="Reverse Proxy: Keep the original host header instead of rewriting it to the reverse proxy target."
+ )
def proxy_ssl_options(parser):
diff --git a/mitmproxy/tools/web/app.py b/mitmproxy/tools/web/app.py
index 893c3dde..35b549ee 100644
--- a/mitmproxy/tools/web/app.py
+++ b/mitmproxy/tools/web/app.py
@@ -65,6 +65,7 @@ def flow_to_json(flow: mitmproxy.flow.Flow) -> dict:
"timestamp_start": flow.request.timestamp_start,
"timestamp_end": flow.request.timestamp_end,
"is_replay": flow.request.is_replay,
+ "pretty_host": flow.request.pretty_host,
}
if flow.response:
if flow.response.raw_content:
diff --git a/mitmproxy/tools/web/static/app.css b/mitmproxy/tools/web/static/app.css
index 9b44ea9a..09043a0b 100644
--- a/mitmproxy/tools/web/static/app.css
+++ b/mitmproxy/tools/web/static/app.css
@@ -773,9 +773,6 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
display: inline-block;
vertical-align: top;
margin-bottom: -30px;
- /* Hack to make IE7 behave */
- *zoom:1;
- *display:inline;
}
.CodeMirror-gutter-wrapper {
position: absolute;
@@ -819,8 +816,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
+ -webkit-font-variant-ligatures: contextual;
+ font-variant-ligatures: contextual;
}
.CodeMirror-wrap pre {
word-wrap: break-word;
@@ -894,9 +891,6 @@ div.CodeMirror-dragcursors {
background: rgba(255, 255, 0, .4);
}
-/* IE7 hack to prevent it from returning funny offsetTops on the spans */
-.CodeMirror span { *vertical-align: text-bottom; }
-
/* Used to force a border model for a node */
.cm-force-border { padding-right: .1px; }
diff --git a/mitmproxy/tools/web/static/app.js b/mitmproxy/tools/web/static/app.js
index c21a478b..22692876 100644
--- a/mitmproxy/tools/web/static/app.js
+++ b/mitmproxy/tools/web/static/app.js
@@ -1,6 +1,5 @@
(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(require,module,exports){
// shim for using process in browser
-
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
@@ -11,22 +10,84 @@ var process = module.exports = {};
var cachedSetTimeout;
var cachedClearTimeout;
+function defaultSetTimout() {
+ throw new Error('setTimeout has not been defined');
+}
+function defaultClearTimeout () {
+ throw new Error('clearTimeout has not been defined');
+}
(function () {
- try {
- cachedSetTimeout = setTimeout;
- } catch (e) {
- cachedSetTimeout = function () {
- throw new Error('setTimeout is not defined');
+ try {
+ if (typeof setTimeout === 'function') {
+ cachedSetTimeout = setTimeout;
+ } else {
+ cachedSetTimeout = defaultSetTimout;
+ }
+ } catch (e) {
+ cachedSetTimeout = defaultSetTimout;
}
- }
- try {
- cachedClearTimeout = clearTimeout;
- } catch (e) {
- cachedClearTimeout = function () {
- throw new Error('clearTimeout is not defined');
+ try {
+ if (typeof clearTimeout === 'function') {
+ cachedClearTimeout = clearTimeout;
+ } else {
+ cachedClearTimeout = defaultClearTimeout;
+ }
+ } catch (e) {
+ cachedClearTimeout = defaultClearTimeout;
}
- }
} ())
+function runTimeout(fun) {
+ if (cachedSetTimeout === setTimeout) {
+ //normal enviroments in sane situations
+ return setTimeout(fun, 0);
+ }
+ // if setTimeout wasn't available but was latter defined
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
+ cachedSetTimeout = setTimeout;
+ return setTimeout(fun, 0);
+ }
+ try {
+ // when when somebody has screwed with setTimeout but no I.E. maddness
+ return cachedSetTimeout(fun, 0);
+ } catch(e){
+ try {
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
+ return cachedSetTimeout.call(null, fun, 0);
+ } catch(e){
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
+ return cachedSetTimeout.call(this, fun, 0);
+ }
+ }
+
+
+}
+function runClearTimeout(marker) {
+ if (cachedClearTimeout === clearTimeout) {
+ //normal enviroments in sane situations
+ return clearTimeout(marker);
+ }
+ // if clearTimeout wasn't available but was latter defined
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
+ cachedClearTimeout = clearTimeout;
+ return clearTimeout(marker);
+ }
+ try {
+ // when when somebody has screwed with setTimeout but no I.E. maddness
+ return cachedClearTimeout(marker);
+ } catch (e){
+ try {
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
+ return cachedClearTimeout.call(null, marker);
+ } catch (e){
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
+ // Some versions of I.E. have different rules for clearTimeout vs setTimeout
+ return cachedClearTimeout.call(this, marker);
+ }
+ }
+
+
+
+}
var queue = [];
var draining = false;
var currentQueue;
@@ -51,7 +112,7 @@ function drainQueue() {
if (draining) {
return;
}
- var timeout = cachedSetTimeout(cleanUpNextTick);
+ var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
@@ -68,7 +129,7 @@ function drainQueue() {
}
currentQueue = null;
draining = false;
- cachedClearTimeout(timeout);
+ runClearTimeout(timeout);
}
process.nextTick = function (fun) {
@@ -80,7 +141,7 @@ process.nextTick = function (fun) {
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
- cachedSetTimeout(drainQueue, 0);
+ runTimeout(drainQueue);
}
};
@@ -347,13 +408,13 @@ ContentView.isContentTooLarge = function (msg) {
};
function ContentView(props) {
- var flow = props.flow;
- var message = props.message;
- var contentView = props.contentView;
- var isDisplayLarge = props.isDisplayLarge;
- var displayLarge = props.displayLarge;
- var onContentChange = props.onContentChange;
- var readonly = props.readonly;
+ var flow = props.flow,
+ message = props.message,
+ contentView = props.contentView,
+ isDisplayLarge = props.isDisplayLarge,
+ displayLarge = props.displayLarge,
+ onContentChange = props.onContentChange,
+ readonly = props.readonly;
if (message.contentLength === 0 && readonly) {
@@ -411,8 +472,8 @@ CodeEditor.propTypes = {
};
function CodeEditor(_ref) {
- var content = _ref.content;
- var onChange = _ref.onChange;
+ var content = _ref.content,
+ onChange = _ref.onChange;
var options = {
@@ -461,7 +522,7 @@ exports.default = function (View) {
function _class(props) {
_classCallCheck(this, _class);
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(_class).call(this, props));
+ var _this = _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this, props));
_this.state = {
content: undefined,
@@ -589,11 +650,11 @@ ContentViewOptions.propTypes = {
};
function ContentViewOptions(_ref) {
- var flow = _ref.flow;
- var message = _ref.message;
- var uploadContent = _ref.uploadContent;
- var readonly = _ref.readonly;
- var contentViewDescription = _ref.contentViewDescription;
+ var flow = _ref.flow,
+ message = _ref.message,
+ uploadContent = _ref.uploadContent,
+ readonly = _ref.readonly,
+ contentViewDescription = _ref.contentViewDescription;
return _react2.default.createElement(
'div',
@@ -608,11 +669,11 @@ function ContentViewOptions(_ref) {
),
' edit'
),
- ' ',
+ '\xA0',
_react2.default.createElement(_DownloadContentButton2.default, { flow: flow, message: message }),
- ' ',
+ '\xA0',
!readonly && _react2.default.createElement(_UploadContentButton2.default, { uploadContent: uploadContent }),
- ' ',
+ '\xA0',
readonly && _react2.default.createElement(
'span',
null,
@@ -675,8 +736,8 @@ ViewImage.propTypes = {
message: _react.PropTypes.object.isRequired
};
function ViewImage(_ref) {
- var flow = _ref.flow;
- var message = _ref.message;
+ var flow = _ref.flow,
+ message = _ref.message;
return _react2.default.createElement(
'div',
@@ -690,8 +751,8 @@ Edit.propTypes = {
};
function Edit(_ref2) {
- var content = _ref2.content;
- var onChange = _ref2.onChange;
+ var content = _ref2.content,
+ onChange = _ref2.onChange;
return _react2.default.createElement(_CodeEditor2.default, { content: content, onChange: onChange });
}
@@ -703,7 +764,7 @@ var ViewServer = function (_Component) {
function ViewServer() {
_classCallCheck(this, ViewServer);
- return _possibleConstructorReturn(this, Object.getPrototypeOf(ViewServer).apply(this, arguments));
+ return _possibleConstructorReturn(this, (ViewServer.__proto__ || Object.getPrototypeOf(ViewServer)).apply(this, arguments));
}
_createClass(ViewServer, [{
@@ -733,11 +794,11 @@ var ViewServer = function (_Component) {
}, {
key: 'render',
value: function render() {
- var _props = this.props;
- var content = _props.content;
- var contentView = _props.contentView;
- var message = _props.message;
- var maxLines = _props.maxLines;
+ var _props = this.props,
+ content = _props.content,
+ contentView = _props.contentView,
+ message = _props.message,
+ maxLines = _props.maxLines;
var lines = this.props.showFullContent ? this.data.lines : this.data.lines.slice(0, maxLines);
return _react2.default.createElement(
@@ -752,10 +813,9 @@ var ViewServer = function (_Component) {
'div',
{ key: 'line' + i },
line.map(function (element, j) {
- var _element = _slicedToArray(element, 2);
-
- var style = _element[0];
- var text = _element[1];
+ var _element = _slicedToArray(element, 2),
+ style = _element[0],
+ text = _element[1];
return _react2.default.createElement(
'span',
@@ -813,8 +873,8 @@ DownloadContentButton.propTypes = {
};
function DownloadContentButton(_ref) {
- var flow = _ref.flow;
- var message = _ref.message;
+ var flow = _ref.flow,
+ message = _ref.message;
return React.createElement(
@@ -853,8 +913,8 @@ var _DownloadContentButton2 = _interopRequireDefault(_DownloadContentButton);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ContentEmpty(_ref) {
- var flow = _ref.flow;
- var message = _ref.message;
+ var flow = _ref.flow,
+ message = _ref.message;
return _react2.default.createElement(
'div',
@@ -866,8 +926,8 @@ function ContentEmpty(_ref) {
}
function ContentMissing(_ref2) {
- var flow = _ref2.flow;
- var message = _ref2.message;
+ var flow = _ref2.flow,
+ message = _ref2.message;
return _react2.default.createElement(
'div',
@@ -878,10 +938,10 @@ function ContentMissing(_ref2) {
}
function ContentTooLarge(_ref3) {
- var message = _ref3.message;
- var onClick = _ref3.onClick;
- var uploadContent = _ref3.uploadContent;
- var flow = _ref3.flow;
+ var message = _ref3.message,
+ onClick = _ref3.onClick,
+ uploadContent = _ref3.uploadContent,
+ flow = _ref3.flow;
return _react2.default.createElement(
'div',
@@ -901,7 +961,7 @@ function ContentTooLarge(_ref3) {
'div',
{ className: 'view-options text-center' },
_react2.default.createElement(_UploadContentButton2.default, { uploadContent: uploadContent }),
- ' ',
+ '\xA0',
_react2.default.createElement(_DownloadContentButton2.default, { flow: flow, message: message })
)
);
@@ -936,10 +996,10 @@ ShowFullContentButton.propTypes = {
};
function ShowFullContentButton(_ref) {
- var setShowFullContent = _ref.setShowFullContent;
- var showFullContent = _ref.showFullContent;
- var visibleLines = _ref.visibleLines;
- var contentLines = _ref.contentLines;
+ var setShowFullContent = _ref.setShowFullContent,
+ showFullContent = _ref.showFullContent,
+ visibleLines = _ref.visibleLines,
+ contentLines = _ref.contentLines;
return !showFullContent && _react2.default.createElement(
@@ -959,7 +1019,7 @@ function ShowFullContentButton(_ref) {
visibleLines,
'/',
contentLines,
- ' are visible   '
+ ' are visible \xA0 '
)
);
}
@@ -1034,9 +1094,9 @@ ViewSelector.propTypes = {
};
function ViewSelector(_ref) {
- var contentViews = _ref.contentViews;
- var activeView = _ref.activeView;
- var setContentView = _ref.setContentView;
+ var contentViews = _ref.contentViews,
+ activeView = _ref.activeView,
+ setContentView = _ref.setContentView;
var inner = _react2.default.createElement(
'span',
@@ -1117,7 +1177,7 @@ var EventLog = function (_Component) {
function EventLog(props, context) {
_classCallCheck(this, EventLog);
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(EventLog).call(this, props, context));
+ var _this = _possibleConstructorReturn(this, (EventLog.__proto__ || Object.getPrototypeOf(EventLog)).call(this, props, context));
_this.state = { height: _this.props.defaultHeight };
@@ -1152,11 +1212,11 @@ var EventLog = function (_Component) {
key: 'render',
value: function render() {
var height = this.state.height;
- var _props = this.props;
- var filters = _props.filters;
- var events = _props.events;
- var toggleFilter = _props.toggleFilter;
- var close = _props.close;
+ var _props = this.props,
+ filters = _props.filters,
+ events = _props.events,
+ toggleFilter = _props.toggleFilter,
+ close = _props.close;
return _react2.default.createElement(
@@ -1246,7 +1306,7 @@ var EventLogList = function (_Component) {
function EventLogList(props) {
_classCallCheck(this, EventLogList);
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(EventLogList).call(this, props));
+ var _this = _possibleConstructorReturn(this, (EventLogList.__proto__ || Object.getPrototypeOf(EventLogList)).call(this, props));
_this.heights = {};
_this.state = { vScroll: (0, _VirtualScroll.calcVScroll)() };
@@ -1405,7 +1465,7 @@ var FlowTable = function (_React$Component) {
function FlowTable(props, context) {
_classCallCheck(this, FlowTable);
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(FlowTable).call(this, props, context));
+ var _this = _possibleConstructorReturn(this, (FlowTable.__proto__ || Object.getPrototypeOf(FlowTable)).call(this, props, context));
_this.state = { vScroll: (0, _VirtualScroll.calcVScroll)() };
_this.onViewportUpdate = _this.onViewportUpdate.bind(_this);
@@ -1433,10 +1493,10 @@ var FlowTable = function (_React$Component) {
this.shouldScrollIntoView = false;
- var _props = this.props;
- var rowHeight = _props.rowHeight;
- var flows = _props.flows;
- var selected = _props.selected;
+ var _props = this.props,
+ rowHeight = _props.rowHeight,
+ flows = _props.flows,
+ selected = _props.selected;
var viewport = _reactDom2.default.findDOMNode(this);
var head = _reactDom2.default.findDOMNode(this.refs.head);
@@ -1485,13 +1545,13 @@ var FlowTable = function (_React$Component) {
value: function render() {
var _this2 = this;
- var _state = this.state;
- var vScroll = _state.vScroll;
- var viewportTop = _state.viewportTop;
- var _props2 = this.props;
- var flows = _props2.flows;
- var selected = _props2.selected;
- var highlight = _props2.highlight;
+ var _state = this.state,
+ vScroll = _state.vScroll,
+ viewportTop = _state.viewportTop;
+ var _props2 = this.props,
+ flows = _props2.flows,
+ selected = _props2.selected,
+ highlight = _props2.highlight;
var isHighlighted = highlight ? _filt2.default.parse(highlight) : function () {
return false;
@@ -1741,10 +1801,10 @@ FlowRow.propTypes = {
};
function FlowRow(_ref) {
- var flow = _ref.flow;
- var selected = _ref.selected;
- var highlighted = _ref.highlighted;
- var onSelect = _ref.onSelect;
+ var flow = _ref.flow,
+ selected = _ref.selected,
+ highlighted = _ref.highlighted,
+ onSelect = _ref.onSelect;
var className = (0, _classnames2.default)({
'selected': selected,
@@ -1799,9 +1859,9 @@ FlowTableHead.propTypes = {
};
function FlowTableHead(_ref) {
- var sortColumn = _ref.sortColumn;
- var sortDesc = _ref.sortDesc;
- var setSort = _ref.setSort;
+ var sortColumn = _ref.sortColumn,
+ sortDesc = _ref.sortDesc,
+ setSort = _ref.setSort;
var sortType = sortDesc ? 'sort-desc' : 'sort-asc';
@@ -1880,7 +1940,7 @@ var FlowView = function (_Component) {
function FlowView(props, context) {
_classCallCheck(this, FlowView);
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(FlowView).call(this, props, context));
+ var _this = _possibleConstructorReturn(this, (FlowView.__proto__ || Object.getPrototypeOf(FlowView)).call(this, props, context));
_this.onPromptFinish = _this.onPromptFinish.bind(_this);
return _this;
@@ -1919,10 +1979,10 @@ var FlowView = function (_Component) {
value: function render() {
var _this2 = this;
- var _props = this.props;
- var flow = _props.flow;
- var active = _props.tab;
- var updateFlow = _props.updateFlow;
+ var _props = this.props,
+ flow = _props.flow,
+ active = _props.tab,
+ updateFlow = _props.updateFlow;
var tabs = ['request', 'response', 'error'].filter(function (k) {
return flow[k];
@@ -1998,9 +2058,9 @@ var _utils = require('../../utils.js');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function TimeStamp(_ref) {
- var t = _ref.t;
- var deltaTo = _ref.deltaTo;
- var title = _ref.title;
+ var t = _ref.t,
+ deltaTo = _ref.deltaTo,
+ title = _ref.title;
return t ? _react2.default.createElement(
'tr',
@@ -2101,10 +2161,10 @@ function CertificateInfo(_ref3) {
function Timing(_ref4) {
var flow = _ref4.flow;
- var sc = flow.server_conn;
- var cc = flow.client_conn;
- var req = flow.request;
- var res = flow.response;
+ var sc = flow.server_conn,
+ cc = flow.client_conn,
+ req = flow.request,
+ res = flow.response;
var timestamps = [{
@@ -2234,7 +2294,7 @@ var HeaderEditor = function (_Component) {
function HeaderEditor(props) {
_classCallCheck(this, HeaderEditor);
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(HeaderEditor).call(this, props));
+ var _this = _possibleConstructorReturn(this, (HeaderEditor.__proto__ || Object.getPrototypeOf(HeaderEditor)).call(this, props));
_this.onKeyDown = _this.onKeyDown.bind(_this);
return _this;
@@ -2243,10 +2303,9 @@ var HeaderEditor = function (_Component) {
_createClass(HeaderEditor, [{
key: 'render',
value: function render() {
- var _props = this.props;
- var onTab = _props.onTab;
-
- var props = _objectWithoutProperties(_props, ['onTab']);
+ var _props = this.props,
+ onTab = _props.onTab,
+ props = _objectWithoutProperties(_props, ['onTab']);
return _react2.default.createElement(_ValueEditor2.default, _extends({}, props, {
onKeyDown: this.onKeyDown
@@ -2286,7 +2345,7 @@ var Headers = function (_Component2) {
function Headers() {
_classCallCheck(this, Headers);
- return _possibleConstructorReturn(this, Object.getPrototypeOf(Headers).apply(this, arguments));
+ return _possibleConstructorReturn(this, (Headers.__proto__ || Object.getPrototypeOf(Headers)).apply(this, arguments));
}
_createClass(Headers, [{
@@ -2362,9 +2421,9 @@ var Headers = function (_Component2) {
value: function render() {
var _this3 = this;
- var _props2 = this.props;
- var message = _props2.message;
- var readonly = _props2.readonly;
+ var _props2 = this.props,
+ message = _props2.message,
+ readonly = _props2.readonly;
return _react2.default.createElement(
@@ -2499,9 +2558,9 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function RequestLine(_ref) {
- var flow = _ref.flow;
- var readonly = _ref.readonly;
- var updateFlow = _ref.updateFlow;
+ var flow = _ref.flow,
+ readonly = _ref.readonly,
+ updateFlow = _ref.updateFlow;
return _react2.default.createElement(
'div',
@@ -2516,7 +2575,7 @@ function RequestLine(_ref) {
return updateFlow({ request: { method: method } });
}
}),
- ' ',
+ '\xA0',
_react2.default.createElement(_ValidateEditor2.default, {
content: _utils.RequestUtils.pretty_url(flow.request),
readonly: readonly,
@@ -2527,7 +2586,7 @@ function RequestLine(_ref) {
return !!(0, _utils.parseUrl)(url).host;
}
}),
- ' ',
+ '\xA0',
_react2.default.createElement(_ValidateEditor2.default, {
content: flow.request.http_version,
readonly: readonly,
@@ -2541,9 +2600,9 @@ function RequestLine(_ref) {
}
function ResponseLine(_ref2) {
- var flow = _ref2.flow;
- var readonly = _ref2.readonly;
- var updateFlow = _ref2.updateFlow;
+ var flow = _ref2.flow,
+ readonly = _ref2.readonly,
+ updateFlow = _ref2.updateFlow;
return _react2.default.createElement(
'div',
@@ -2556,7 +2615,7 @@ function ResponseLine(_ref2) {
},
isValid: _utils.isValidHttpVersion
}),
- ' ',
+ '\xA0',
_react2.default.createElement(_ValidateEditor2.default, {
content: flow.response.status_code + '',
readonly: readonly,
@@ -2568,7 +2627,7 @@ function ResponseLine(_ref2) {
);
}
}),
- ' ',
+ '\xA0',
_react2.default.createElement(_ValueEditor2.default, {
content: flow.response.reason,
readonly: readonly,
@@ -2595,17 +2654,17 @@ var Request = exports.Request = function (_Component) {
function Request() {
_classCallCheck(this, Request);
- return _possibleConstructorReturn(this, Object.getPrototypeOf(Request).apply(this, arguments));
+ return _possibleConstructorReturn(this, (Request.__proto__ || Object.getPrototypeOf(Request)).apply(this, arguments));
}
_createClass(Request, [{
key: 'render',
value: function render() {
- var _props = this.props;
- var flow = _props.flow;
- var isEdit = _props.isEdit;
- var updateFlow = _props.updateFlow;
- var _uploadContent = _props.uploadContent;
+ var _props = this.props,
+ flow = _props.flow,
+ isEdit = _props.isEdit,
+ updateFlow = _props.updateFlow,
+ _uploadContent = _props.uploadContent;
var noContent = !isEdit && (flow.request.contentLength == 0 || flow.request.contentLength == null);
return _react2.default.createElement(
@@ -2684,17 +2743,17 @@ var Response = exports.Response = function (_Component2) {
function Response() {
_classCallCheck(this, Response);
- return _possibleConstructorReturn(this, Object.getPrototypeOf(Response).apply(this, arguments));
+ return _possibleConstructorReturn(this, (Response.__proto__ || Object.getPrototypeOf(Response)).apply(this, arguments));
}
_createClass(Response, [{
key: 'render',
value: function render() {
- var _props2 = this.props;
- var flow = _props2.flow;
- var isEdit = _props2.isEdit;
- var updateFlow = _props2.updateFlow;
- var _uploadContent2 = _props2.uploadContent;
+ var _props2 = this.props,
+ flow = _props2.flow,
+ isEdit = _props2.isEdit,
+ updateFlow = _props2.updateFlow,
+ _uploadContent2 = _props2.uploadContent;
var noContent = !isEdit && (flow.response.contentLength == 0 || flow.response.contentLength == null);
@@ -2823,9 +2882,9 @@ NavAction.propTypes = {
};
function NavAction(_ref) {
- var icon = _ref.icon;
- var title = _ref.title;
- var _onClick = _ref.onClick;
+ var icon = _ref.icon,
+ title = _ref.title,
+ _onClick = _ref.onClick;
return _react2.default.createElement(
'a',
@@ -2847,9 +2906,9 @@ Nav.propTypes = {
};
function Nav(_ref2) {
- var active = _ref2.active;
- var tabs = _ref2.tabs;
- var onSelectTab = _ref2.onSelectTab;
+ var active = _ref2.active,
+ tabs = _ref2.tabs,
+ onSelectTab = _ref2.onSelectTab;
return _react2.default.createElement(
'nav',
@@ -2895,11 +2954,11 @@ ToggleEdit.propTypes = {
};
function ToggleEdit(_ref) {
- var isEdit = _ref.isEdit;
- var startEdit = _ref.startEdit;
- var stopEdit = _ref.stopEdit;
- var flow = _ref.flow;
- var modifiedFlow = _ref.modifiedFlow;
+ var isEdit = _ref.isEdit,
+ startEdit = _ref.startEdit,
+ stopEdit = _ref.stopEdit,
+ flow = _ref.flow,
+ modifiedFlow = _ref.modifiedFlow;
return _react2.default.createElement(
'div',
@@ -2954,21 +3013,21 @@ Footer.propTypes = {
function Footer(_ref) {
var settings = _ref.settings;
- var mode = settings.mode;
- var intercept = settings.intercept;
- var showhost = settings.showhost;
- var no_upstream_cert = settings.no_upstream_cert;
- var rawtcp = settings.rawtcp;
- var http2 = settings.http2;
- var websocket = settings.websocket;
- var anticache = settings.anticache;
- var anticomp = settings.anticomp;
- var stickyauth = settings.stickyauth;
- var stickycookie = settings.stickycookie;
- var stream_large_bodies = settings.stream_large_bodies;
- var listen_host = settings.listen_host;
- var listen_port = settings.listen_port;
- var version = settings.version;
+ var mode = settings.mode,
+ intercept = settings.intercept,
+ showhost = settings.showhost,
+ no_upstream_cert = settings.no_upstream_cert,
+ rawtcp = settings.rawtcp,
+ http2 = settings.http2,
+ websocket = settings.websocket,
+ anticache = settings.anticache,
+ anticomp = settings.anticomp,
+ stickyauth = settings.stickyauth,
+ stickycookie = settings.stickycookie,
+ stream_large_bodies = settings.stream_large_bodies,
+ listen_host = settings.listen_host,
+ listen_port = settings.listen_port,
+ version = settings.version;
return _react2.default.createElement(
'footer',
@@ -3117,7 +3176,7 @@ var Header = function (_Component) {
function Header() {
_classCallCheck(this, Header);
- return _possibleConstructorReturn(this, Object.getPrototypeOf(Header).apply(this, arguments));
+ return _possibleConstructorReturn(this, (Header.__proto__ || Object.getPrototypeOf(Header)).apply(this, arguments));
}
_createClass(Header, [{
@@ -3131,9 +3190,9 @@ var Header = function (_Component) {
value: function render() {
var _this2 = this;
- var _props = this.props;
- var selectedFlowId = _props.selectedFlowId;
- var activeMenu = _props.activeMenu;
+ var _props = this.props,
+ selectedFlowId = _props.selectedFlowId,
+ activeMenu = _props.activeMenu;
var entries = [].concat(_toConsumableArray(Header.entries));
@@ -3228,9 +3287,9 @@ FileMenu.onNewClick = function (e, clearFlows) {
};
function FileMenu(_ref) {
- var clearFlows = _ref.clearFlows;
- var loadFlows = _ref.loadFlows;
- var saveFlows = _ref.saveFlows;
+ var clearFlows = _ref.clearFlows,
+ loadFlows = _ref.loadFlows,
+ saveFlows = _ref.saveFlows;
return _react2.default.createElement(
_Dropdown2.default,
@@ -3241,11 +3300,11 @@ function FileMenu(_ref) {
return FileMenu.onNewClick(e, clearFlows);
} },
_react2.default.createElement('i', { className: 'fa fa-fw fa-file' }),
- ' New'
+ '\xA0New'
),
_react2.default.createElement(_FileChooser2.default, {
icon: 'fa-folder-open',
- text: ' Open...',
+ text: '\xA0Open...',
onOpenFile: function onOpenFile(file) {
return loadFlows(file);
}
@@ -3256,14 +3315,14 @@ function FileMenu(_ref) {
e.preventDefault();saveFlows();
} },
_react2.default.createElement('i', { className: 'fa fa-fw fa-floppy-o' }),
- ' Save...'
+ '\xA0Save...'
),
_react2.default.createElement(_Dropdown.Divider, null),
_react2.default.createElement(
'a',
{ href: 'http://mitm.it/', target: '_blank' },
_react2.default.createElement('i', { className: 'fa fa-fw fa-external-link' }),
- ' Install Certificates...'
+ '\xA0Install Certificates...'
)
);
}
@@ -3305,7 +3364,7 @@ var FilterDocs = function (_Component) {
function FilterDocs(props, context) {
_classCallCheck(this, FilterDocs);
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(FilterDocs).call(this, props, context));
+ var _this = _possibleConstructorReturn(this, (FilterDocs.__proto__ || Object.getPrototypeOf(FilterDocs)).call(this, props, context));
_this.state = { doc: FilterDocs.doc };
return _this;
@@ -3349,7 +3408,7 @@ var FilterDocs = function (_Component) {
_react2.default.createElement(
'td',
null,
- cmd[0].replace(' ', ' ')
+ cmd[0].replace(' ', '\xA0')
),
_react2.default.createElement(
'td',
@@ -3369,7 +3428,7 @@ var FilterDocs = function (_Component) {
{ href: 'http://docs.mitmproxy.org/en/stable/features/filters.html',
target: '_blank' },
_react2.default.createElement('i', { className: 'fa fa-external-link' }),
- '  mitmproxy docs'
+ '\xA0 mitmproxy docs'
)
)
)
@@ -3433,8 +3492,7 @@ var FilterInput = function (_Component) {
// Consider both focus and mouseover for showing/hiding the tooltip,
// because onBlur of the input is triggered before the click on the tooltip
// finalized, hiding the tooltip just as the user clicks on it.
-
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(FilterInput).call(this, props, context));
+ var _this = _possibleConstructorReturn(this, (FilterInput.__proto__ || Object.getPrototypeOf(FilterInput)).call(this, props, context));
_this.state = { value: _this.props.value, focus: false, mousefocus: false };
@@ -3531,14 +3589,14 @@ var FilterInput = function (_Component) {
}, {
key: 'render',
value: function render() {
- var _props = this.props;
- var type = _props.type;
- var color = _props.color;
- var placeholder = _props.placeholder;
- var _state = this.state;
- var value = _state.value;
- var focus = _state.focus;
- var mousefocus = _state.mousefocus;
+ var _props = this.props,
+ type = _props.type,
+ color = _props.color,
+ placeholder = _props.placeholder;
+ var _state = this.state,
+ value = _state.value,
+ focus = _state.focus,
+ mousefocus = _state.mousefocus;
return _react2.default.createElement(
'div',
@@ -3620,13 +3678,13 @@ FlowMenu.propTypes = {
};
function FlowMenu(_ref) {
- var flow = _ref.flow;
- var resumeFlow = _ref.resumeFlow;
- var killFlow = _ref.killFlow;
- var replayFlow = _ref.replayFlow;
- var duplicateFlow = _ref.duplicateFlow;
- var removeFlow = _ref.removeFlow;
- var revertFlow = _ref.revertFlow;
+ var flow = _ref.flow,
+ resumeFlow = _ref.resumeFlow,
+ killFlow = _ref.killFlow,
+ replayFlow = _ref.replayFlow,
+ duplicateFlow = _ref.duplicateFlow,
+ removeFlow = _ref.removeFlow,
+ revertFlow = _ref.revertFlow;
if (!flow) return _react2.default.createElement("div", null);
return _react2.default.createElement(
@@ -3835,9 +3893,9 @@ MenuToggle.propTypes = {
};
function MenuToggle(_ref) {
- var value = _ref.value;
- var onChange = _ref.onChange;
- var children = _ref.children;
+ var value = _ref.value,
+ onChange = _ref.onChange,
+ children = _ref.children;
return React.createElement(
"div",
@@ -3859,10 +3917,10 @@ SettingsToggle.propTypes = {
};
function SettingsToggle(_ref2) {
- var setting = _ref2.setting;
- var children = _ref2.children;
- var settings = _ref2.settings;
- var updateSettings = _ref2.updateSettings;
+ var setting = _ref2.setting,
+ children = _ref2.children,
+ settings = _ref2.settings,
+ updateSettings = _ref2.updateSettings;
return React.createElement(
MenuToggle,
@@ -3884,8 +3942,8 @@ exports.SettingsToggle = SettingsToggle = (0, _reactRedux.connect)(function (sta
})(SettingsToggle);
function EventlogToggle(_ref3) {
- var toggleVisibility = _ref3.toggleVisibility;
- var eventLogVisible = _ref3.eventLogVisible;
+ var toggleVisibility = _ref3.toggleVisibility,
+ eventLogVisible = _ref3.eventLogVisible;
return React.createElement(
MenuToggle,
@@ -4057,7 +4115,7 @@ var MainView = function (_Component) {
function MainView() {
_classCallCheck(this, MainView);
- return _possibleConstructorReturn(this, Object.getPrototypeOf(MainView).apply(this, arguments));
+ return _possibleConstructorReturn(this, (MainView.__proto__ || Object.getPrototypeOf(MainView)).apply(this, arguments));
}
_createClass(MainView, [{
@@ -4065,10 +4123,10 @@ var MainView = function (_Component) {
value: function render() {
var _this2 = this;
- var _props = this.props;
- var flows = _props.flows;
- var selectedFlow = _props.selectedFlow;
- var highlight = _props.highlight;
+ var _props = this.props,
+ flows = _props.flows,
+ selectedFlow = _props.selectedFlow,
+ highlight = _props.highlight;
return _react2.default.createElement(
'div',
@@ -4144,9 +4202,9 @@ Prompt.propTypes = {
};
function Prompt(_ref) {
- var prompt = _ref.prompt;
- var done = _ref.done;
- var options = _ref.options;
+ var prompt = _ref.prompt,
+ done = _ref.done,
+ options = _ref.options;
var opts = [];
@@ -4261,7 +4319,7 @@ var ProxyAppMain = function (_Component) {
function ProxyAppMain() {
_classCallCheck(this, ProxyAppMain);
- return _possibleConstructorReturn(this, Object.getPrototypeOf(ProxyAppMain).apply(this, arguments));
+ return _possibleConstructorReturn(this, (ProxyAppMain.__proto__ || Object.getPrototypeOf(ProxyAppMain)).apply(this, arguments));
}
_createClass(ProxyAppMain, [{
@@ -4277,11 +4335,11 @@ var ProxyAppMain = function (_Component) {
}, {
key: 'render',
value: function render() {
- var _props = this.props;
- var showEventLog = _props.showEventLog;
- var location = _props.location;
- var filter = _props.filter;
- var highlight = _props.highlight;
+ var _props = this.props,
+ showEventLog = _props.showEventLog,
+ location = _props.location,
+ filter = _props.filter,
+ highlight = _props.highlight;
return _react2.default.createElement(
'div',
@@ -4340,7 +4398,7 @@ var ValidateEditor = function (_Component) {
function ValidateEditor(props) {
_classCallCheck(this, ValidateEditor);
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ValidateEditor).call(this, props));
+ var _this = _possibleConstructorReturn(this, (ValidateEditor.__proto__ || Object.getPrototypeOf(ValidateEditor)).call(this, props));
_this.state = { valid: props.isValid(props.content) };
_this.onInput = _this.onInput.bind(_this);
@@ -4438,7 +4496,7 @@ var ValueEditor = function (_Component) {
function ValueEditor(props) {
_classCallCheck(this, ValueEditor);
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ValueEditor).call(this, props));
+ var _this = _possibleConstructorReturn(this, (ValueEditor.__proto__ || Object.getPrototypeOf(ValueEditor)).call(this, props));
_this.state = { editable: false };
@@ -4640,12 +4698,12 @@ Button.propTypes = {
};
function Button(_ref) {
- var onClick = _ref.onClick;
- var children = _ref.children;
- var icon = _ref.icon;
- var disabled = _ref.disabled;
- var className = _ref.className;
- var title = _ref.title;
+ var onClick = _ref.onClick,
+ children = _ref.children,
+ icon = _ref.icon,
+ disabled = _ref.disabled,
+ className = _ref.className,
+ title = _ref.title;
return _react2.default.createElement(
"div",
@@ -4673,8 +4731,8 @@ DocsLink.propTypes = {
};
function DocsLink(_ref) {
- var children = _ref.children;
- var resource = _ref.resource;
+ var children = _ref.children,
+ resource = _ref.resource;
var url = "http://docs.mitmproxy.org/en/stable/" + resource;
return React.createElement(
@@ -4720,7 +4778,7 @@ var Dropdown = function (_Component) {
function Dropdown(props, context) {
_classCallCheck(this, Dropdown);
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Dropdown).call(this, props, context));
+ var _this = _possibleConstructorReturn(this, (Dropdown.__proto__ || Object.getPrototypeOf(Dropdown)).call(this, props, context));
_this.state = { open: false };
_this.close = _this.close.bind(_this);
@@ -4747,12 +4805,12 @@ var Dropdown = function (_Component) {
}, {
key: 'render',
value: function render() {
- var _props = this.props;
- var dropup = _props.dropup;
- var className = _props.className;
- var btnClass = _props.btnClass;
- var text = _props.text;
- var children = _props.children;
+ var _props = this.props,
+ dropup = _props.dropup,
+ className = _props.className,
+ btnClass = _props.btnClass,
+ text = _props.text,
+ children = _props.children;
return _react2.default.createElement(
'div',
@@ -4816,11 +4874,11 @@ FileChooser.propTypes = {
};
function FileChooser(_ref) {
- var icon = _ref.icon;
- var text = _ref.text;
- var className = _ref.className;
- var title = _ref.title;
- var onOpenFile = _ref.onOpenFile;
+ var icon = _ref.icon,
+ text = _ref.text,
+ className = _ref.className,
+ title = _ref.title,
+ onOpenFile = _ref.onOpenFile;
var fileInput = void 0;
return _react2.default.createElement(
@@ -4880,7 +4938,7 @@ var Splitter = function (_Component) {
function Splitter(props, context) {
_classCallCheck(this, Splitter);
- var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Splitter).call(this, props, context));
+ var _this = _possibleConstructorReturn(this, (Splitter.__proto__ || Object.getPrototypeOf(Splitter)).call(this, props, context));
_this.state = { applied: false, startX: false, startY: false };
@@ -5011,15 +5069,15 @@ ToggleButton.propTypes = {
};
function ToggleButton(_ref) {
- var checked = _ref.checked;
- var onToggle = _ref.onToggle;
- var text = _ref.text;
+ var checked = _ref.checked,
+ onToggle = _ref.onToggle,
+ text = _ref.text;
return _react2.default.createElement(
"div",
{ className: "btn btn-toggle " + (checked ? "btn-primary" : "btn-default"), onClick: onToggle },
_react2.default.createElement("i", { className: "fa fa-fw " + (checked ? "fa-check-square-o" : "fa-square-o") }),
- " ",
+ "\xA0",
text
);
}
@@ -5065,7 +5123,7 @@ exports.default = function (Component) {
function AutoScrollWrapper() {
_classCallCheck(this, AutoScrollWrapper);
- return _possibleConstructorReturn(this, Object.getPrototypeOf(AutoScrollWrapper).apply(this, arguments));
+ return _possibleConstructorReturn(this, (AutoScrollWrapper.__proto__ || Object.getPrototypeOf(AutoScrollWrapper)).apply(this, arguments));
}
_createClass(AutoScrollWrapper, [{
@@ -5073,7 +5131,7 @@ exports.default = function (Component) {
value: function componentWillUpdate() {
var viewport = _reactDom2.default.findDOMNode(this);
this[symShouldStick] = viewport.scrollTop && isAtBottom(viewport);
- _get(Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentWillUpdate", this) && _get(Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentWillUpdate", this).call(this);
+ _get(AutoScrollWrapper.prototype.__proto__ || Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentWillUpdate", this) && _get(AutoScrollWrapper.prototype.__proto__ || Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentWillUpdate", this).call(this);
}
}, {
key: "componentDidUpdate",
@@ -5082,7 +5140,7 @@ exports.default = function (Component) {
if (this[symShouldStick] && !isAtBottom(viewport)) {
viewport.scrollTop = viewport.scrollHeight;
}
- _get(Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentDidUpdate", this) && _get(Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentDidUpdate", this).call(this);
+ _get(AutoScrollWrapper.prototype.__proto__ || Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentDidUpdate", this) && _get(AutoScrollWrapper.prototype.__proto__ || Object.getPrototypeOf(AutoScrollWrapper.prototype), "componentDidUpdate", this).call(this);
}
}]);
@@ -5122,11 +5180,11 @@ function calcVScroll(opts) {
return { start: 0, end: 0, paddingTop: 0, paddingBottom: 0 };
}
- var itemCount = opts.itemCount;
- var rowHeight = opts.rowHeight;
- var viewportTop = opts.viewportTop;
- var viewportHeight = opts.viewportHeight;
- var itemHeights = opts.itemHeights;
+ var itemCount = opts.itemCount,
+ rowHeight = opts.rowHeight,
+ viewportTop = opts.viewportTop,
+ viewportHeight = opts.viewportHeight,
+ itemHeights = opts.itemHeights;
var viewportBottom = viewportTop + viewportHeight;
@@ -5177,8 +5235,6 @@ Object.defineProperty(exports, "__esModule", {
});
exports.TOGGLE_FILTER = exports.TOGGLE_VISIBILITY = exports.RECEIVE = exports.ADD = undefined;
-var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports.default = reduce;
@@ -5205,45 +5261,33 @@ var defaultState = _extends({
}, (0, storeActions.default)(undefined, {}));
function reduce() {
- var state = arguments.length <= 0 || arguments[0] === undefined ? defaultState : arguments[0];
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
var action = arguments[1];
- var _ret = function () {
- switch (action.type) {
+ switch (action.type) {
- case TOGGLE_VISIBILITY:
- return {
- v: _extends({}, state, {
- visible: !state.visible
- })
- };
-
- case TOGGLE_FILTER:
- var filters = _extends({}, state.filters, _defineProperty({}, action.filter, !state.filters[action.filter]));
- return {
- v: _extends({}, state, {
- filters: filters
- }, (0, storeActions.default)(state, storeActions.setFilter(function (log) {
- return filters[log.level];
- })))
- };
-
- case ADD:
- case RECEIVE:
- return {
- v: _extends({}, state, (0, storeActions.default)(state, storeActions[action.cmd](action.data, function (log) {
- return state.filters[log.level];
- })))
- };
+ case TOGGLE_VISIBILITY:
+ return _extends({}, state, {
+ visible: !state.visible
+ });
- default:
- return {
- v: state
- };
- }
- }();
+ case TOGGLE_FILTER:
+ var filters = _extends({}, state.filters, _defineProperty({}, action.filter, !state.filters[action.filter]));
+ return _extends({}, state, {
+ filters: filters
+ }, (0, storeActions.default)(state, storeActions.setFilter(function (log) {
+ return filters[log.level];
+ })));
+
+ case ADD:
+ case RECEIVE:
+ return _extends({}, state, (0, storeActions.default)(state, storeActions[action.cmd](action.data, function (log) {
+ return state.filters[log.level];
+ })));
- if ((typeof _ret === "undefined" ? "undefined" : _typeof(_ret)) === "object") return _ret.v;
+ default:
+ return state;
+ }
}
function toggleFilter(filter) {
@@ -5255,7 +5299,7 @@ function toggleVisibility() {
}
function add(message) {
- var level = arguments.length <= 1 || arguments[1] === undefined ? 'web' : arguments[1];
+ var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'web';
var data = {
id: Math.random().toString(),
@@ -5335,7 +5379,7 @@ var defaultState = _extends({
}, (0, storeActions.default)(undefined, {}));
function reduce() {
- var state = arguments.length <= 0 || arguments[0] === undefined ? defaultState : arguments[0];
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
var action = arguments[1];
switch (action.type) {
@@ -5438,8 +5482,8 @@ function makeFilter(filter) {
}
function makeSort(_ref) {
- var column = _ref.column;
- var desc = _ref.desc;
+ var column = _ref.column,
+ desc = _ref.desc;
var sortKeyFun = sortKeyFuns[column];
if (!sortKeyFun) {
@@ -5634,7 +5678,7 @@ var UNKNOWN_CMD = exports.UNKNOWN_CMD = 'SETTINGS_UNKNOWN_CMD';
var defaultState = {};
function reducer() {
- var state = arguments.length <= 0 || arguments[0] === undefined ? defaultState : arguments[0];
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
var action = arguments[1];
switch (action.type) {
@@ -5712,7 +5756,7 @@ var defaultState = {
};
function reducer() {
- var state = arguments.length <= 0 || arguments[0] === undefined ? defaultState : arguments[0];
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
var action = arguments[1];
var wasInEditMode = !!state.modifiedFlow;
@@ -5858,7 +5902,7 @@ var defaultState = {
};
function reducer() {
- var state = arguments.length <= 0 || arguments[0] === undefined ? defaultState : arguments[0];
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
var action = arguments[1];
switch (action.type) {
@@ -6126,13 +6170,13 @@ var defaultState = {
*
*/
function reduce() {
- var state = arguments.length <= 0 || arguments[0] === undefined ? defaultState : arguments[0];
+ var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultState;
var action = arguments[1];
- var byId = state.byId;
- var list = state.list;
- var listIndex = state.listIndex;
- var view = state.view;
- var viewIndex = state.viewIndex;
+ var byId = state.byId,
+ list = state.list,
+ listIndex = state.listIndex,
+ view = state.view,
+ viewIndex = state.viewIndex;
switch (action.type) {
@@ -6233,28 +6277,28 @@ function reduce() {
}
function setFilter() {
- var filter = arguments.length <= 0 || arguments[0] === undefined ? defaultFilter : arguments[0];
- var sort = arguments.length <= 1 || arguments[1] === undefined ? defaultSort : arguments[1];
+ var filter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultFilter;
+ var sort = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultSort;
return { type: SET_FILTER, filter: filter, sort: sort };
}
function setSort() {
- var sort = arguments.length <= 0 || arguments[0] === undefined ? defaultSort : arguments[0];
+ var sort = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultSort;
return { type: SET_SORT, sort: sort };
}
function add(item) {
- var filter = arguments.length <= 1 || arguments[1] === undefined ? defaultFilter : arguments[1];
- var sort = arguments.length <= 2 || arguments[2] === undefined ? defaultSort : arguments[2];
+ var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultFilter;
+ var sort = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultSort;
return { type: ADD, item: item, filter: filter, sort: sort };
}
function update(item) {
- var filter = arguments.length <= 1 || arguments[1] === undefined ? defaultFilter : arguments[1];
- var sort = arguments.length <= 2 || arguments[2] === undefined ? defaultSort : arguments[2];
+ var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultFilter;
+ var sort = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultSort;
return { type: UPDATE, item: item, filter: filter, sort: sort };
}
@@ -6264,8 +6308,8 @@ function remove(id) {
}
function receive(list) {
- var filter = arguments.length <= 1 || arguments[1] === undefined ? defaultFilter : arguments[1];
- var sort = arguments.length <= 2 || arguments[2] === undefined ? defaultSort : arguments[2];
+ var filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultFilter;
+ var sort = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultSort;
return { type: RECEIVE, list: list, filter: filter, sort: sort };
}
@@ -8722,23 +8766,19 @@ var Query = {
};
function updateStoreFromUrl(store) {
- var _window$location$hash = window.location.hash.substr(1).split("?", 2);
-
- var _window$location$hash2 = _slicedToArray(_window$location$hash, 2);
-
- var path = _window$location$hash2[0];
- var query = _window$location$hash2[1];
+ var _window$location$hash = window.location.hash.substr(1).split("?", 2),
+ _window$location$hash2 = _slicedToArray(_window$location$hash, 2),
+ path = _window$location$hash2[0],
+ query = _window$location$hash2[1];
var path_components = path.substr(1).split("/");
if (path_components[0] === "flows") {
if (path_components.length == 3) {
- var _path_components$slic = path_components.slice(1);
-
- var _path_components$slic2 = _slicedToArray(_path_components$slic, 2);
-
- var flowId = _path_components$slic2[0];
- var tab = _path_components$slic2[1];
+ var _path_components$slic = path_components.slice(1),
+ _path_components$slic2 = _slicedToArray(_path_components$slic, 2),
+ flowId = _path_components$slic2[0],
+ tab = _path_components$slic2[1];
store.dispatch((0, _flows.select)(flowId));
store.dispatch((0, _flow.selectTab)(tab));
@@ -8747,12 +8787,10 @@ function updateStoreFromUrl(store) {
if (query) {
query.split("&").forEach(function (x) {
- var _x$split = x.split("=", 2);
-
- var _x$split2 = _slicedToArray(_x$split, 2);
-
- var key = _x$split2[0];
- var value = _x$split2[1];
+ var _x$split = x.split("=", 2),
+ _x$split2 = _slicedToArray(_x$split, 2),
+ key = _x$split2[0],
+ value = _x$split2[1];
switch (key) {
case Query.SEARCH:
@@ -8911,7 +8949,7 @@ function getCookie(name) {
var xsrf = '_xsrf=' + getCookie("_xsrf");
function fetchApi(url) {
- var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (options.method && options.method !== "GET") {
if (url.indexOf("?") === -1) {
@@ -8954,7 +8992,7 @@ var pure = exports.pure = function pure(renderFn) {
function _class() {
_classCallCheck(this, _class);
- return _possibleConstructorReturn(this, Object.getPrototypeOf(_class).apply(this, arguments));
+ return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).apply(this, arguments));
}
_createClass(_class, [{
@@ -8975,5 +9013,4 @@ var pure = exports.pure = function pure(renderFn) {
},{"lodash":"lodash","react":"react","shallowequal":"shallowequal"}]},{},[2])
-
//# sourceMappingURL=app.js.map
diff --git a/mitmproxy/tools/web/static/vendor.css b/mitmproxy/tools/web/static/vendor.css
index f8df478e..4826b4c3 100644
--- a/mitmproxy/tools/web/static/vendor.css
+++ b/mitmproxy/tools/web/static/vendor.css
@@ -1090,7 +1090,6 @@ a:focus {
text-decoration: underline;
}
a:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -2519,7 +2518,6 @@ select[size] {
input[type="file"]:focus,
input[type="radio"]:focus,
input[type="checkbox"]:focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
@@ -3010,7 +3008,6 @@ select[multiple].input-lg {
.btn.focus,
.btn:active.focus,
.btn.active.focus {
- outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
diff --git a/mitmproxy/tools/web/static/vendor.js b/mitmproxy/tools/web/static/vendor.js
index 39361c78..e83b8ba4 100644
--- a/mitmproxy/tools/web/static/vendor.js
+++ b/mitmproxy/tools/web/static/vendor.js
@@ -8,4985 +8,7806 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof requ
// You can find some technical background for some of the code below
// at http://marijnhaverbeke.nl/blog/#cm-internals .
-(function(mod) {
- if (typeof exports == "object" && typeof module == "object") // CommonJS
- module.exports = mod();
- else if (typeof define == "function" && define.amd) // AMD
- return define([], mod);
- else // Plain browser env
- (this || window).CodeMirror = mod();
-})(function() {
- "use strict";
-
- // BROWSER SNIFFING
-
- // Kludges for bugs and behavior differences that can't be feature
- // detected are enabled based on userAgent etc sniffing.
- var userAgent = navigator.userAgent;
- var platform = navigator.platform;
-
- var gecko = /gecko\/\d/i.test(userAgent);
- var ie_upto10 = /MSIE \d/.test(userAgent);
- var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
- var ie = ie_upto10 || ie_11up;
- var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]);
- var webkit = /WebKit\//.test(userAgent);
- var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
- var chrome = /Chrome\//.test(userAgent);
- var presto = /Opera\//.test(userAgent);
- var safari = /Apple Computer/.test(navigator.vendor);
- var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
- var phantom = /PhantomJS/.test(userAgent);
-
- var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
- // This is woefully incomplete. Suggestions for alternative methods welcome.
- var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
- var mac = ios || /Mac/.test(platform);
- var chromeOS = /\bCrOS\b/.test(userAgent);
- var windows = /win/i.test(platform);
-
- var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
- if (presto_version) presto_version = Number(presto_version[1]);
- if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
- // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
- var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
- var captureRightClick = gecko || (ie && ie_version >= 9);
-
- // Optimize some code when these features are not used.
- var sawReadOnlySpans = false, sawCollapsedSpans = false;
-
- // EDITOR CONSTRUCTOR
-
- // A CodeMirror instance represents an editor. This is the object
- // that user code is usually dealing with.
-
- function CodeMirror(place, options) {
- if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
-
- this.options = options = options ? copyObj(options) : {};
- // Determine effective options based on given values and defaults.
- copyObj(defaults, options, false);
- setGuttersForLineNumbers(options);
-
- var doc = options.value;
- if (typeof doc == "string") doc = new Doc(doc, options.mode, null, options.lineSeparator);
- this.doc = doc;
-
- var input = new CodeMirror.inputStyles[options.inputStyle](this);
- var display = this.display = new Display(place, doc, input);
- display.wrapper.CodeMirror = this;
- updateGutters(this);
- themeChanged(this);
- if (options.lineWrapping)
- this.display.wrapper.className += " CodeMirror-wrap";
- if (options.autofocus && !mobile) display.input.focus();
- initScrollbars(this);
-
- this.state = {
- keyMaps: [], // stores maps added by addKeyMap
- overlays: [], // highlighting overlays, as added by addOverlay
- modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
- overwrite: false,
- delayingBlurEvent: false,
- focused: false,
- suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
- pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
- selectingText: false,
- draggingText: false,
- highlight: new Delayed(), // stores highlight worker timeout
- keySeq: null, // Unfinished key sequence
- specialChars: null
- };
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global.CodeMirror = factory());
+}(this, (function () { 'use strict';
+
+// Kludges for bugs and behavior differences that can't be feature
+// detected are enabled based on userAgent etc sniffing.
+var userAgent = navigator.userAgent
+var platform = navigator.platform
+
+var gecko = /gecko\/\d/i.test(userAgent)
+var ie_upto10 = /MSIE \d/.test(userAgent)
+var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent)
+var edge = /Edge\/(\d+)/.exec(userAgent)
+var ie = ie_upto10 || ie_11up || edge
+var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1])
+var webkit = !edge && /WebKit\//.test(userAgent)
+var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent)
+var chrome = !edge && /Chrome\//.test(userAgent)
+var presto = /Opera\//.test(userAgent)
+var safari = /Apple Computer/.test(navigator.vendor)
+var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent)
+var phantom = /PhantomJS/.test(userAgent)
+
+var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent)
+// This is woefully incomplete. Suggestions for alternative methods welcome.
+var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent)
+var mac = ios || /Mac/.test(platform)
+var chromeOS = /\bCrOS\b/.test(userAgent)
+var windows = /win/i.test(platform)
+
+var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/)
+if (presto_version) { presto_version = Number(presto_version[1]) }
+if (presto_version && presto_version >= 15) { presto = false; webkit = true }
+// Some browsers use the wrong event properties to signal cmd/ctrl on OS X
+var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11))
+var captureRightClick = gecko || (ie && ie_version >= 9)
+
+function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") }
+
+var rmClass = function(node, cls) {
+ var current = node.className
+ var match = classTest(cls).exec(current)
+ if (match) {
+ var after = current.slice(match.index + match[0].length)
+ node.className = current.slice(0, match.index) + (after ? match[1] + after : "")
+ }
+}
+
+function removeChildren(e) {
+ for (var count = e.childNodes.length; count > 0; --count)
+ { e.removeChild(e.firstChild) }
+ return e
+}
+
+function removeChildrenAndAdd(parent, e) {
+ return removeChildren(parent).appendChild(e)
+}
+
+function elt(tag, content, className, style) {
+ var e = document.createElement(tag)
+ if (className) { e.className = className }
+ if (style) { e.style.cssText = style }
+ if (typeof content == "string") { e.appendChild(document.createTextNode(content)) }
+ else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]) } }
+ return e
+}
+
+var range
+if (document.createRange) { range = function(node, start, end, endNode) {
+ var r = document.createRange()
+ r.setEnd(endNode || node, end)
+ r.setStart(node, start)
+ return r
+} }
+else { range = function(node, start, end) {
+ var r = document.body.createTextRange()
+ try { r.moveToElementText(node.parentNode) }
+ catch(e) { return r }
+ r.collapse(true)
+ r.moveEnd("character", end)
+ r.moveStart("character", start)
+ return r
+} }
+
+function contains(parent, child) {
+ if (child.nodeType == 3) // Android browser always returns false when child is a textnode
+ { child = child.parentNode }
+ if (parent.contains)
+ { return parent.contains(child) }
+ do {
+ if (child.nodeType == 11) { child = child.host }
+ if (child == parent) { return true }
+ } while (child = child.parentNode)
+}
- var cm = this;
+function activeElt() {
+ // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
+ // IE < 10 will throw when accessed while the page is loading or in an iframe.
+ // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
+ var activeElement
+ try {
+ activeElement = document.activeElement
+ } catch(e) {
+ activeElement = document.body || null
+ }
+ while (activeElement && activeElement.root && activeElement.root.activeElement)
+ { activeElement = activeElement.root.activeElement }
+ return activeElement
+}
- // Override magic textarea content restore that IE sometimes does
- // on our hidden textarea on reload
- if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20);
+function addClass(node, cls) {
+ var current = node.className
+ if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls }
+}
+function joinClasses(a, b) {
+ var as = a.split(" ")
+ for (var i = 0; i < as.length; i++)
+ { if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i] } }
+ return b
+}
- registerEventHandlers(this);
- ensureGlobalHandlers();
+var selectInput = function(node) { node.select() }
+if (ios) // Mobile Safari apparently has a bug where select() is broken.
+ { selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length } }
+else if (ie) // Suppress mysterious IE10 errors
+ { selectInput = function(node) { try { node.select() } catch(_e) {} } }
- startOperation(this);
- this.curOp.forceUpdate = true;
- attachDoc(this, doc);
+function bind(f) {
+ var args = Array.prototype.slice.call(arguments, 1)
+ return function(){return f.apply(null, args)}
+}
- if ((options.autofocus && !mobile) || cm.hasFocus())
- setTimeout(bind(onFocus, this), 20);
- else
- onBlur(this);
-
- for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
- optionHandlers[opt](this, options[opt], Init);
- maybeUpdateLineNumberWidth(this);
- if (options.finishInit) options.finishInit(this);
- for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
- endOperation(this);
- // Suppress optimizelegibility in Webkit, since it breaks text
- // measuring on line wrapping boundaries.
- if (webkit && options.lineWrapping &&
- getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
- display.lineDiv.style.textRendering = "auto";
- }
-
- // DISPLAY CONSTRUCTOR
-
- // The display handles the DOM integration, both for input reading
- // and content drawing. It holds references to DOM nodes and
- // display-related state.
-
- function Display(place, doc, input) {
- var d = this;
- this.input = input;
-
- // Covers bottom-right square when both scrollbars are present.
- d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
- d.scrollbarFiller.setAttribute("cm-not-content", "true");
- // Covers bottom of gutter when coverGutterNextToScrollbar is on
- // and h scrollbar is present.
- d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
- d.gutterFiller.setAttribute("cm-not-content", "true");
- // Will contain the actual code, positioned to cover the viewport.
- d.lineDiv = elt("div", null, "CodeMirror-code");
- // Elements are added to these to represent selection and cursors.
- d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
- d.cursorDiv = elt("div", null, "CodeMirror-cursors");
- // A visibility: hidden element used to find the size of things.
- d.measure = elt("div", null, "CodeMirror-measure");
- // When lines outside of the viewport are measured, they are drawn in this.
- d.lineMeasure = elt("div", null, "CodeMirror-measure");
- // Wraps everything that needs to exist inside the vertically-padded coordinate system
- d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
- null, "position: relative; outline: none");
- // Moved around its parent to cover visible view.
- d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative");
- // Set to the height of the document, allowing scrolling.
- d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
- d.sizerWidth = null;
- // Behavior of elts with overflow: auto and padding is
- // inconsistent across browsers. This is used to ensure the
- // scrollable area is big enough.
- d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
- // Will contain the gutters, if any.
- d.gutters = elt("div", null, "CodeMirror-gutters");
- d.lineGutter = null;
- // Actual scrollable element.
- d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
- d.scroller.setAttribute("tabIndex", "-1");
- // The element in which the editor lives.
- d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
-
- // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
- if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
- if (!webkit && !(gecko && mobile)) d.scroller.draggable = true;
-
- if (place) {
- if (place.appendChild) place.appendChild(d.wrapper);
- else place(d.wrapper);
- }
-
- // Current rendered range (may be bigger than the view window).
- d.viewFrom = d.viewTo = doc.first;
- d.reportedViewFrom = d.reportedViewTo = doc.first;
- // Information about the rendered lines.
- d.view = [];
- d.renderedView = null;
- // Holds info about a single rendered line when it was rendered
- // for measurement, while not in view.
- d.externalMeasured = null;
- // Empty space (in pixels) above the view
- d.viewOffset = 0;
- d.lastWrapHeight = d.lastWrapWidth = 0;
- d.updateLineNumbers = null;
-
- d.nativeBarWidth = d.barHeight = d.barWidth = 0;
- d.scrollbarsClipped = false;
-
- // Used to only resize the line number gutter when necessary (when
- // the amount of lines crosses a boundary that makes its width change)
- d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
- // Set to true when a non-horizontal-scrolling line widget is
- // added. As an optimization, line widget aligning is skipped when
- // this is false.
- d.alignWidgets = false;
-
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
-
- // Tracks the maximum line length so that the horizontal scrollbar
- // can be kept static when scrolling.
- d.maxLine = null;
- d.maxLineLength = 0;
- d.maxLineChanged = false;
-
- // Used for measuring wheel scrolling granularity
- d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
-
- // True when shift is held down.
- d.shift = false;
-
- // Used to track whether anything happened since the context menu
- // was opened.
- d.selForContextMenu = null;
-
- d.activeTouch = null;
-
- input.init(d);
- }
-
- // STATE UPDATES
-
- // Used to get the editor into a consistent state again when options change.
-
- function loadMode(cm) {
- cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption);
- resetModeState(cm);
- }
-
- function resetModeState(cm) {
- cm.doc.iter(function(line) {
- if (line.stateAfter) line.stateAfter = null;
- if (line.styles) line.styles = null;
- });
- cm.doc.frontier = cm.doc.first;
- startWorker(cm, 100);
- cm.state.modeGen++;
- if (cm.curOp) regChange(cm);
- }
+function copyObj(obj, target, overwrite) {
+ if (!target) { target = {} }
+ for (var prop in obj)
+ { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
+ { target[prop] = obj[prop] } }
+ return target
+}
- function wrappingChanged(cm) {
- if (cm.options.lineWrapping) {
- addClass(cm.display.wrapper, "CodeMirror-wrap");
- cm.display.sizer.style.minWidth = "";
- cm.display.sizerWidth = null;
- } else {
- rmClass(cm.display.wrapper, "CodeMirror-wrap");
- findMaxLine(cm);
- }
- estimateLineHeights(cm);
- regChange(cm);
- clearCaches(cm);
- setTimeout(function(){updateScrollbars(cm);}, 100);
+// Counts the column offset in a string, taking tabs into account.
+// Used mostly to find indentation.
+function countColumn(string, end, tabSize, startIndex, startValue) {
+ if (end == null) {
+ end = string.search(/[^\s\u00a0]/)
+ if (end == -1) { end = string.length }
}
+ for (var i = startIndex || 0, n = startValue || 0;;) {
+ var nextTab = string.indexOf("\t", i)
+ if (nextTab < 0 || nextTab >= end)
+ { return n + (end - i) }
+ n += nextTab - i
+ n += tabSize - (n % tabSize)
+ i = nextTab + 1
+ }
+}
- // Returns a function that estimates the height of a line, to use as
- // first approximation until the line becomes visible (and is thus
- // properly measurable).
- function estimateHeight(cm) {
- var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
- var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
- return function(line) {
- if (lineIsHidden(cm.doc, line)) return 0;
-
- var widgetsHeight = 0;
- if (line.widgets) for (var i = 0; i < line.widgets.length; i++) {
- if (line.widgets[i].height) widgetsHeight += line.widgets[i].height;
- }
+var Delayed = function() {this.id = null};
+Delayed.prototype.set = function (ms, f) {
+ clearTimeout(this.id)
+ this.id = setTimeout(f, ms)
+};
- if (wrapping)
- return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th;
- else
- return widgetsHeight + th;
- };
- }
+function indexOf(array, elt) {
+ for (var i = 0; i < array.length; ++i)
+ { if (array[i] == elt) { return i } }
+ return -1
+}
- function estimateLineHeights(cm) {
- var doc = cm.doc, est = estimateHeight(cm);
- doc.iter(function(line) {
- var estHeight = est(line);
- if (estHeight != line.height) updateLineHeight(line, estHeight);
- });
- }
+// Number of pixels added to scroller and sizer to hide scrollbar
+var scrollerGap = 30
- function themeChanged(cm) {
- cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
- cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
- clearCaches(cm);
- }
+// Returned or thrown by various protocols to signal 'I'm not
+// handling this'.
+var Pass = {toString: function(){return "CodeMirror.Pass"}}
- function guttersChanged(cm) {
- updateGutters(cm);
- regChange(cm);
- setTimeout(function(){alignHorizontally(cm);}, 20);
+// Reused option objects for setSelection & friends
+var sel_dontScroll = {scroll: false};
+var sel_mouse = {origin: "*mouse"};
+var sel_move = {origin: "+move"};
+// The inverse of countColumn -- find the offset that corresponds to
+// a particular column.
+function findColumn(string, goal, tabSize) {
+ for (var pos = 0, col = 0;;) {
+ var nextTab = string.indexOf("\t", pos)
+ if (nextTab == -1) { nextTab = string.length }
+ var skipped = nextTab - pos
+ if (nextTab == string.length || col + skipped >= goal)
+ { return pos + Math.min(skipped, goal - col) }
+ col += nextTab - pos
+ col += tabSize - (col % tabSize)
+ pos = nextTab + 1
+ if (col >= goal) { return pos }
}
+}
- // Rebuild the gutter elements, ensure the margin to the left of the
- // code matches their width.
- function updateGutters(cm) {
- var gutters = cm.display.gutters, specs = cm.options.gutters;
- removeChildren(gutters);
- for (var i = 0; i < specs.length; ++i) {
- var gutterClass = specs[i];
- var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
- if (gutterClass == "CodeMirror-linenumbers") {
- cm.display.lineGutter = gElt;
- gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
- }
- }
- gutters.style.display = i ? "" : "none";
- updateGutterSpace(cm);
- }
+var spaceStrs = [""]
+function spaceStr(n) {
+ while (spaceStrs.length <= n)
+ { spaceStrs.push(lst(spaceStrs) + " ") }
+ return spaceStrs[n]
+}
- function updateGutterSpace(cm) {
- var width = cm.display.gutters.offsetWidth;
- cm.display.sizer.style.marginLeft = width + "px";
- }
+function lst(arr) { return arr[arr.length-1] }
- // Compute the character length of a line, taking into account
- // collapsed ranges (see markText) that might hide parts, and join
- // other lines onto it.
- function lineLength(line) {
- if (line.height == 0) return 0;
- var len = line.text.length, merged, cur = line;
- while (merged = collapsedSpanAtStart(cur)) {
- var found = merged.find(0, true);
- cur = found.from.line;
- len += found.from.ch - found.to.ch;
- }
- cur = line;
- while (merged = collapsedSpanAtEnd(cur)) {
- var found = merged.find(0, true);
- len -= cur.text.length - found.from.ch;
- cur = found.to.line;
- len += cur.text.length - found.to.ch;
- }
- return len;
- }
+function map(array, f) {
+ var out = []
+ for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i) }
+ return out
+}
- // Find the longest line in the document.
- function findMaxLine(cm) {
- var d = cm.display, doc = cm.doc;
- d.maxLine = getLine(doc, doc.first);
- d.maxLineLength = lineLength(d.maxLine);
- d.maxLineChanged = true;
- doc.iter(function(line) {
- var len = lineLength(line);
- if (len > d.maxLineLength) {
- d.maxLineLength = len;
- d.maxLine = line;
- }
- });
- }
+function insertSorted(array, value, score) {
+ var pos = 0, priority = score(value)
+ while (pos < array.length && score(array[pos]) <= priority) { pos++ }
+ array.splice(pos, 0, value)
+}
- // Make sure the gutters options contains the element
- // "CodeMirror-linenumbers" when the lineNumbers option is true.
- function setGuttersForLineNumbers(options) {
- var found = indexOf(options.gutters, "CodeMirror-linenumbers");
- if (found == -1 && options.lineNumbers) {
- options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
- } else if (found > -1 && !options.lineNumbers) {
- options.gutters = options.gutters.slice(0);
- options.gutters.splice(found, 1);
- }
- }
+function nothing() {}
- // SCROLLBARS
+function createObj(base, props) {
+ var inst
+ if (Object.create) {
+ inst = Object.create(base)
+ } else {
+ nothing.prototype = base
+ inst = new nothing()
+ }
+ if (props) { copyObj(props, inst) }
+ return inst
+}
+
+var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/
+function isWordCharBasic(ch) {
+ return /\w/.test(ch) || ch > "\x80" &&
+ (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))
+}
+function isWordChar(ch, helper) {
+ if (!helper) { return isWordCharBasic(ch) }
+ if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true }
+ return helper.test(ch)
+}
+
+function isEmpty(obj) {
+ for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } }
+ return true
+}
+
+// Extending unicode characters. A series of a non-extending char +
+// any number of extending chars is treated as a single unit as far
+// as editing and measuring is concerned. This is not fully correct,
+// since some scripts/fonts/browsers also treat other configurations
+// of code points as a group.
+var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/
+function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
+
+// Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.
+function skipExtendingChars(str, pos, dir) {
+ while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir }
+ return pos
+}
+
+// Returns the value from the range [`from`; `to`] that satisfies
+// `pred` and is closest to `from`. Assumes that at least `to` satisfies `pred`.
+function findFirst(pred, from, to) {
+ for (;;) {
+ if (Math.abs(from - to) <= 1) { return pred(from) ? from : to }
+ var mid = Math.floor((from + to) / 2)
+ if (pred(mid)) { to = mid }
+ else { from = mid }
+ }
+}
+
+// The display handles the DOM integration, both for input reading
+// and content drawing. It holds references to DOM nodes and
+// display-related state.
+
+function Display(place, doc, input) {
+ var d = this
+ this.input = input
+
+ // Covers bottom-right square when both scrollbars are present.
+ d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler")
+ d.scrollbarFiller.setAttribute("cm-not-content", "true")
+ // Covers bottom of gutter when coverGutterNextToScrollbar is on
+ // and h scrollbar is present.
+ d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler")
+ d.gutterFiller.setAttribute("cm-not-content", "true")
+ // Will contain the actual code, positioned to cover the viewport.
+ d.lineDiv = elt("div", null, "CodeMirror-code")
+ // Elements are added to these to represent selection and cursors.
+ d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1")
+ d.cursorDiv = elt("div", null, "CodeMirror-cursors")
+ // A visibility: hidden element used to find the size of things.
+ d.measure = elt("div", null, "CodeMirror-measure")
+ // When lines outside of the viewport are measured, they are drawn in this.
+ d.lineMeasure = elt("div", null, "CodeMirror-measure")
+ // Wraps everything that needs to exist inside the vertically-padded coordinate system
+ d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
+ null, "position: relative; outline: none")
+ // Moved around its parent to cover visible view.
+ d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative")
+ // Set to the height of the document, allowing scrolling.
+ d.sizer = elt("div", [d.mover], "CodeMirror-sizer")
+ d.sizerWidth = null
+ // Behavior of elts with overflow: auto and padding is
+ // inconsistent across browsers. This is used to ensure the
+ // scrollable area is big enough.
+ d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;")
+ // Will contain the gutters, if any.
+ d.gutters = elt("div", null, "CodeMirror-gutters")
+ d.lineGutter = null
+ // Actual scrollable element.
+ d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll")
+ d.scroller.setAttribute("tabIndex", "-1")
+ // The element in which the editor lives.
+ d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror")
+
+ // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
+ if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0 }
+ if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true }
+
+ if (place) {
+ if (place.appendChild) { place.appendChild(d.wrapper) }
+ else { place(d.wrapper) }
+ }
+
+ // Current rendered range (may be bigger than the view window).
+ d.viewFrom = d.viewTo = doc.first
+ d.reportedViewFrom = d.reportedViewTo = doc.first
+ // Information about the rendered lines.
+ d.view = []
+ d.renderedView = null
+ // Holds info about a single rendered line when it was rendered
+ // for measurement, while not in view.
+ d.externalMeasured = null
+ // Empty space (in pixels) above the view
+ d.viewOffset = 0
+ d.lastWrapHeight = d.lastWrapWidth = 0
+ d.updateLineNumbers = null
+
+ d.nativeBarWidth = d.barHeight = d.barWidth = 0
+ d.scrollbarsClipped = false
+
+ // Used to only resize the line number gutter when necessary (when
+ // the amount of lines crosses a boundary that makes its width change)
+ d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null
+ // Set to true when a non-horizontal-scrolling line widget is
+ // added. As an optimization, line widget aligning is skipped when
+ // this is false.
+ d.alignWidgets = false
+
+ d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null
+
+ // Tracks the maximum line length so that the horizontal scrollbar
+ // can be kept static when scrolling.
+ d.maxLine = null
+ d.maxLineLength = 0
+ d.maxLineChanged = false
+
+ // Used for measuring wheel scrolling granularity
+ d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null
+
+ // True when shift is held down.
+ d.shift = false
+
+ // Used to track whether anything happened since the context menu
+ // was opened.
+ d.selForContextMenu = null
+
+ d.activeTouch = null
+
+ input.init(d)
+}
+
+// Find the line object corresponding to the given line number.
+function getLine(doc, n) {
+ n -= doc.first
+ if (n < 0 || n >= doc.size) { throw new Error("There is no line " + (n + doc.first) + " in the document.") }
+ var chunk = doc
+ while (!chunk.lines) {
+ for (var i = 0;; ++i) {
+ var child = chunk.children[i], sz = child.chunkSize()
+ if (n < sz) { chunk = child; break }
+ n -= sz
+ }
+ }
+ return chunk.lines[n]
+}
+
+// Get the part of a document between two positions, as an array of
+// strings.
+function getBetween(doc, start, end) {
+ var out = [], n = start.line
+ doc.iter(start.line, end.line + 1, function (line) {
+ var text = line.text
+ if (n == end.line) { text = text.slice(0, end.ch) }
+ if (n == start.line) { text = text.slice(start.ch) }
+ out.push(text)
+ ++n
+ })
+ return out
+}
+// Get the lines between from and to, as array of strings.
+function getLines(doc, from, to) {
+ var out = []
+ doc.iter(from, to, function (line) { out.push(line.text) }) // iter aborts when callback returns truthy value
+ return out
+}
+
+// Update the height of a line, propagating the height change
+// upwards to parent nodes.
+function updateLineHeight(line, height) {
+ var diff = height - line.height
+ if (diff) { for (var n = line; n; n = n.parent) { n.height += diff } }
+}
- // Prepare DOM reads needed to update the scrollbars. Done in one
- // shot to minimize update/measure roundtrips.
- function measureForScrollbars(cm) {
- var d = cm.display, gutterW = d.gutters.offsetWidth;
- var docH = Math.round(cm.doc.height + paddingVert(cm.display));
- return {
- clientHeight: d.scroller.clientHeight,
- viewHeight: d.wrapper.clientHeight,
- scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
- viewWidth: d.wrapper.clientWidth,
- barLeft: cm.options.fixedGutter ? gutterW : 0,
- docHeight: docH,
- scrollHeight: docH + scrollGap(cm) + d.barHeight,
- nativeBarWidth: d.nativeBarWidth,
- gutterWidth: gutterW
- };
+// Given a line object, find its line number by walking up through
+// its parent links.
+function lineNo(line) {
+ if (line.parent == null) { return null }
+ var cur = line.parent, no = indexOf(cur.lines, line)
+ for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
+ for (var i = 0;; ++i) {
+ if (chunk.children[i] == cur) { break }
+ no += chunk.children[i].chunkSize()
+ }
+ }
+ return no + cur.first
+}
+
+// Find the line at the given vertical position, using the height
+// information in the document tree.
+function lineAtHeight(chunk, h) {
+ var n = chunk.first
+ outer: do {
+ for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {
+ var child = chunk.children[i$1], ch = child.height
+ if (h < ch) { chunk = child; continue outer }
+ h -= ch
+ n += child.chunkSize()
+ }
+ return n
+ } while (!chunk.lines)
+ var i = 0
+ for (; i < chunk.lines.length; ++i) {
+ var line = chunk.lines[i], lh = line.height
+ if (h < lh) { break }
+ h -= lh
}
+ return n + i
+}
- function NativeScrollbars(place, scroll, cm) {
- this.cm = cm;
- var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
- var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
- place(vert); place(horiz);
-
- on(vert, "scroll", function() {
- if (vert.clientHeight) scroll(vert.scrollTop, "vertical");
- });
- on(horiz, "scroll", function() {
- if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
- });
+function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size}
- this.checkedZeroWidth = false;
- // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
- if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
- }
+function lineNumberFor(options, i) {
+ return String(options.lineNumberFormatter(i + options.firstLineNumber))
+}
- NativeScrollbars.prototype = copyObj({
- update: function(measure) {
- var needsH = measure.scrollWidth > measure.clientWidth + 1;
- var needsV = measure.scrollHeight > measure.clientHeight + 1;
- var sWidth = measure.nativeBarWidth;
+// A Pos instance represents a position within the text.
+function Pos(line, ch, sticky) {
+ if ( sticky === void 0 ) sticky = null;
+
+ if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) }
+ this.line = line
+ this.ch = ch
+ this.sticky = sticky
+}
- if (needsV) {
- this.vert.style.display = "block";
- this.vert.style.bottom = needsH ? sWidth + "px" : "0";
- var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
- // A bug in IE8 can cause this value to be negative, so guard it.
- this.vert.firstChild.style.height =
- Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
+// Compare two positions, return 0 if they are the same, a negative
+// number when a is less, and a positive number otherwise.
+function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
+
+function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 }
+
+function copyPos(x) {return Pos(x.line, x.ch)}
+function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
+function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
+
+// Most of the external API clips given positions to make sure they
+// actually exist within the document.
+function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))}
+function clipPos(doc, pos) {
+ if (pos.line < doc.first) { return Pos(doc.first, 0) }
+ var last = doc.first + doc.size - 1
+ if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) }
+ return clipToLen(pos, getLine(doc, pos.line).text.length)
+}
+function clipToLen(pos, linelen) {
+ var ch = pos.ch
+ if (ch == null || ch > linelen) { return Pos(pos.line, linelen) }
+ else if (ch < 0) { return Pos(pos.line, 0) }
+ else { return pos }
+}
+function clipPosArray(doc, array) {
+ var out = []
+ for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]) }
+ return out
+}
+
+// Optimize some code when these features are not used.
+var sawReadOnlySpans = false;
+var sawCollapsedSpans = false;
+function seeReadOnlySpans() {
+ sawReadOnlySpans = true
+}
+
+function seeCollapsedSpans() {
+ sawCollapsedSpans = true
+}
+
+// TEXTMARKER SPANS
+
+function MarkedSpan(marker, from, to) {
+ this.marker = marker
+ this.from = from; this.to = to
+}
+
+// Search an array of spans for a span matching the given marker.
+function getMarkedSpanFor(spans, marker) {
+ if (spans) { for (var i = 0; i < spans.length; ++i) {
+ var span = spans[i]
+ if (span.marker == marker) { return span }
+ } }
+}
+// Remove a span from an array, returning undefined if no spans are
+// left (we don't store arrays for lines without spans).
+function removeMarkedSpan(spans, span) {
+ var r
+ for (var i = 0; i < spans.length; ++i)
+ { if (spans[i] != span) { (r || (r = [])).push(spans[i]) } }
+ return r
+}
+// Add a span to a line.
+function addMarkedSpan(line, span) {
+ line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]
+ span.marker.attachLine(line)
+}
+
+// Used for the algorithm that adjusts markers for a change in the
+// document. These functions cut an array of spans at a given
+// character position, returning an array of remaining chunks (or
+// undefined if nothing remains).
+function markedSpansBefore(old, startCh, isInsert) {
+ var nw
+ if (old) { for (var i = 0; i < old.length; ++i) {
+ var span = old[i], marker = span.marker
+ var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh)
+ if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
+ var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh)
+ ;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to))
+ }
+ } }
+ return nw
+}
+function markedSpansAfter(old, endCh, isInsert) {
+ var nw
+ if (old) { for (var i = 0; i < old.length; ++i) {
+ var span = old[i], marker = span.marker
+ var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh)
+ if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
+ var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh)
+ ;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
+ span.to == null ? null : span.to - endCh))
+ }
+ } }
+ return nw
+}
+
+// Given a change object, compute the new set of marker spans that
+// cover the line in which the change took place. Removes spans
+// entirely within the change, reconnects spans belonging to the
+// same marker that appear on both sides of the change, and cuts off
+// spans partially within the change. Returns an array of span
+// arrays with one element for each line in (after) the change.
+function stretchSpansOverChange(doc, change) {
+ if (change.full) { return null }
+ var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans
+ var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans
+ if (!oldFirst && !oldLast) { return null }
+
+ var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0
+ // Get the spans that 'stick out' on both sides
+ var first = markedSpansBefore(oldFirst, startCh, isInsert)
+ var last = markedSpansAfter(oldLast, endCh, isInsert)
+
+ // Next, merge those two ends
+ var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0)
+ if (first) {
+ // Fix up .to properties of first
+ for (var i = 0; i < first.length; ++i) {
+ var span = first[i]
+ if (span.to == null) {
+ var found = getMarkedSpanFor(last, span.marker)
+ if (!found) { span.to = startCh }
+ else if (sameLine) { span.to = found.to == null ? null : found.to + offset }
+ }
+ }
+ }
+ if (last) {
+ // Fix up .from in last (or move them into first in case of sameLine)
+ for (var i$1 = 0; i$1 < last.length; ++i$1) {
+ var span$1 = last[i$1]
+ if (span$1.to != null) { span$1.to += offset }
+ if (span$1.from == null) {
+ var found$1 = getMarkedSpanFor(first, span$1.marker)
+ if (!found$1) {
+ span$1.from = offset
+ if (sameLine) { (first || (first = [])).push(span$1) }
+ }
} else {
- this.vert.style.display = "";
- this.vert.firstChild.style.height = "0";
- }
-
- if (needsH) {
- this.horiz.style.display = "block";
- this.horiz.style.right = needsV ? sWidth + "px" : "0";
- this.horiz.style.left = measure.barLeft + "px";
- var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
- this.horiz.firstChild.style.width =
- (measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
+ span$1.from += offset
+ if (sameLine) { (first || (first = [])).push(span$1) }
+ }
+ }
+ }
+ // Make sure we didn't create any zero-length spans
+ if (first) { first = clearEmptySpans(first) }
+ if (last && last != first) { last = clearEmptySpans(last) }
+
+ var newMarkers = [first]
+ if (!sameLine) {
+ // Fill gap with whole-line-spans
+ var gap = change.text.length - 2, gapMarkers
+ if (gap > 0 && first)
+ { for (var i$2 = 0; i$2 < first.length; ++i$2)
+ { if (first[i$2].to == null)
+ { (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)) } } }
+ for (var i$3 = 0; i$3 < gap; ++i$3)
+ { newMarkers.push(gapMarkers) }
+ newMarkers.push(last)
+ }
+ return newMarkers
+}
+
+// Remove spans that are empty and don't have a clearWhenEmpty
+// option of false.
+function clearEmptySpans(spans) {
+ for (var i = 0; i < spans.length; ++i) {
+ var span = spans[i]
+ if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
+ { spans.splice(i--, 1) }
+ }
+ if (!spans.length) { return null }
+ return spans
+}
+
+// Used to 'clip' out readOnly ranges when making a change.
+function removeReadOnlyRanges(doc, from, to) {
+ var markers = null
+ doc.iter(from.line, to.line + 1, function (line) {
+ if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
+ var mark = line.markedSpans[i].marker
+ if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
+ { (markers || (markers = [])).push(mark) }
+ } }
+ })
+ if (!markers) { return null }
+ var parts = [{from: from, to: to}]
+ for (var i = 0; i < markers.length; ++i) {
+ var mk = markers[i], m = mk.find(0)
+ for (var j = 0; j < parts.length; ++j) {
+ var p = parts[j]
+ if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue }
+ var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to)
+ if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
+ { newParts.push({from: p.from, to: m.from}) }
+ if (dto > 0 || !mk.inclusiveRight && !dto)
+ { newParts.push({from: m.to, to: p.to}) }
+ parts.splice.apply(parts, newParts)
+ j += newParts.length - 3
+ }
+ }
+ return parts
+}
+
+// Connect or disconnect spans from a line.
+function detachMarkedSpans(line) {
+ var spans = line.markedSpans
+ if (!spans) { return }
+ for (var i = 0; i < spans.length; ++i)
+ { spans[i].marker.detachLine(line) }
+ line.markedSpans = null
+}
+function attachMarkedSpans(line, spans) {
+ if (!spans) { return }
+ for (var i = 0; i < spans.length; ++i)
+ { spans[i].marker.attachLine(line) }
+ line.markedSpans = spans
+}
+
+// Helpers used when computing which overlapping collapsed span
+// counts as the larger one.
+function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 }
+function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 }
+
+// Returns a number indicating which of two overlapping collapsed
+// spans is larger (and thus includes the other). Falls back to
+// comparing ids when the spans cover exactly the same range.
+function compareCollapsedMarkers(a, b) {
+ var lenDiff = a.lines.length - b.lines.length
+ if (lenDiff != 0) { return lenDiff }
+ var aPos = a.find(), bPos = b.find()
+ var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b)
+ if (fromCmp) { return -fromCmp }
+ var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b)
+ if (toCmp) { return toCmp }
+ return b.id - a.id
+}
+
+// Find out whether a line ends or starts in a collapsed span. If
+// so, return the marker for that span.
+function collapsedSpanAtSide(line, start) {
+ var sps = sawCollapsedSpans && line.markedSpans, found
+ if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
+ sp = sps[i]
+ if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
+ (!found || compareCollapsedMarkers(found, sp.marker) < 0))
+ { found = sp.marker }
+ } }
+ return found
+}
+function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) }
+function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) }
+
+// Test whether there exists a collapsed span that partially
+// overlaps (covers the start or end, but not both) of a new span.
+// Such overlap is not allowed.
+function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
+ var line = getLine(doc, lineNo)
+ var sps = sawCollapsedSpans && line.markedSpans
+ if (sps) { for (var i = 0; i < sps.length; ++i) {
+ var sp = sps[i]
+ if (!sp.marker.collapsed) { continue }
+ var found = sp.marker.find(0)
+ var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker)
+ var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker)
+ if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue }
+ if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
+ fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
+ { return true }
+ } }
+}
+
+// A visual line is a line as drawn on the screen. Folding, for
+// example, can cause multiple logical lines to appear on the same
+// visual line. This finds the start of the visual line that the
+// given line is part of (usually that is the line itself).
+function visualLine(line) {
+ var merged
+ while (merged = collapsedSpanAtStart(line))
+ { line = merged.find(-1, true).line }
+ return line
+}
+
+function visualLineEnd(line) {
+ var merged
+ while (merged = collapsedSpanAtEnd(line))
+ { line = merged.find(1, true).line }
+ return line
+}
+
+// Returns an array of logical lines that continue the visual line
+// started by the argument, or undefined if there are no such lines.
+function visualLineContinued(line) {
+ var merged, lines
+ while (merged = collapsedSpanAtEnd(line)) {
+ line = merged.find(1, true).line
+ ;(lines || (lines = [])).push(line)
+ }
+ return lines
+}
+
+// Get the line number of the start of the visual line that the
+// given line number is part of.
+function visualLineNo(doc, lineN) {
+ var line = getLine(doc, lineN), vis = visualLine(line)
+ if (line == vis) { return lineN }
+ return lineNo(vis)
+}
+
+// Get the line number of the start of the next visual line after
+// the given line.
+function visualLineEndNo(doc, lineN) {
+ if (lineN > doc.lastLine()) { return lineN }
+ var line = getLine(doc, lineN), merged
+ if (!lineIsHidden(doc, line)) { return lineN }
+ while (merged = collapsedSpanAtEnd(line))
+ { line = merged.find(1, true).line }
+ return lineNo(line) + 1
+}
+
+// Compute whether a line is hidden. Lines count as hidden when they
+// are part of a visual line that starts with another line, or when
+// they are entirely covered by collapsed, non-widget span.
+function lineIsHidden(doc, line) {
+ var sps = sawCollapsedSpans && line.markedSpans
+ if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
+ sp = sps[i]
+ if (!sp.marker.collapsed) { continue }
+ if (sp.from == null) { return true }
+ if (sp.marker.widgetNode) { continue }
+ if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
+ { return true }
+ } }
+}
+function lineIsHiddenInner(doc, line, span) {
+ if (span.to == null) {
+ var end = span.marker.find(1, true)
+ return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker))
+ }
+ if (span.marker.inclusiveRight && span.to == line.text.length)
+ { return true }
+ for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) {
+ sp = line.markedSpans[i]
+ if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
+ (sp.to == null || sp.to != span.from) &&
+ (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
+ lineIsHiddenInner(doc, line, sp)) { return true }
+ }
+}
+
+// Find the height above the given line.
+function heightAtLine(lineObj) {
+ lineObj = visualLine(lineObj)
+
+ var h = 0, chunk = lineObj.parent
+ for (var i = 0; i < chunk.lines.length; ++i) {
+ var line = chunk.lines[i]
+ if (line == lineObj) { break }
+ else { h += line.height }
+ }
+ for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
+ for (var i$1 = 0; i$1 < p.children.length; ++i$1) {
+ var cur = p.children[i$1]
+ if (cur == chunk) { break }
+ else { h += cur.height }
+ }
+ }
+ return h
+}
+
+// Compute the character length of a line, taking into account
+// collapsed ranges (see markText) that might hide parts, and join
+// other lines onto it.
+function lineLength(line) {
+ if (line.height == 0) { return 0 }
+ var len = line.text.length, merged, cur = line
+ while (merged = collapsedSpanAtStart(cur)) {
+ var found = merged.find(0, true)
+ cur = found.from.line
+ len += found.from.ch - found.to.ch
+ }
+ cur = line
+ while (merged = collapsedSpanAtEnd(cur)) {
+ var found$1 = merged.find(0, true)
+ len -= cur.text.length - found$1.from.ch
+ cur = found$1.to.line
+ len += cur.text.length - found$1.to.ch
+ }
+ return len
+}
+
+// Find the longest line in the document.
+function findMaxLine(cm) {
+ var d = cm.display, doc = cm.doc
+ d.maxLine = getLine(doc, doc.first)
+ d.maxLineLength = lineLength(d.maxLine)
+ d.maxLineChanged = true
+ doc.iter(function (line) {
+ var len = lineLength(line)
+ if (len > d.maxLineLength) {
+ d.maxLineLength = len
+ d.maxLine = line
+ }
+ })
+}
+
+// BIDI HELPERS
+
+function iterateBidiSections(order, from, to, f) {
+ if (!order) { return f(from, to, "ltr") }
+ var found = false
+ for (var i = 0; i < order.length; ++i) {
+ var part = order[i]
+ if (part.from < to && part.to > from || from == to && part.to == from) {
+ f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr")
+ found = true
+ }
+ }
+ if (!found) { f(from, to, "ltr") }
+}
+
+var bidiOther = null
+function getBidiPartAt(order, ch, sticky) {
+ var found
+ bidiOther = null
+ for (var i = 0; i < order.length; ++i) {
+ var cur = order[i]
+ if (cur.from < ch && cur.to > ch) { return i }
+ if (cur.to == ch) {
+ if (cur.from != cur.to && sticky == "before") { found = i }
+ else { bidiOther = i }
+ }
+ if (cur.from == ch) {
+ if (cur.from != cur.to && sticky != "before") { found = i }
+ else { bidiOther = i }
+ }
+ }
+ return found != null ? found : bidiOther
+}
+
+// Bidirectional ordering algorithm
+// See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
+// that this (partially) implements.
+
+// One-char codes used for character types:
+// L (L): Left-to-Right
+// R (R): Right-to-Left
+// r (AL): Right-to-Left Arabic
+// 1 (EN): European Number
+// + (ES): European Number Separator
+// % (ET): European Number Terminator
+// n (AN): Arabic Number
+// , (CS): Common Number Separator
+// m (NSM): Non-Spacing Mark
+// b (BN): Boundary Neutral
+// s (B): Paragraph Separator
+// t (S): Segment Separator
+// w (WS): Whitespace
+// N (ON): Other Neutrals
+
+// Returns null if characters are ordered as they appear
+// (left-to-right), or an array of sections ({from, to, level}
+// objects) in the order in which they occur visually.
+var bidiOrdering = (function() {
+ // Character types for codepoints 0 to 0xff
+ var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"
+ // Character types for codepoints 0x600 to 0x6f9
+ var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111"
+ function charType(code) {
+ if (code <= 0xf7) { return lowTypes.charAt(code) }
+ else if (0x590 <= code && code <= 0x5f4) { return "R" }
+ else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) }
+ else if (0x6ee <= code && code <= 0x8ac) { return "r" }
+ else if (0x2000 <= code && code <= 0x200b) { return "w" }
+ else if (code == 0x200c) { return "b" }
+ else { return "L" }
+ }
+
+ var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/
+ var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/
+ // Browsers seem to always treat the boundaries of block elements as being L.
+ var outerType = "L"
+
+ function BidiSpan(level, from, to) {
+ this.level = level
+ this.from = from; this.to = to
+ }
+
+ return function(str) {
+ if (!bidiRE.test(str)) { return false }
+ var len = str.length, types = []
+ for (var i = 0; i < len; ++i)
+ { types.push(charType(str.charCodeAt(i))) }
+
+ // W1. Examine each non-spacing mark (NSM) in the level run, and
+ // change the type of the NSM to the type of the previous
+ // character. If the NSM is at the start of the level run, it will
+ // get the type of sor.
+ for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) {
+ var type = types[i$1]
+ if (type == "m") { types[i$1] = prev }
+ else { prev = type }
+ }
+
+ // W2. Search backwards from each instance of a European number
+ // until the first strong type (R, L, AL, or sor) is found. If an
+ // AL is found, change the type of the European number to Arabic
+ // number.
+ // W3. Change all ALs to R.
+ for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) {
+ var type$1 = types[i$2]
+ if (type$1 == "1" && cur == "r") { types[i$2] = "n" }
+ else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R" } }
+ }
+
+ // W4. A single European separator between two European numbers
+ // changes to a European number. A single common separator between
+ // two numbers of the same type changes to that type.
+ for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) {
+ var type$2 = types[i$3]
+ if (type$2 == "+" && prev$1 == "1" && types[i$3+1] == "1") { types[i$3] = "1" }
+ else if (type$2 == "," && prev$1 == types[i$3+1] &&
+ (prev$1 == "1" || prev$1 == "n")) { types[i$3] = prev$1 }
+ prev$1 = type$2
+ }
+
+ // W5. A sequence of European terminators adjacent to European
+ // numbers changes to all European numbers.
+ // W6. Otherwise, separators and terminators change to Other
+ // Neutral.
+ for (var i$4 = 0; i$4 < len; ++i$4) {
+ var type$3 = types[i$4]
+ if (type$3 == ",") { types[i$4] = "N" }
+ else if (type$3 == "%") {
+ var end = (void 0)
+ for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {}
+ var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N"
+ for (var j = i$4; j < end; ++j) { types[j] = replace }
+ i$4 = end - 1
+ }
+ }
+
+ // W7. Search backwards from each instance of a European number
+ // until the first strong type (R, L, or sor) is found. If an L is
+ // found, then change the type of the European number to L.
+ for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {
+ var type$4 = types[i$5]
+ if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L" }
+ else if (isStrong.test(type$4)) { cur$1 = type$4 }
+ }
+
+ // N1. A sequence of neutrals takes the direction of the
+ // surrounding strong text if the text on both sides has the same
+ // direction. European and Arabic numbers act as if they were R in
+ // terms of their influence on neutrals. Start-of-level-run (sor)
+ // and end-of-level-run (eor) are used at level run boundaries.
+ // N2. Any remaining neutrals take the embedding direction.
+ for (var i$6 = 0; i$6 < len; ++i$6) {
+ if (isNeutral.test(types[i$6])) {
+ var end$1 = (void 0)
+ for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
+ var before = (i$6 ? types[i$6-1] : outerType) == "L"
+ var after = (end$1 < len ? types[end$1] : outerType) == "L"
+ var replace$1 = before || after ? "L" : "R"
+ for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1 }
+ i$6 = end$1 - 1
+ }
+ }
+
+ // Here we depart from the documented algorithm, in order to avoid
+ // building up an actual levels array. Since there are only three
+ // levels (0, 1, 2) in an implementation that doesn't take
+ // explicit embedding into account, we can build up the order on
+ // the fly, without following the level-based algorithm.
+ var order = [], m
+ for (var i$7 = 0; i$7 < len;) {
+ if (countsAsLeft.test(types[i$7])) {
+ var start = i$7
+ for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}
+ order.push(new BidiSpan(0, start, i$7))
} else {
- this.horiz.style.display = "";
- this.horiz.firstChild.style.width = "0";
- }
-
- if (!this.checkedZeroWidth && measure.clientHeight > 0) {
- if (sWidth == 0) this.zeroWidthHack();
- this.checkedZeroWidth = true;
+ var pos = i$7, at = order.length
+ for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {}
+ for (var j$2 = pos; j$2 < i$7;) {
+ if (countsAsNum.test(types[j$2])) {
+ if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)) }
+ var nstart = j$2
+ for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}
+ order.splice(at, 0, new BidiSpan(2, nstart, j$2))
+ pos = j$2
+ } else { ++j$2 }
+ }
+ if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)) }
}
-
- return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
- },
- setScrollLeft: function(pos) {
- if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
- if (this.disableHoriz) this.enableZeroWidthBar(this.horiz, this.disableHoriz);
- },
- setScrollTop: function(pos) {
- if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
- if (this.disableVert) this.enableZeroWidthBar(this.vert, this.disableVert);
- },
- zeroWidthHack: function() {
- var w = mac && !mac_geMountainLion ? "12px" : "18px";
- this.horiz.style.height = this.vert.style.width = w;
- this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
- this.disableHoriz = new Delayed;
- this.disableVert = new Delayed;
- },
- enableZeroWidthBar: function(bar, delay) {
- bar.style.pointerEvents = "auto";
- function maybeDisable() {
- // To find out whether the scrollbar is still visible, we
- // check whether the element under the pixel in the bottom
- // left corner of the scrollbar box is the scrollbar box
- // itself (when the bar is still visible) or its filler child
- // (when the bar is hidden). If it is still visible, we keep
- // it enabled, if it's hidden, we disable pointer events.
- var box = bar.getBoundingClientRect();
- var elt = document.elementFromPoint(box.left + 1, box.bottom - 1);
- if (elt != bar) bar.style.pointerEvents = "none";
- else delay.set(1000, maybeDisable);
- }
- delay.set(1000, maybeDisable);
- },
- clear: function() {
- var parent = this.horiz.parentNode;
- parent.removeChild(this.horiz);
- parent.removeChild(this.vert);
}
- }, NativeScrollbars.prototype);
+ if (order[0].level == 1 && (m = str.match(/^\s+/))) {
+ order[0].from = m[0].length
+ order.unshift(new BidiSpan(0, 0, m[0].length))
+ }
+ if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
+ lst(order).to -= m[0].length
+ order.push(new BidiSpan(0, len - m[0].length, len))
+ }
- function NullScrollbars() {}
+ return order
+ }
+})()
- NullScrollbars.prototype = copyObj({
- update: function() { return {bottom: 0, right: 0}; },
- setScrollLeft: function() {},
- setScrollTop: function() {},
- clear: function() {}
- }, NullScrollbars.prototype);
+// Get the bidi ordering for the given line (and cache it). Returns
+// false for lines that are fully left-to-right, and an array of
+// BidiSpan objects otherwise.
+function getOrder(line) {
+ var order = line.order
+ if (order == null) { order = line.order = bidiOrdering(line.text) }
+ return order
+}
- CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
+function moveCharLogically(line, ch, dir) {
+ var target = skipExtendingChars(line.text, ch + dir, dir)
+ return target < 0 || target > line.text.length ? null : target
+}
- function initScrollbars(cm) {
- if (cm.display.scrollbars) {
- cm.display.scrollbars.clear();
- if (cm.display.scrollbars.addClass)
- rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
- }
+function moveLogically(line, start, dir) {
+ var ch = moveCharLogically(line, start.ch, dir)
+ return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before")
+}
- cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
- cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
- // Prevent clicks in the scrollbars from killing focus
- on(node, "mousedown", function() {
- if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0);
- });
- node.setAttribute("cm-not-content", "true");
- }, function(pos, axis) {
- if (axis == "horizontal") setScrollLeft(cm, pos);
- else setScrollTop(cm, pos);
- }, cm);
- if (cm.display.scrollbars.addClass)
- addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
- }
-
- function updateScrollbars(cm, measure) {
- if (!measure) measure = measureForScrollbars(cm);
- var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
- updateScrollbarsInner(cm, measure);
- for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
- if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
- updateHeightsInViewport(cm);
- updateScrollbarsInner(cm, measureForScrollbars(cm));
- startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
- }
- }
-
- // Re-synchronize the fake scrollbars with the actual size of the
- // content.
- function updateScrollbarsInner(cm, measure) {
- var d = cm.display;
- var sizes = d.scrollbars.update(measure);
-
- d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
- d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
- d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"
-
- if (sizes.right && sizes.bottom) {
- d.scrollbarFiller.style.display = "block";
- d.scrollbarFiller.style.height = sizes.bottom + "px";
- d.scrollbarFiller.style.width = sizes.right + "px";
- } else d.scrollbarFiller.style.display = "";
- if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
- d.gutterFiller.style.display = "block";
- d.gutterFiller.style.height = sizes.bottom + "px";
- d.gutterFiller.style.width = measure.gutterWidth + "px";
- } else d.gutterFiller.style.display = "";
- }
-
- // Compute the lines that are visible in a given viewport (defaults
- // the the current scroll position). viewport may contain top,
- // height, and ensure (see op.scrollToPos) properties.
- function visibleLines(display, doc, viewport) {
- var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
- top = Math.floor(top - paddingTop(display));
- var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
-
- var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
- // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
- // forces those lines into the viewport (if possible).
- if (viewport && viewport.ensure) {
- var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
- if (ensureFrom < from) {
- from = ensureFrom;
- to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
- } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
- from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
- to = ensureTo;
- }
- }
- return {from: from, to: Math.max(to, from + 1)};
- }
-
- // LINE NUMBERS
-
- // Re-align line numbers and gutter marks to compensate for
- // horizontal scrolling.
- function alignHorizontally(cm) {
- var display = cm.display, view = display.view;
- if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
- var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
- var gutterW = display.gutters.offsetWidth, left = comp + "px";
- for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
- if (cm.options.fixedGutter && view[i].gutter)
- view[i].gutter.style.left = left;
- var align = view[i].alignable;
- if (align) for (var j = 0; j < align.length; j++)
- align[j].style.left = left;
- }
- if (cm.options.fixedGutter)
- display.gutters.style.left = (comp + gutterW) + "px";
- }
-
- // Used to ensure that the line number gutter is still the right
- // size for the current document size. Returns true when an update
- // is needed.
- function maybeUpdateLineNumberWidth(cm) {
- if (!cm.options.lineNumbers) return false;
- var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
- if (last.length != display.lineNumChars) {
- var test = display.measure.appendChild(elt("div", [elt("div", last)],
- "CodeMirror-linenumber CodeMirror-gutter-elt"));
- var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
- display.lineGutter.style.width = "";
- display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
- display.lineNumWidth = display.lineNumInnerWidth + padding;
- display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
- display.lineGutter.style.width = display.lineNumWidth + "px";
- updateGutterSpace(cm);
- return true;
+function endOfLine(visually, cm, lineObj, lineNo, dir) {
+ if (visually) {
+ var order = getOrder(lineObj)
+ if (order) {
+ var part = dir < 0 ? lst(order) : order[0]
+ var moveInStorageOrder = (dir < 0) == (part.level == 1)
+ var sticky = moveInStorageOrder ? "after" : "before"
+ var ch
+ // With a wrapped rtl chunk (possibly spanning multiple bidi parts),
+ // it could be that the last bidi part is not on the last visual line,
+ // since visual lines contain content order-consecutive chunks.
+ // Thus, in rtl, we are looking for the first (content-order) character
+ // in the rtl chunk that is on the last line (that is, the same line
+ // as the last (content-order) character).
+ if (part.level > 0) {
+ var prep = prepareMeasureForLine(cm, lineObj)
+ ch = dir < 0 ? lineObj.text.length - 1 : 0
+ var targetTop = measureCharPrepared(cm, prep, ch).top
+ ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch)
+ if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1, true) }
+ } else { ch = dir < 0 ? part.to : part.from }
+ return new Pos(lineNo, ch, sticky)
}
- return false;
}
+ return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after")
+}
- function lineNumberFor(options, i) {
- return String(options.lineNumberFormatter(i + options.firstLineNumber));
+function moveVisually(cm, line, start, dir) {
+ var bidi = getOrder(line)
+ if (!bidi) { return moveLogically(line, start, dir) }
+ if (start.ch >= line.text.length) {
+ start.ch = line.text.length
+ start.sticky = "before"
+ } else if (start.ch <= 0) {
+ start.ch = 0
+ start.sticky = "after"
}
-
- // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
- // but using getBoundingClientRect to get a sub-pixel-accurate
- // result.
- function compensateForHScroll(display) {
- return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
+ var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos]
+ if (part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) {
+ // Case 1: We move within an ltr part. Even with wrapped lines,
+ // nothing interesting happens.
+ return moveLogically(line, start, dir)
}
- // DISPLAY DRAWING
-
- function DisplayUpdate(cm, viewport, force) {
- var display = cm.display;
-
- this.viewport = viewport;
- // Store some values that we'll need later (but don't want to force a relayout for)
- this.visible = visibleLines(display, cm.doc, viewport);
- this.editorIsHidden = !display.wrapper.offsetWidth;
- this.wrapperHeight = display.wrapper.clientHeight;
- this.wrapperWidth = display.wrapper.clientWidth;
- this.oldDisplayWidth = displayWidth(cm);
- this.force = force;
- this.dims = getDimensions(cm);
- this.events = [];
+ var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); }
+ var prep
+ var getWrappedLineExtent = function (ch) {
+ if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} }
+ prep = prep || prepareMeasureForLine(cm, line)
+ return wrappedLineExtentChar(cm, line, prep, ch)
}
+ var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch)
- DisplayUpdate.prototype.signal = function(emitter, type) {
- if (hasHandler(emitter, type))
- this.events.push(arguments);
- };
- DisplayUpdate.prototype.finish = function() {
- for (var i = 0; i < this.events.length; i++)
- signal.apply(null, this.events[i]);
- };
-
- function maybeClipScrollbars(cm) {
- var display = cm.display;
- if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
- display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
- display.heightForcer.style.height = scrollGap(cm) + "px";
- display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
- display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
- display.scrollbarsClipped = true;
+ if (part.level % 2 == 1) {
+ var ch = mv(start, -dir)
+ if (ch != null && (dir > 0 ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) {
+ // Case 2: We move within an rtl part on the same visual line
+ var sticky = dir < 0 ? "before" : "after"
+ return new Pos(start.line, ch, sticky)
}
}
- // Does the actual updating of the line display. Bails out
- // (returning false) when there is nothing to be done and forced is
- // false.
- function updateDisplayIfNeeded(cm, update) {
- var display = cm.display, doc = cm.doc;
+ // Case 3: Could not move within this bidi part in this visual line, so leave
+ // the current bidi part
- if (update.editorIsHidden) {
- resetView(cm);
- return false;
+ var searchInVisualLine = function (partPos, dir, wrappedLineExtent) {
+ var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder
+ ? new Pos(start.line, mv(ch, 1), "before")
+ : new Pos(start.line, ch, "after"); }
+
+ for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {
+ var part = bidi[partPos]
+ var moveInStorageOrder = (dir > 0) == (part.level != 1)
+ var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1)
+ if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) }
+ ch = moveInStorageOrder ? part.from : mv(part.to, -1)
+ if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) }
}
+ }
- // Bail out if the visible area is already rendered and nothing changed.
- if (!update.force &&
- update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
- (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
- display.renderedView == display.view && countDirtyView(cm) == 0)
- return false;
+ // Case 3a: Look for other bidi parts on the same visual line
+ var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent)
+ if (res) { return res }
- if (maybeUpdateLineNumberWidth(cm)) {
- resetView(cm);
- update.dims = getDimensions(cm);
- }
+ // Case 3b: Look for other bidi parts on the next visual line
+ var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1)
+ if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {
+ res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh))
+ if (res) { return res }
+ }
- // Compute a suitable new viewport (from & to)
- var end = doc.first + doc.size;
- var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
- var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
- if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
- if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
- if (sawCollapsedSpans) {
- from = visualLineNo(cm.doc, from);
- to = visualLineEndNo(cm.doc, to);
- }
+ // Case 4: Nowhere to move
+ return null
+}
- var different = from != display.viewFrom || to != display.viewTo ||
- display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
- adjustView(cm, from, to);
+// EVENT HANDLING
- display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
- // Position the mover div to align with the current scroll position
- cm.display.mover.style.top = display.viewOffset + "px";
+// Lightweight event framework. on/off also work on DOM nodes,
+// registering native DOM handlers.
- var toUpdate = countDirtyView(cm);
- if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
- (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
- return false;
+var noHandlers = []
- // For big changes, we hide the enclosing element during the
- // update, since that speeds up the operations on most browsers.
- var focused = activeElt();
- if (toUpdate > 4) display.lineDiv.style.display = "none";
- patchDisplay(cm, display.updateLineNumbers, update.dims);
- if (toUpdate > 4) display.lineDiv.style.display = "";
- display.renderedView = display.view;
- // There might have been a widget with a focused element that got
- // hidden or updated, if so re-focus it.
- if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
+var on = function(emitter, type, f) {
+ if (emitter.addEventListener) {
+ emitter.addEventListener(type, f, false)
+ } else if (emitter.attachEvent) {
+ emitter.attachEvent("on" + type, f)
+ } else {
+ var map = emitter._handlers || (emitter._handlers = {})
+ map[type] = (map[type] || noHandlers).concat(f)
+ }
+}
- // Prevent selection and cursors from interfering with the scroll
- // width and height.
- removeChildren(display.cursorDiv);
- removeChildren(display.selectionDiv);
- display.gutters.style.height = display.sizer.style.minHeight = 0;
+function getHandlers(emitter, type) {
+ return emitter._handlers && emitter._handlers[type] || noHandlers
+}
- if (different) {
- display.lastWrapHeight = update.wrapperHeight;
- display.lastWrapWidth = update.wrapperWidth;
- startWorker(cm, 400);
+function off(emitter, type, f) {
+ if (emitter.removeEventListener) {
+ emitter.removeEventListener(type, f, false)
+ } else if (emitter.detachEvent) {
+ emitter.detachEvent("on" + type, f)
+ } else {
+ var map = emitter._handlers, arr = map && map[type]
+ if (arr) {
+ var index = indexOf(arr, f)
+ if (index > -1)
+ { map[type] = arr.slice(0, index).concat(arr.slice(index + 1)) }
}
+ }
+}
- display.updateLineNumbers = null;
+function signal(emitter, type /*, values...*/) {
+ var handlers = getHandlers(emitter, type)
+ if (!handlers.length) { return }
+ var args = Array.prototype.slice.call(arguments, 2)
+ for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args) }
+}
+
+// The DOM events that CodeMirror handles can be overridden by
+// registering a (non-DOM) handler on the editor for the event name,
+// and preventDefault-ing the event in that handler.
+function signalDOMEvent(cm, e, override) {
+ if (typeof e == "string")
+ { e = {type: e, preventDefault: function() { this.defaultPrevented = true }} }
+ signal(cm, override || e.type, cm, e)
+ return e_defaultPrevented(e) || e.codemirrorIgnore
+}
+
+function signalCursorActivity(cm) {
+ var arr = cm._handlers && cm._handlers.cursorActivity
+ if (!arr) { return }
+ var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = [])
+ for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1)
+ { set.push(arr[i]) } }
+}
+
+function hasHandler(emitter, type) {
+ return getHandlers(emitter, type).length > 0
+}
+
+// Add on and off methods to a constructor's prototype, to make
+// registering events on such objects more convenient.
+function eventMixin(ctor) {
+ ctor.prototype.on = function(type, f) {on(this, type, f)}
+ ctor.prototype.off = function(type, f) {off(this, type, f)}
+}
+
+// Due to the fact that we still support jurassic IE versions, some
+// compatibility wrappers are needed.
+
+function e_preventDefault(e) {
+ if (e.preventDefault) { e.preventDefault() }
+ else { e.returnValue = false }
+}
+function e_stopPropagation(e) {
+ if (e.stopPropagation) { e.stopPropagation() }
+ else { e.cancelBubble = true }
+}
+function e_defaultPrevented(e) {
+ return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false
+}
+function e_stop(e) {e_preventDefault(e); e_stopPropagation(e)}
+
+function e_target(e) {return e.target || e.srcElement}
+function e_button(e) {
+ var b = e.which
+ if (b == null) {
+ if (e.button & 1) { b = 1 }
+ else if (e.button & 2) { b = 3 }
+ else if (e.button & 4) { b = 2 }
+ }
+ if (mac && e.ctrlKey && b == 1) { b = 3 }
+ return b
+}
+
+// Detect drag-and-drop
+var dragAndDrop = function() {
+ // There is *some* kind of drag-and-drop support in IE6-8, but I
+ // couldn't get it to work yet.
+ if (ie && ie_version < 9) { return false }
+ var div = elt('div')
+ return "draggable" in div || "dragDrop" in div
+}()
+
+var zwspSupported
+function zeroWidthElement(measure) {
+ if (zwspSupported == null) {
+ var test = elt("span", "\u200b")
+ removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]))
+ if (measure.firstChild.offsetHeight != 0)
+ { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8) }
+ }
+ var node = zwspSupported ? elt("span", "\u200b") :
+ elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px")
+ node.setAttribute("cm-text", "")
+ return node
+}
+
+// Feature-detect IE's crummy client rect reporting for bidi text
+var badBidiRects
+function hasBadBidiRects(measure) {
+ if (badBidiRects != null) { return badBidiRects }
+ var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"))
+ var r0 = range(txt, 0, 1).getBoundingClientRect()
+ var r1 = range(txt, 1, 2).getBoundingClientRect()
+ removeChildren(measure)
+ if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780)
+ return badBidiRects = (r1.right - r0.right < 3)
+}
+
+// See if "".split is the broken IE version, if so, provide an
+// alternative way to split lines.
+var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) {
+ var pos = 0, result = [], l = string.length
+ while (pos <= l) {
+ var nl = string.indexOf("\n", pos)
+ if (nl == -1) { nl = string.length }
+ var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl)
+ var rt = line.indexOf("\r")
+ if (rt != -1) {
+ result.push(line.slice(0, rt))
+ pos += rt + 1
+ } else {
+ result.push(line)
+ pos = nl + 1
+ }
+ }
+ return result
+} : function (string) { return string.split(/\r\n?|\n/); }
+
+var hasSelection = window.getSelection ? function (te) {
+ try { return te.selectionStart != te.selectionEnd }
+ catch(e) { return false }
+} : function (te) {
+ var range
+ try {range = te.ownerDocument.selection.createRange()}
+ catch(e) {}
+ if (!range || range.parentElement() != te) { return false }
+ return range.compareEndPoints("StartToEnd", range) != 0
+}
+
+var hasCopyEvent = (function () {
+ var e = elt("div")
+ if ("oncopy" in e) { return true }
+ e.setAttribute("oncopy", "return;")
+ return typeof e.oncopy == "function"
+})()
+
+var badZoomedRects = null
+function hasBadZoomedRects(measure) {
+ if (badZoomedRects != null) { return badZoomedRects }
+ var node = removeChildrenAndAdd(measure, elt("span", "x"))
+ var normal = node.getBoundingClientRect()
+ var fromRange = range(node, 0, 1).getBoundingClientRect()
+ return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1
+}
+
+var modes = {};
+var mimeModes = {};
+// Extra arguments are stored as the mode's dependencies, which is
+// used by (legacy) mechanisms like loadmode.js to automatically
+// load a mode. (Preferred mechanism is the require/define calls.)
+function defineMode(name, mode) {
+ if (arguments.length > 2)
+ { mode.dependencies = Array.prototype.slice.call(arguments, 2) }
+ modes[name] = mode
+}
+
+function defineMIME(mime, spec) {
+ mimeModes[mime] = spec
+}
+
+// Given a MIME type, a {name, ...options} config object, or a name
+// string, return a mode config object.
+function resolveMode(spec) {
+ if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
+ spec = mimeModes[spec]
+ } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
+ var found = mimeModes[spec.name]
+ if (typeof found == "string") { found = {name: found} }
+ spec = createObj(found, spec)
+ spec.name = found.name
+ } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
+ return resolveMode("application/xml")
+ } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
+ return resolveMode("application/json")
+ }
+ if (typeof spec == "string") { return {name: spec} }
+ else { return spec || {name: "null"} }
+}
+
+// Given a mode spec (anything that resolveMode accepts), find and
+// initialize an actual mode object.
+function getMode(options, spec) {
+ spec = resolveMode(spec)
+ var mfactory = modes[spec.name]
+ if (!mfactory) { return getMode(options, "text/plain") }
+ var modeObj = mfactory(options, spec)
+ if (modeExtensions.hasOwnProperty(spec.name)) {
+ var exts = modeExtensions[spec.name]
+ for (var prop in exts) {
+ if (!exts.hasOwnProperty(prop)) { continue }
+ if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop] }
+ modeObj[prop] = exts[prop]
+ }
+ }
+ modeObj.name = spec.name
+ if (spec.helperType) { modeObj.helperType = spec.helperType }
+ if (spec.modeProps) { for (var prop$1 in spec.modeProps)
+ { modeObj[prop$1] = spec.modeProps[prop$1] } }
+
+ return modeObj
+}
+
+// This can be used to attach properties to mode objects from
+// outside the actual mode definition.
+var modeExtensions = {}
+function extendMode(mode, properties) {
+ var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {})
+ copyObj(properties, exts)
+}
+
+function copyState(mode, state) {
+ if (state === true) { return state }
+ if (mode.copyState) { return mode.copyState(state) }
+ var nstate = {}
+ for (var n in state) {
+ var val = state[n]
+ if (val instanceof Array) { val = val.concat([]) }
+ nstate[n] = val
+ }
+ return nstate
+}
+
+// Given a mode and a state (for that mode), find the inner mode and
+// state at the position that the state refers to.
+function innerMode(mode, state) {
+ var info
+ while (mode.innerMode) {
+ info = mode.innerMode(state)
+ if (!info || info.mode == mode) { break }
+ state = info.state
+ mode = info.mode
+ }
+ return info || {mode: mode, state: state}
+}
+
+function startState(mode, a1, a2) {
+ return mode.startState ? mode.startState(a1, a2) : true
+}
+
+// STRING STREAM
+
+// Fed to the mode parsers, provides helper functions to make
+// parsers more succinct.
- return true;
+var StringStream = function(string, tabSize) {
+ this.pos = this.start = 0
+ this.string = string
+ this.tabSize = tabSize || 8
+ this.lastColumnPos = this.lastColumnValue = 0
+ this.lineStart = 0
+};
+
+StringStream.prototype.eol = function () {return this.pos >= this.string.length};
+StringStream.prototype.sol = function () {return this.pos == this.lineStart};
+StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined};
+StringStream.prototype.next = function () {
+ if (this.pos < this.string.length)
+ { return this.string.charAt(this.pos++) }
+};
+StringStream.prototype.eat = function (match) {
+ var ch = this.string.charAt(this.pos)
+ var ok
+ if (typeof match == "string") { ok = ch == match }
+ else { ok = ch && (match.test ? match.test(ch) : match(ch)) }
+ if (ok) {++this.pos; return ch}
+};
+StringStream.prototype.eatWhile = function (match) {
+ var start = this.pos
+ while (this.eat(match)){}
+ return this.pos > start
+};
+StringStream.prototype.eatSpace = function () {
+ var this$1 = this;
+
+ var start = this.pos
+ while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos }
+ return this.pos > start
+};
+StringStream.prototype.skipToEnd = function () {this.pos = this.string.length};
+StringStream.prototype.skipTo = function (ch) {
+ var found = this.string.indexOf(ch, this.pos)
+ if (found > -1) {this.pos = found; return true}
+};
+StringStream.prototype.backUp = function (n) {this.pos -= n};
+StringStream.prototype.column = function () {
+ if (this.lastColumnPos < this.start) {
+ this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue)
+ this.lastColumnPos = this.start
}
+ return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
+};
+StringStream.prototype.indentation = function () {
+ return countColumn(this.string, null, this.tabSize) -
+ (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
+};
+StringStream.prototype.match = function (pattern, consume, caseInsensitive) {
+ if (typeof pattern == "string") {
+ var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }
+ var substr = this.string.substr(this.pos, pattern.length)
+ if (cased(substr) == cased(pattern)) {
+ if (consume !== false) { this.pos += pattern.length }
+ return true
+ }
+ } else {
+ var match = this.string.slice(this.pos).match(pattern)
+ if (match && match.index > 0) { return null }
+ if (match && consume !== false) { this.pos += match[0].length }
+ return match
+ }
+};
+StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)};
+StringStream.prototype.hideFirstChars = function (n, inner) {
+ this.lineStart += n
+ try { return inner() }
+ finally { this.lineStart -= n }
+};
- function postUpdateDisplay(cm, update) {
- var viewport = update.viewport;
+// Compute a style array (an array starting with a mode generation
+// -- for invalidation -- followed by pairs of end positions and
+// style strings), which is used to highlight the tokens on the
+// line.
+function highlightLine(cm, line, state, forceToEnd) {
+ // A styles array always starts with a number identifying the
+ // mode/overlays that it is based on (for easy invalidation).
+ var st = [cm.state.modeGen], lineClasses = {}
+ // Compute the base array of styles
+ runMode(cm, line.text, cm.doc.mode, state, function (end, style) { return st.push(end, style); },
+ lineClasses, forceToEnd)
+
+ // Run overlays, adjust style array.
+ var loop = function ( o ) {
+ var overlay = cm.state.overlays[o], i = 1, at = 0
+ runMode(cm, line.text, overlay.mode, true, function (end, style) {
+ var start = i
+ // Ensure there's a token end at the current position, and that i points at it
+ while (at < end) {
+ var i_end = st[i]
+ if (i_end > end)
+ { st.splice(i, 1, end, st[i+1], i_end) }
+ i += 2
+ at = Math.min(end, i_end)
+ }
+ if (!style) { return }
+ if (overlay.opaque) {
+ st.splice(start, i - start, end, "overlay " + style)
+ i = start + 2
+ } else {
+ for (; start < i; start += 2) {
+ var cur = st[start+1]
+ st[start+1] = (cur ? cur + " " : "") + "overlay " + style
+ }
+ }
+ }, lineClasses)
+ };
- for (var first = true;; first = false) {
- if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
- // Clip forced viewport to actual scrollable area.
- if (viewport && viewport.top != null)
- viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
- // Updated line heights might result in the drawn area not
- // actually covering the viewport. Keep looping until it does.
- update.visible = visibleLines(cm.display, cm.doc, viewport);
- if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
- break;
+ for (var o = 0; o < cm.state.overlays.length; ++o) loop( o );
+
+ return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}
+}
+
+function getLineStyles(cm, line, updateFrontier) {
+ if (!line.styles || line.styles[0] != cm.state.modeGen) {
+ var state = getStateBefore(cm, lineNo(line))
+ var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state)
+ line.stateAfter = state
+ line.styles = result.styles
+ if (result.classes) { line.styleClasses = result.classes }
+ else if (line.styleClasses) { line.styleClasses = null }
+ if (updateFrontier === cm.doc.frontier) { cm.doc.frontier++ }
+ }
+ return line.styles
+}
+
+function getStateBefore(cm, n, precise) {
+ var doc = cm.doc, display = cm.display
+ if (!doc.mode.startState) { return true }
+ var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter
+ if (!state) { state = startState(doc.mode) }
+ else { state = copyState(doc.mode, state) }
+ doc.iter(pos, n, function (line) {
+ processLine(cm, line.text, state)
+ var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo
+ line.stateAfter = save ? copyState(doc.mode, state) : null
+ ++pos
+ })
+ if (precise) { doc.frontier = pos }
+ return state
+}
+
+// Lightweight form of highlight -- proceed over this line and
+// update state, but don't save a style array. Used for lines that
+// aren't currently visible.
+function processLine(cm, text, state, startAt) {
+ var mode = cm.doc.mode
+ var stream = new StringStream(text, cm.options.tabSize)
+ stream.start = stream.pos = startAt || 0
+ if (text == "") { callBlankLine(mode, state) }
+ while (!stream.eol()) {
+ readToken(mode, stream, state)
+ stream.start = stream.pos
+ }
+}
+
+function callBlankLine(mode, state) {
+ if (mode.blankLine) { return mode.blankLine(state) }
+ if (!mode.innerMode) { return }
+ var inner = innerMode(mode, state)
+ if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) }
+}
+
+function readToken(mode, stream, state, inner) {
+ for (var i = 0; i < 10; i++) {
+ if (inner) { inner[0] = innerMode(mode, state).mode }
+ var style = mode.token(stream, state)
+ if (stream.pos > stream.start) { return style }
+ }
+ throw new Error("Mode " + mode.name + " failed to advance stream.")
+}
+
+// Utility for getTokenAt and getLineTokens
+function takeToken(cm, pos, precise, asArray) {
+ var getObj = function (copy) { return ({
+ start: stream.start, end: stream.pos,
+ string: stream.current(),
+ type: style || null,
+ state: copy ? copyState(doc.mode, state) : state
+ }); }
+
+ var doc = cm.doc, mode = doc.mode, style
+ pos = clipPos(doc, pos)
+ var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise)
+ var stream = new StringStream(line.text, cm.options.tabSize), tokens
+ if (asArray) { tokens = [] }
+ while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
+ stream.start = stream.pos
+ style = readToken(mode, stream, state)
+ if (asArray) { tokens.push(getObj(true)) }
+ }
+ return asArray ? tokens : getObj()
+}
+
+function extractLineClasses(type, output) {
+ if (type) { for (;;) {
+ var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/)
+ if (!lineClass) { break }
+ type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length)
+ var prop = lineClass[1] ? "bgClass" : "textClass"
+ if (output[prop] == null)
+ { output[prop] = lineClass[2] }
+ else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
+ { output[prop] += " " + lineClass[2] }
+ } }
+ return type
+}
+
+// Run the given mode's parser over a line, calling f for each token.
+function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
+ var flattenSpans = mode.flattenSpans
+ if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans }
+ var curStart = 0, curStyle = null
+ var stream = new StringStream(text, cm.options.tabSize), style
+ var inner = cm.options.addModeClass && [null]
+ if (text == "") { extractLineClasses(callBlankLine(mode, state), lineClasses) }
+ while (!stream.eol()) {
+ if (stream.pos > cm.options.maxHighlightLength) {
+ flattenSpans = false
+ if (forceToEnd) { processLine(cm, text, state, stream.pos) }
+ stream.pos = text.length
+ style = null
+ } else {
+ style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses)
+ }
+ if (inner) {
+ var mName = inner[0].name
+ if (mName) { style = "m-" + (style ? mName + " " + style : mName) }
+ }
+ if (!flattenSpans || curStyle != style) {
+ while (curStart < stream.start) {
+ curStart = Math.min(stream.start, curStart + 5000)
+ f(curStart, curStyle)
}
- if (!updateDisplayIfNeeded(cm, update)) break;
- updateHeightsInViewport(cm);
- var barMeasure = measureForScrollbars(cm);
- updateSelection(cm);
- updateScrollbars(cm, barMeasure);
- setDocumentHeight(cm, barMeasure);
+ curStyle = style
}
+ stream.start = stream.pos
+ }
+ while (curStart < stream.pos) {
+ // Webkit seems to refuse to render text nodes longer than 57444
+ // characters, and returns inaccurate measurements in nodes
+ // starting around 5000 chars.
+ var pos = Math.min(stream.pos, curStart + 5000)
+ f(pos, curStyle)
+ curStart = pos
+ }
+}
- update.signal(cm, "update", cm);
- if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
- update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
- cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
+// Finds the line to start with when starting a parse. Tries to
+// find a line with a stateAfter, so that it can start with a
+// valid state. If that fails, it returns the line with the
+// smallest indentation, which tends to need the least context to
+// parse correctly.
+function findStartLine(cm, n, precise) {
+ var minindent, minline, doc = cm.doc
+ var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100)
+ for (var search = n; search > lim; --search) {
+ if (search <= doc.first) { return doc.first }
+ var line = getLine(doc, search - 1)
+ if (line.stateAfter && (!precise || search <= doc.frontier)) { return search }
+ var indented = countColumn(line.text, null, cm.options.tabSize)
+ if (minline == null || minindent > indented) {
+ minline = search - 1
+ minindent = indented
}
}
+ return minline
+}
+
+// LINE DATA STRUCTURE
+
+// Line objects. These hold state related to a line, including
+// highlighting info (the styles array).
+var Line = function(text, markedSpans, estimateHeight) {
+ this.text = text
+ attachMarkedSpans(this, markedSpans)
+ this.height = estimateHeight ? estimateHeight(this) : 1
+};
- function updateDisplaySimple(cm, viewport) {
- var update = new DisplayUpdate(cm, viewport);
- if (updateDisplayIfNeeded(cm, update)) {
- updateHeightsInViewport(cm);
- postUpdateDisplay(cm, update);
- var barMeasure = measureForScrollbars(cm);
- updateSelection(cm);
- updateScrollbars(cm, barMeasure);
- setDocumentHeight(cm, barMeasure);
- update.finish();
+Line.prototype.lineNo = function () { return lineNo(this) };
+eventMixin(Line)
+
+// Change the content (text, markers) of a line. Automatically
+// invalidates cached information and tries to re-estimate the
+// line's height.
+function updateLine(line, text, markedSpans, estimateHeight) {
+ line.text = text
+ if (line.stateAfter) { line.stateAfter = null }
+ if (line.styles) { line.styles = null }
+ if (line.order != null) { line.order = null }
+ detachMarkedSpans(line)
+ attachMarkedSpans(line, markedSpans)
+ var estHeight = estimateHeight ? estimateHeight(line) : 1
+ if (estHeight != line.height) { updateLineHeight(line, estHeight) }
+}
+
+// Detach a line from the document tree and its markers.
+function cleanUpLine(line) {
+ line.parent = null
+ detachMarkedSpans(line)
+}
+
+// Convert a style as returned by a mode (either null, or a string
+// containing one or more styles) to a CSS style. This is cached,
+// and also looks for line-wide styles.
+var styleToClassCache = {};
+var styleToClassCacheWithMode = {};
+function interpretTokenStyle(style, options) {
+ if (!style || /^\s*$/.test(style)) { return null }
+ var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache
+ return cache[style] ||
+ (cache[style] = style.replace(/\S+/g, "cm-$&"))
+}
+
+// Render the DOM representation of the text of a line. Also builds
+// up a 'line map', which points at the DOM nodes that represent
+// specific stretches of text, and is used by the measuring code.
+// The returned object contains the DOM node, this map, and
+// information about line-wide styles that were set by the mode.
+function buildLineContent(cm, lineView) {
+ // The padding-right forces the element to have a 'border', which
+ // is needed on Webkit to be able to get line-level bounding
+ // rectangles for it (in measureChar).
+ var content = elt("span", null, null, webkit ? "padding-right: .1px" : null)
+ var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
+ col: 0, pos: 0, cm: cm,
+ trailingSpace: false,
+ splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}
+ // hide from accessibility tree
+ content.setAttribute("role", "presentation")
+ builder.pre.setAttribute("role", "presentation")
+ lineView.measure = {}
+
+ // Iterate over the logical lines that make up this visual line.
+ for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
+ var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0)
+ builder.pos = 0
+ builder.addToken = buildToken
+ // Optionally wire in some hacks into the token-rendering
+ // algorithm, to deal with browser quirks.
+ if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
+ { builder.addToken = buildTokenBadBidi(builder.addToken, order) }
+ builder.map = []
+ var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line)
+ insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate))
+ if (line.styleClasses) {
+ if (line.styleClasses.bgClass)
+ { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "") }
+ if (line.styleClasses.textClass)
+ { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "") }
+ }
+
+ // Ensure at least a single node is present, for measuring.
+ if (builder.map.length == 0)
+ { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))) }
+
+ // Store the map and a cache object for the current logical line
+ if (i == 0) {
+ lineView.measure.map = builder.map
+ lineView.measure.cache = {}
+ } else {
+ ;(lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map)
+ ;(lineView.measure.caches || (lineView.measure.caches = [])).push({})
}
}
- function setDocumentHeight(cm, measure) {
- cm.display.sizer.style.minHeight = measure.docHeight + "px";
- cm.display.heightForcer.style.top = measure.docHeight + "px";
- cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
+ // See issue #2901
+ if (webkit) {
+ var last = builder.content.lastChild
+ if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
+ { builder.content.className = "cm-tab-wrap-hack" }
}
- // Read the actual heights of the rendered lines, and update their
- // stored heights to match.
- function updateHeightsInViewport(cm) {
- var display = cm.display;
- var prevBottom = display.lineDiv.offsetTop;
- for (var i = 0; i < display.view.length; i++) {
- var cur = display.view[i], height;
- if (cur.hidden) continue;
- if (ie && ie_version < 8) {
- var bot = cur.node.offsetTop + cur.node.offsetHeight;
- height = bot - prevBottom;
- prevBottom = bot;
+ signal(cm, "renderLine", cm, lineView.line, builder.pre)
+ if (builder.pre.className)
+ { builder.textClass = joinClasses(builder.pre.className, builder.textClass || "") }
+
+ return builder
+}
+
+function defaultSpecialCharPlaceholder(ch) {
+ var token = elt("span", "\u2022", "cm-invalidchar")
+ token.title = "\\u" + ch.charCodeAt(0).toString(16)
+ token.setAttribute("aria-label", token.title)
+ return token
+}
+
+// Build up the DOM representation for a single token, and add it to
+// the line map. Takes care to render special characters separately.
+function buildToken(builder, text, style, startStyle, endStyle, title, css) {
+ if (!text) { return }
+ var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text
+ var special = builder.cm.state.specialChars, mustWrap = false
+ var content
+ if (!special.test(text)) {
+ builder.col += text.length
+ content = document.createTextNode(displayText)
+ builder.map.push(builder.pos, builder.pos + text.length, content)
+ if (ie && ie_version < 9) { mustWrap = true }
+ builder.pos += text.length
+ } else {
+ content = document.createDocumentFragment()
+ var pos = 0
+ while (true) {
+ special.lastIndex = pos
+ var m = special.exec(text)
+ var skipped = m ? m.index - pos : text.length - pos
+ if (skipped) {
+ var txt = document.createTextNode(displayText.slice(pos, pos + skipped))
+ if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])) }
+ else { content.appendChild(txt) }
+ builder.map.push(builder.pos, builder.pos + skipped, txt)
+ builder.col += skipped
+ builder.pos += skipped
+ }
+ if (!m) { break }
+ pos += skipped + 1
+ var txt$1 = (void 0)
+ if (m[0] == "\t") {
+ var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize
+ txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"))
+ txt$1.setAttribute("role", "presentation")
+ txt$1.setAttribute("cm-text", "\t")
+ builder.col += tabWidth
+ } else if (m[0] == "\r" || m[0] == "\n") {
+ txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"))
+ txt$1.setAttribute("cm-text", m[0])
+ builder.col += 1
} else {
- var box = cur.node.getBoundingClientRect();
- height = box.bottom - box.top;
- }
- var diff = cur.line.height - height;
- if (height < 2) height = textHeight(display);
- if (diff > .001 || diff < -.001) {
- updateLineHeight(cur.line, height);
- updateWidgetHeight(cur.line);
- if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
- updateWidgetHeight(cur.rest[j]);
- }
- }
- }
-
- // Read and store the height of line widgets associated with the
- // given line.
- function updateWidgetHeight(line) {
- if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
- line.widgets[i].height = line.widgets[i].node.parentNode.offsetHeight;
- }
-
- // Do a bulk-read of the DOM positions and sizes needed to draw the
- // view, so that we don't interleave reading and writing to the DOM.
- function getDimensions(cm) {
- var d = cm.display, left = {}, width = {};
- var gutterLeft = d.gutters.clientLeft;
- for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
- left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
- width[cm.options.gutters[i]] = n.clientWidth;
- }
- return {fixedPos: compensateForHScroll(d),
- gutterTotalWidth: d.gutters.offsetWidth,
- gutterLeft: left,
- gutterWidth: width,
- wrapperWidth: d.wrapper.clientWidth};
- }
-
- // Sync the actual display DOM structure with display.view, removing
- // nodes for lines that are no longer in view, and creating the ones
- // that are not there yet, and updating the ones that are out of
- // date.
- function patchDisplay(cm, updateNumbersFrom, dims) {
- var display = cm.display, lineNumbers = cm.options.lineNumbers;
- var container = display.lineDiv, cur = container.firstChild;
-
- function rm(node) {
- var next = node.nextSibling;
- // Works around a throw-scroll bug in OS X Webkit
- if (webkit && mac && cm.display.currentWheelTarget == node)
- node.style.display = "none";
- else
- node.parentNode.removeChild(node);
- return next;
- }
-
- var view = display.view, lineN = display.viewFrom;
- // Loop over the elements in the view, syncing cur (the DOM nodes
- // in display.lineDiv) with the view as we go.
- for (var i = 0; i < view.length; i++) {
- var lineView = view[i];
- if (lineView.hidden) {
- } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
- var node = buildLineElement(cm, lineView, lineN, dims);
- container.insertBefore(node, cur);
- } else { // Already drawn
- while (cur != lineView.node) cur = rm(cur);
- var updateNumber = lineNumbers && updateNumbersFrom != null &&
- updateNumbersFrom <= lineN && lineView.lineNumber;
- if (lineView.changes) {
- if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
- updateLineForChanges(cm, lineView, lineN, dims);
- }
- if (updateNumber) {
- removeChildren(lineView.lineNumber);
- lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
- }
- cur = lineView.node.nextSibling;
- }
- lineN += lineView.size;
- }
- while (cur) cur = rm(cur);
- }
-
- // When an aspect of a line changes, a string is added to
- // lineView.changes. This updates the relevant part of the line's
- // DOM structure.
- function updateLineForChanges(cm, lineView, lineN, dims) {
- for (var j = 0; j < lineView.changes.length; j++) {
- var type = lineView.changes[j];
- if (type == "text") updateLineText(cm, lineView);
- else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
- else if (type == "class") updateLineClasses(lineView);
- else if (type == "widget") updateLineWidgets(cm, lineView, dims);
- }
- lineView.changes = null;
- }
-
- // Lines with gutter elements, widgets or a background class need to
- // be wrapped, and have the extra elements added to the wrapper div
- function ensureLineWrapped(lineView) {
- if (lineView.node == lineView.text) {
- lineView.node = elt("div", null, null, "position: relative");
- if (lineView.text.parentNode)
- lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
- lineView.node.appendChild(lineView.text);
- if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
- }
- return lineView.node;
- }
-
- function updateLineBackground(lineView) {
- var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
- if (cls) cls += " CodeMirror-linebackground";
- if (lineView.background) {
- if (cls) lineView.background.className = cls;
- else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
- } else if (cls) {
- var wrap = ensureLineWrapped(lineView);
- lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
- }
- }
-
- // Wrapper around buildLineContent which will reuse the structure
- // in display.externalMeasured when possible.
- function getLineContent(cm, lineView) {
- var ext = cm.display.externalMeasured;
- if (ext && ext.line == lineView.line) {
- cm.display.externalMeasured = null;
- lineView.measure = ext.measure;
- return ext.built;
- }
- return buildLineContent(cm, lineView);
- }
-
- // Redraw the line's text. Interacts with the background and text
- // classes because the mode may output tokens that influence these
- // classes.
- function updateLineText(cm, lineView) {
- var cls = lineView.text.className;
- var built = getLineContent(cm, lineView);
- if (lineView.text == lineView.node) lineView.node = built.pre;
- lineView.text.parentNode.replaceChild(built.pre, lineView.text);
- lineView.text = built.pre;
- if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
- lineView.bgClass = built.bgClass;
- lineView.textClass = built.textClass;
- updateLineClasses(lineView);
- } else if (cls) {
- lineView.text.className = cls;
- }
- }
-
- function updateLineClasses(lineView) {
- updateLineBackground(lineView);
- if (lineView.line.wrapClass)
- ensureLineWrapped(lineView).className = lineView.line.wrapClass;
- else if (lineView.node != lineView.text)
- lineView.node.className = "";
- var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
- lineView.text.className = textClass || "";
- }
-
- function updateLineGutter(cm, lineView, lineN, dims) {
- if (lineView.gutter) {
- lineView.node.removeChild(lineView.gutter);
- lineView.gutter = null;
- }
- if (lineView.gutterBackground) {
- lineView.node.removeChild(lineView.gutterBackground);
- lineView.gutterBackground = null;
- }
- if (lineView.line.gutterClass) {
- var wrap = ensureLineWrapped(lineView);
- lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
- "left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
- "px; width: " + dims.gutterTotalWidth + "px");
- wrap.insertBefore(lineView.gutterBackground, lineView.text);
- }
- var markers = lineView.line.gutterMarkers;
- if (cm.options.lineNumbers || markers) {
- var wrap = ensureLineWrapped(lineView);
- var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
- (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px");
- cm.display.input.setUneditable(gutterWrap);
- wrap.insertBefore(gutterWrap, lineView.text);
- if (lineView.line.gutterClass)
- gutterWrap.className += " " + lineView.line.gutterClass;
- if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
- lineView.lineNumber = gutterWrap.appendChild(
- elt("div", lineNumberFor(cm.options, lineN),
- "CodeMirror-linenumber CodeMirror-gutter-elt",
- "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: "
- + cm.display.lineNumInnerWidth + "px"));
- if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) {
- var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
- if (found)
- gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " +
- dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px"));
- }
- }
- }
-
- function updateLineWidgets(cm, lineView, dims) {
- if (lineView.alignable) lineView.alignable = null;
- for (var node = lineView.node.firstChild, next; node; node = next) {
- var next = node.nextSibling;
- if (node.className == "CodeMirror-linewidget")
- lineView.node.removeChild(node);
- }
- insertLineWidgets(cm, lineView, dims);
- }
-
- // Build a line's DOM representation from scratch
- function buildLineElement(cm, lineView, lineN, dims) {
- var built = getLineContent(cm, lineView);
- lineView.text = lineView.node = built.pre;
- if (built.bgClass) lineView.bgClass = built.bgClass;
- if (built.textClass) lineView.textClass = built.textClass;
-
- updateLineClasses(lineView);
- updateLineGutter(cm, lineView, lineN, dims);
- insertLineWidgets(cm, lineView, dims);
- return lineView.node;
- }
-
- // A lineView may contain multiple logical lines (when merged by
- // collapsed spans). The widgets for all of them need to be drawn.
- function insertLineWidgets(cm, lineView, dims) {
- insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
- if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
- insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false);
- }
-
- function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
- if (!line.widgets) return;
- var wrap = ensureLineWrapped(lineView);
- for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
- var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
- if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true");
- positionLineWidget(widget, node, lineView, dims);
- cm.display.input.setUneditable(node);
- if (allowAbove && widget.above)
- wrap.insertBefore(node, lineView.gutter || lineView.text);
- else
- wrap.appendChild(node);
- signalLater(widget, "redraw");
- }
- }
+ txt$1 = builder.cm.options.specialCharPlaceholder(m[0])
+ txt$1.setAttribute("cm-text", m[0])
+ if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])) }
+ else { content.appendChild(txt$1) }
+ builder.col += 1
+ }
+ builder.map.push(builder.pos, builder.pos + 1, txt$1)
+ builder.pos++
+ }
+ }
+ builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32
+ if (style || startStyle || endStyle || mustWrap || css) {
+ var fullStyle = style || ""
+ if (startStyle) { fullStyle += startStyle }
+ if (endStyle) { fullStyle += endStyle }
+ var token = elt("span", [content], fullStyle, css)
+ if (title) { token.title = title }
+ return builder.content.appendChild(token)
+ }
+ builder.content.appendChild(content)
+}
+
+function splitSpaces(text, trailingBefore) {
+ if (text.length > 1 && !/ /.test(text)) { return text }
+ var spaceBefore = trailingBefore, result = ""
+ for (var i = 0; i < text.length; i++) {
+ var ch = text.charAt(i)
+ if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
+ { ch = "\u00a0" }
+ result += ch
+ spaceBefore = ch == " "
+ }
+ return result
+}
+
+// Work around nonsense dimensions being reported for stretches of
+// right-to-left text.
+function buildTokenBadBidi(inner, order) {
+ return function (builder, text, style, startStyle, endStyle, title, css) {
+ style = style ? style + " cm-force-border" : "cm-force-border"
+ var start = builder.pos, end = start + text.length
+ for (;;) {
+ // Find the part that overlaps with the start of this text
+ var part = (void 0)
+ for (var i = 0; i < order.length; i++) {
+ part = order[i]
+ if (part.to > start && part.from <= start) { break }
+ }
+ if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, title, css) }
+ inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css)
+ startStyle = null
+ text = text.slice(part.to - start)
+ start = part.to
+ }
+ }
+}
+
+function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
+ var widget = !ignoreWidget && marker.widgetNode
+ if (widget) { builder.map.push(builder.pos, builder.pos + size, widget) }
+ if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
+ if (!widget)
+ { widget = builder.content.appendChild(document.createElement("span")) }
+ widget.setAttribute("cm-marker", marker.id)
+ }
+ if (widget) {
+ builder.cm.display.input.setUneditable(widget)
+ builder.content.appendChild(widget)
+ }
+ builder.pos += size
+ builder.trailingSpace = false
+}
+
+// Outputs a number of spans to make up a line, taking highlighting
+// and marked text into account.
+function insertLineContent(line, builder, styles) {
+ var spans = line.markedSpans, allText = line.text, at = 0
+ if (!spans) {
+ for (var i$1 = 1; i$1 < styles.length; i$1+=2)
+ { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)) }
+ return
+ }
+
+ var len = allText.length, pos = 0, i = 1, text = "", style, css
+ var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed
+ for (;;) {
+ if (nextChange == pos) { // Update current marker set
+ spanStyle = spanEndStyle = spanStartStyle = title = css = ""
+ collapsed = null; nextChange = Infinity
+ var foundBookmarks = [], endStyles = (void 0)
+ for (var j = 0; j < spans.length; ++j) {
+ var sp = spans[j], m = sp.marker
+ if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
+ foundBookmarks.push(m)
+ } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
+ if (sp.to != null && sp.to != pos && nextChange > sp.to) {
+ nextChange = sp.to
+ spanEndStyle = ""
+ }
+ if (m.className) { spanStyle += " " + m.className }
+ if (m.css) { css = (css ? css + ";" : "") + m.css }
+ if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle }
+ if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to) }
+ if (m.title && !title) { title = m.title }
+ if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
+ { collapsed = sp }
+ } else if (sp.from > pos && nextChange > sp.from) {
+ nextChange = sp.from
+ }
+ }
+ if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2)
+ { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1] } } }
- function positionLineWidget(widget, node, lineView, dims) {
- if (widget.noHScroll) {
- (lineView.alignable || (lineView.alignable = [])).push(node);
- var width = dims.wrapperWidth;
- node.style.left = dims.fixedPos + "px";
- if (!widget.coverGutter) {
- width -= dims.gutterTotalWidth;
- node.style.paddingLeft = dims.gutterTotalWidth + "px";
+ if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2)
+ { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]) } }
+ if (collapsed && (collapsed.from || 0) == pos) {
+ buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
+ collapsed.marker, collapsed.from == null)
+ if (collapsed.to == null) { return }
+ if (collapsed.to == pos) { collapsed = false }
}
- node.style.width = width + "px";
}
- if (widget.coverGutter) {
- node.style.zIndex = 5;
- node.style.position = "relative";
- if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px";
+ if (pos >= len) { break }
+
+ var upto = Math.min(len, nextChange)
+ while (true) {
+ if (text) {
+ var end = pos + text.length
+ if (!collapsed) {
+ var tokenText = end > upto ? text.slice(0, upto - pos) : text
+ builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
+ spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css)
+ }
+ if (end >= upto) {text = text.slice(upto - pos); pos = upto; break}
+ pos = end
+ spanStartStyle = ""
+ }
+ text = allText.slice(at, at = styles[i++])
+ style = interpretTokenStyle(styles[i++], builder.cm.options)
}
}
+}
- // POSITION OBJECT
- // A Pos instance represents a position within the text.
- var Pos = CodeMirror.Pos = function(line, ch) {
- if (!(this instanceof Pos)) return new Pos(line, ch);
- this.line = line; this.ch = ch;
- };
+// These objects are used to represent the visible (currently drawn)
+// part of the document. A LineView may correspond to multiple
+// logical lines, if those are connected by collapsed ranges.
+function LineView(doc, line, lineN) {
+ // The starting line
+ this.line = line
+ // Continuing lines, if any
+ this.rest = visualLineContinued(line)
+ // Number of logical lines in this visual line
+ this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1
+ this.node = this.text = null
+ this.hidden = lineIsHidden(doc, line)
+}
- // Compare two positions, return 0 if they are the same, a negative
- // number when a is less, and a positive number otherwise.
- var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; };
-
- function copyPos(x) {return Pos(x.line, x.ch);}
- function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; }
- function minPos(a, b) { return cmp(a, b) < 0 ? a : b; }
-
- // INPUT HANDLING
-
- function ensureFocus(cm) {
- if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
- }
-
- // This will be set to a {lineWise: bool, text: [string]} object, so
- // that, when pasting, we know what kind of selections the copied
- // text was made out of.
- var lastCopied = null;
-
- function applyTextInput(cm, inserted, deleted, sel, origin) {
- var doc = cm.doc;
- cm.display.shift = false;
- if (!sel) sel = doc.sel;
-
- var paste = cm.state.pasteIncoming || origin == "paste";
- var textLines = doc.splitLines(inserted), multiPaste = null
- // When pasing N lines into N selections, insert one line per selection
- if (paste && sel.ranges.length > 1) {
- if (lastCopied && lastCopied.text.join("\n") == inserted) {
- if (sel.ranges.length % lastCopied.text.length == 0) {
- multiPaste = [];
- for (var i = 0; i < lastCopied.text.length; i++)
- multiPaste.push(doc.splitLines(lastCopied.text[i]));
- }
- } else if (textLines.length == sel.ranges.length) {
- multiPaste = map(textLines, function(l) { return [l]; });
- }
- }
-
- // Normal behavior is to insert the new text into every selection
- for (var i = sel.ranges.length - 1; i >= 0; i--) {
- var range = sel.ranges[i];
- var from = range.from(), to = range.to();
- if (range.empty()) {
- if (deleted && deleted > 0) // Handle deletion
- from = Pos(from.line, from.ch - deleted);
- else if (cm.state.overwrite && !paste) // Handle overwrite
- to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length));
- else if (lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
- from = to = Pos(from.line, 0)
- }
- var updateInput = cm.curOp.updateInput;
- var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines,
- origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
- makeChange(cm.doc, changeEvent);
- signalLater(cm, "inputRead", cm, changeEvent);
- }
- if (inserted && !paste)
- triggerElectric(cm, inserted);
-
- ensureCursorVisible(cm);
- cm.curOp.updateInput = updateInput;
- cm.curOp.typing = true;
- cm.state.pasteIncoming = cm.state.cutIncoming = false;
- }
-
- function handlePaste(e, cm) {
- var pasted = e.clipboardData && e.clipboardData.getData("text/plain");
- if (pasted) {
- e.preventDefault();
- if (!cm.isReadOnly() && !cm.options.disableInput)
- runInOp(cm, function() { applyTextInput(cm, pasted, 0, null, "paste"); });
- return true;
- }
+// Create a range of LineView objects for the given lines.
+function buildViewArray(cm, from, to) {
+ var array = [], nextPos
+ for (var pos = from; pos < to; pos = nextPos) {
+ var view = new LineView(cm.doc, getLine(cm.doc, pos), pos)
+ nextPos = pos + view.size
+ array.push(view)
}
+ return array
+}
- function triggerElectric(cm, inserted) {
- // When an 'electric' character is inserted, immediately trigger a reindent
- if (!cm.options.electricChars || !cm.options.smartIndent) return;
- var sel = cm.doc.sel;
+var operationGroup = null
- for (var i = sel.ranges.length - 1; i >= 0; i--) {
- var range = sel.ranges[i];
- if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) continue;
- var mode = cm.getModeAt(range.head);
- var indented = false;
- if (mode.electricChars) {
- for (var j = 0; j < mode.electricChars.length; j++)
- if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
- indented = indentLine(cm, range.head.line, "smart");
- break;
- }
- } else if (mode.electricInput) {
- if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
- indented = indentLine(cm, range.head.line, "smart");
- }
- if (indented) signalLater(cm, "electricInput", cm, range.head.line);
+function pushOperation(op) {
+ if (operationGroup) {
+ operationGroup.ops.push(op)
+ } else {
+ op.ownsGroup = operationGroup = {
+ ops: [op],
+ delayedCallbacks: []
}
}
+}
- function copyableRanges(cm) {
- var text = [], ranges = [];
- for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
- var line = cm.doc.sel.ranges[i].head.line;
- var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
- ranges.push(lineRange);
- text.push(cm.getRange(lineRange.anchor, lineRange.head));
- }
- return {text: text, ranges: ranges};
+function fireCallbacksForOps(group) {
+ // Calls delayed callbacks and cursorActivity handlers until no
+ // new ones appear
+ var callbacks = group.delayedCallbacks, i = 0
+ do {
+ for (; i < callbacks.length; i++)
+ { callbacks[i].call(null) }
+ for (var j = 0; j < group.ops.length; j++) {
+ var op = group.ops[j]
+ if (op.cursorActivityHandlers)
+ { while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
+ { op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm) } }
+ }
+ } while (i < callbacks.length)
+}
+
+function finishOperation(op, endCb) {
+ var group = op.ownsGroup
+ if (!group) { return }
+
+ try { fireCallbacksForOps(group) }
+ finally {
+ operationGroup = null
+ endCb(group)
+ }
+}
+
+var orphanDelayedCallbacks = null
+
+// Often, we want to signal events at a point where we are in the
+// middle of some work, but don't want the handler to start calling
+// other methods on the editor, which might be in an inconsistent
+// state or simply not expect any other events to happen.
+// signalLater looks whether there are any handlers, and schedules
+// them to be executed when the last operation ends, or, if no
+// operation is active, when a timeout fires.
+function signalLater(emitter, type /*, values...*/) {
+ var arr = getHandlers(emitter, type)
+ if (!arr.length) { return }
+ var args = Array.prototype.slice.call(arguments, 2), list
+ if (operationGroup) {
+ list = operationGroup.delayedCallbacks
+ } else if (orphanDelayedCallbacks) {
+ list = orphanDelayedCallbacks
+ } else {
+ list = orphanDelayedCallbacks = []
+ setTimeout(fireOrphanDelayed, 0)
}
+ var loop = function ( i ) {
+ list.push(function () { return arr[i].apply(null, args); })
+ };
- function disableBrowserMagic(field) {
- field.setAttribute("autocorrect", "off");
- field.setAttribute("autocapitalize", "off");
- field.setAttribute("spellcheck", "false");
+ for (var i = 0; i < arr.length; ++i)
+ loop( i );
+}
+
+function fireOrphanDelayed() {
+ var delayed = orphanDelayedCallbacks
+ orphanDelayedCallbacks = null
+ for (var i = 0; i < delayed.length; ++i) { delayed[i]() }
+}
+
+// When an aspect of a line changes, a string is added to
+// lineView.changes. This updates the relevant part of the line's
+// DOM structure.
+function updateLineForChanges(cm, lineView, lineN, dims) {
+ for (var j = 0; j < lineView.changes.length; j++) {
+ var type = lineView.changes[j]
+ if (type == "text") { updateLineText(cm, lineView) }
+ else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims) }
+ else if (type == "class") { updateLineClasses(lineView) }
+ else if (type == "widget") { updateLineWidgets(cm, lineView, dims) }
+ }
+ lineView.changes = null
+}
+
+// Lines with gutter elements, widgets or a background class need to
+// be wrapped, and have the extra elements added to the wrapper div
+function ensureLineWrapped(lineView) {
+ if (lineView.node == lineView.text) {
+ lineView.node = elt("div", null, null, "position: relative")
+ if (lineView.text.parentNode)
+ { lineView.text.parentNode.replaceChild(lineView.node, lineView.text) }
+ lineView.node.appendChild(lineView.text)
+ if (ie && ie_version < 8) { lineView.node.style.zIndex = 2 }
+ }
+ return lineView.node
+}
+
+function updateLineBackground(lineView) {
+ var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass
+ if (cls) { cls += " CodeMirror-linebackground" }
+ if (lineView.background) {
+ if (cls) { lineView.background.className = cls }
+ else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null }
+ } else if (cls) {
+ var wrap = ensureLineWrapped(lineView)
+ lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild)
+ }
+}
+
+// Wrapper around buildLineContent which will reuse the structure
+// in display.externalMeasured when possible.
+function getLineContent(cm, lineView) {
+ var ext = cm.display.externalMeasured
+ if (ext && ext.line == lineView.line) {
+ cm.display.externalMeasured = null
+ lineView.measure = ext.measure
+ return ext.built
+ }
+ return buildLineContent(cm, lineView)
+}
+
+// Redraw the line's text. Interacts with the background and text
+// classes because the mode may output tokens that influence these
+// classes.
+function updateLineText(cm, lineView) {
+ var cls = lineView.text.className
+ var built = getLineContent(cm, lineView)
+ if (lineView.text == lineView.node) { lineView.node = built.pre }
+ lineView.text.parentNode.replaceChild(built.pre, lineView.text)
+ lineView.text = built.pre
+ if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
+ lineView.bgClass = built.bgClass
+ lineView.textClass = built.textClass
+ updateLineClasses(lineView)
+ } else if (cls) {
+ lineView.text.className = cls
+ }
+}
+
+function updateLineClasses(lineView) {
+ updateLineBackground(lineView)
+ if (lineView.line.wrapClass)
+ { ensureLineWrapped(lineView).className = lineView.line.wrapClass }
+ else if (lineView.node != lineView.text)
+ { lineView.node.className = "" }
+ var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass
+ lineView.text.className = textClass || ""
+}
+
+function updateLineGutter(cm, lineView, lineN, dims) {
+ if (lineView.gutter) {
+ lineView.node.removeChild(lineView.gutter)
+ lineView.gutter = null
+ }
+ if (lineView.gutterBackground) {
+ lineView.node.removeChild(lineView.gutterBackground)
+ lineView.gutterBackground = null
+ }
+ if (lineView.line.gutterClass) {
+ var wrap = ensureLineWrapped(lineView)
+ lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
+ ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px"))
+ wrap.insertBefore(lineView.gutterBackground, lineView.text)
+ }
+ var markers = lineView.line.gutterMarkers
+ if (cm.options.lineNumbers || markers) {
+ var wrap$1 = ensureLineWrapped(lineView)
+ var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"))
+ cm.display.input.setUneditable(gutterWrap)
+ wrap$1.insertBefore(gutterWrap, lineView.text)
+ if (lineView.line.gutterClass)
+ { gutterWrap.className += " " + lineView.line.gutterClass }
+ if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
+ { lineView.lineNumber = gutterWrap.appendChild(
+ elt("div", lineNumberFor(cm.options, lineN),
+ "CodeMirror-linenumber CodeMirror-gutter-elt",
+ ("left: " + (dims.gutterLeft["CodeMirror-linenumbers"]) + "px; width: " + (cm.display.lineNumInnerWidth) + "px"))) }
+ if (markers) { for (var k = 0; k < cm.options.gutters.length; ++k) {
+ var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id]
+ if (found)
+ { gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt",
+ ("left: " + (dims.gutterLeft[id]) + "px; width: " + (dims.gutterWidth[id]) + "px"))) }
+ } }
}
+}
- // TEXTAREA INPUT STYLE
+function updateLineWidgets(cm, lineView, dims) {
+ if (lineView.alignable) { lineView.alignable = null }
+ for (var node = lineView.node.firstChild, next = (void 0); node; node = next) {
+ next = node.nextSibling
+ if (node.className == "CodeMirror-linewidget")
+ { lineView.node.removeChild(node) }
+ }
+ insertLineWidgets(cm, lineView, dims)
+}
- function TextareaInput(cm) {
- this.cm = cm;
- // See input.poll and input.reset
- this.prevInput = "";
+// Build a line's DOM representation from scratch
+function buildLineElement(cm, lineView, lineN, dims) {
+ var built = getLineContent(cm, lineView)
+ lineView.text = lineView.node = built.pre
+ if (built.bgClass) { lineView.bgClass = built.bgClass }
+ if (built.textClass) { lineView.textClass = built.textClass }
- // Flag that indicates whether we expect input to appear real soon
- // now (after some event like 'keypress' or 'input') and are
- // polling intensively.
- this.pollingFast = false;
- // Self-resetting timeout for the poller
- this.polling = new Delayed();
- // Tracks when input.reset has punted to just putting a short
- // string into the textarea instead of the full selection.
- this.inaccurateSelection = false;
- // Used to work around IE issue with selection being forgotten when focus moves away from textarea
- this.hasSelection = false;
- this.composing = null;
- };
+ updateLineClasses(lineView)
+ updateLineGutter(cm, lineView, lineN, dims)
+ insertLineWidgets(cm, lineView, dims)
+ return lineView.node
+}
- function hiddenTextarea() {
- var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none");
- var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
- // The textarea is kept positioned near the cursor to prevent the
- // fact that it'll be scrolled into view on input from scrolling
- // our fake cursor out of view. On webkit, when wrap=off, paste is
- // very slow. So make the area wide instead.
- if (webkit) te.style.width = "1000px";
- else te.setAttribute("wrap", "off");
- // If border: 0; -- iOS fails to open keyboard (issue #1287)
- if (ios) te.style.border = "1px solid black";
- disableBrowserMagic(te);
- return div;
- }
-
- TextareaInput.prototype = copyObj({
- init: function(display) {
- var input = this, cm = this.cm;
-
- // Wraps and hides input textarea
- var div = this.wrapper = hiddenTextarea();
- // The semihidden textarea that is focused when the editor is
- // focused, and receives input.
- var te = this.textarea = div.firstChild;
- display.wrapper.insertBefore(div, display.wrapper.firstChild);
-
- // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
- if (ios) te.style.width = "0px";
-
- on(te, "input", function() {
- if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null;
- input.poll();
- });
+// A lineView may contain multiple logical lines (when merged by
+// collapsed spans). The widgets for all of them need to be drawn.
+function insertLineWidgets(cm, lineView, dims) {
+ insertLineWidgetsFor(cm, lineView.line, lineView, dims, true)
+ if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
+ { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false) } }
+}
- on(te, "paste", function(e) {
- if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
+function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
+ if (!line.widgets) { return }
+ var wrap = ensureLineWrapped(lineView)
+ for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
+ var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget")
+ if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true") }
+ positionLineWidget(widget, node, lineView, dims)
+ cm.display.input.setUneditable(node)
+ if (allowAbove && widget.above)
+ { wrap.insertBefore(node, lineView.gutter || lineView.text) }
+ else
+ { wrap.appendChild(node) }
+ signalLater(widget, "redraw")
+ }
+}
- cm.state.pasteIncoming = true;
- input.fastPoll();
- });
+function positionLineWidget(widget, node, lineView, dims) {
+ if (widget.noHScroll) {
+ ;(lineView.alignable || (lineView.alignable = [])).push(node)
+ var width = dims.wrapperWidth
+ node.style.left = dims.fixedPos + "px"
+ if (!widget.coverGutter) {
+ width -= dims.gutterTotalWidth
+ node.style.paddingLeft = dims.gutterTotalWidth + "px"
+ }
+ node.style.width = width + "px"
+ }
+ if (widget.coverGutter) {
+ node.style.zIndex = 5
+ node.style.position = "relative"
+ if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px" }
+ }
+}
- function prepareCopyCut(e) {
- if (signalDOMEvent(cm, e)) return
- if (cm.somethingSelected()) {
- lastCopied = {lineWise: false, text: cm.getSelections()};
- if (input.inaccurateSelection) {
- input.prevInput = "";
- input.inaccurateSelection = false;
- te.value = lastCopied.text.join("\n");
- selectInput(te);
- }
- } else if (!cm.options.lineWiseCopyCut) {
- return;
- } else {
- var ranges = copyableRanges(cm);
- lastCopied = {lineWise: true, text: ranges.text};
- if (e.type == "cut") {
- cm.setSelections(ranges.ranges, null, sel_dontScroll);
- } else {
- input.prevInput = "";
- te.value = ranges.text.join("\n");
- selectInput(te);
- }
- }
- if (e.type == "cut") cm.state.cutIncoming = true;
- }
- on(te, "cut", prepareCopyCut);
- on(te, "copy", prepareCopyCut);
+function widgetHeight(widget) {
+ if (widget.height != null) { return widget.height }
+ var cm = widget.doc.cm
+ if (!cm) { return 0 }
+ if (!contains(document.body, widget.node)) {
+ var parentStyle = "position: relative;"
+ if (widget.coverGutter)
+ { parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;" }
+ if (widget.noHScroll)
+ { parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;" }
+ removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle))
+ }
+ return widget.height = widget.node.parentNode.offsetHeight
+}
+
+// Return true when the given mouse event happened in a widget
+function eventInWidget(display, e) {
+ for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
+ if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
+ (n.parentNode == display.sizer && n != display.mover))
+ { return true }
+ }
+}
+
+// POSITION MEASUREMENT
+
+function paddingTop(display) {return display.lineSpace.offsetTop}
+function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}
+function paddingH(display) {
+ if (display.cachedPaddingH) { return display.cachedPaddingH }
+ var e = removeChildrenAndAdd(display.measure, elt("pre", "x"))
+ var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle
+ var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)}
+ if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data }
+ return data
+}
+
+function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth }
+function displayWidth(cm) {
+ return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth
+}
+function displayHeight(cm) {
+ return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight
+}
+
+// Ensure the lineView.wrapping.heights array is populated. This is
+// an array of bottom offsets for the lines that make up a drawn
+// line. When lineWrapping is on, there might be more than one
+// height.
+function ensureLineHeights(cm, lineView, rect) {
+ var wrapping = cm.options.lineWrapping
+ var curWidth = wrapping && displayWidth(cm)
+ if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
+ var heights = lineView.measure.heights = []
+ if (wrapping) {
+ lineView.measure.width = curWidth
+ var rects = lineView.text.firstChild.getClientRects()
+ for (var i = 0; i < rects.length - 1; i++) {
+ var cur = rects[i], next = rects[i + 1]
+ if (Math.abs(cur.bottom - next.bottom) > 2)
+ { heights.push((cur.bottom + next.top) / 2 - rect.top) }
+ }
+ }
+ heights.push(rect.bottom - rect.top)
+ }
+}
+
+// Find a line map (mapping character offsets to text nodes) and a
+// measurement cache for the given line number. (A line view might
+// contain multiple lines when collapsed ranges are present.)
+function mapFromLineView(lineView, line, lineN) {
+ if (lineView.line == line)
+ { return {map: lineView.measure.map, cache: lineView.measure.cache} }
+ for (var i = 0; i < lineView.rest.length; i++)
+ { if (lineView.rest[i] == line)
+ { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
+ for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
+ { if (lineNo(lineView.rest[i$1]) > lineN)
+ { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
+}
+
+// Render a line into the hidden node display.externalMeasured. Used
+// when measurement is needed for a line that's not in the viewport.
+function updateExternalMeasurement(cm, line) {
+ line = visualLine(line)
+ var lineN = lineNo(line)
+ var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN)
+ view.lineN = lineN
+ var built = view.built = buildLineContent(cm, view)
+ view.text = built.pre
+ removeChildrenAndAdd(cm.display.lineMeasure, built.pre)
+ return view
+}
+
+// Get a {top, bottom, left, right} box (in line-local coordinates)
+// for a given character.
+function measureChar(cm, line, ch, bias) {
+ return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias)
+}
+
+// Find a line view that corresponds to the given line number.
+function findViewForLine(cm, lineN) {
+ if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
+ { return cm.display.view[findViewIndex(cm, lineN)] }
+ var ext = cm.display.externalMeasured
+ if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
+ { return ext }
+}
+
+// Measurement can be split in two steps, the set-up work that
+// applies to the whole line, and the measurement of the actual
+// character. Functions like coordsChar, that need to do a lot of
+// measurements in a row, can thus ensure that the set-up work is
+// only done once.
+function prepareMeasureForLine(cm, line) {
+ var lineN = lineNo(line)
+ var view = findViewForLine(cm, lineN)
+ if (view && !view.text) {
+ view = null
+ } else if (view && view.changes) {
+ updateLineForChanges(cm, view, lineN, getDimensions(cm))
+ cm.curOp.forceUpdate = true
+ }
+ if (!view)
+ { view = updateExternalMeasurement(cm, line) }
+
+ var info = mapFromLineView(view, line, lineN)
+ return {
+ line: line, view: view, rect: null,
+ map: info.map, cache: info.cache, before: info.before,
+ hasHeights: false
+ }
+}
- on(display.scroller, "paste", function(e) {
- if (eventInWidget(display, e) || signalDOMEvent(cm, e)) return;
- cm.state.pasteIncoming = true;
- input.focus();
- });
+// Given a prepared measurement object, measures the position of an
+// actual character (or fetches it from the cache).
+function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
+ if (prepared.before) { ch = -1 }
+ var key = ch + (bias || ""), found
+ if (prepared.cache.hasOwnProperty(key)) {
+ found = prepared.cache[key]
+ } else {
+ if (!prepared.rect)
+ { prepared.rect = prepared.view.text.getBoundingClientRect() }
+ if (!prepared.hasHeights) {
+ ensureLineHeights(cm, prepared.view, prepared.rect)
+ prepared.hasHeights = true
+ }
+ found = measureCharInner(cm, prepared, ch, bias)
+ if (!found.bogus) { prepared.cache[key] = found }
+ }
+ return {left: found.left, right: found.right,
+ top: varHeight ? found.rtop : found.top,
+ bottom: varHeight ? found.rbottom : found.bottom}
+}
+
+var nullRect = {left: 0, right: 0, top: 0, bottom: 0}
+
+function nodeAndOffsetInLineMap(map, ch, bias) {
+ var node, start, end, collapse, mStart, mEnd
+ // First, search the line map for the text node corresponding to,
+ // or closest to, the target character.
+ for (var i = 0; i < map.length; i += 3) {
+ mStart = map[i]
+ mEnd = map[i + 1]
+ if (ch < mStart) {
+ start = 0; end = 1
+ collapse = "left"
+ } else if (ch < mEnd) {
+ start = ch - mStart
+ end = start + 1
+ } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
+ end = mEnd - mStart
+ start = end - 1
+ if (ch >= mEnd) { collapse = "right" }
+ }
+ if (start != null) {
+ node = map[i + 2]
+ if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
+ { collapse = bias }
+ if (bias == "left" && start == 0)
+ { while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
+ node = map[(i -= 3) + 2]
+ collapse = "left"
+ } }
+ if (bias == "right" && start == mEnd - mStart)
+ { while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
+ node = map[(i += 3) + 2]
+ collapse = "right"
+ } }
+ break
+ }
+ }
+ return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}
+}
+
+function getUsefulRect(rects, bias) {
+ var rect = nullRect
+ if (bias == "left") { for (var i = 0; i < rects.length; i++) {
+ if ((rect = rects[i]).left != rect.right) { break }
+ } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) {
+ if ((rect = rects[i$1]).left != rect.right) { break }
+ } }
+ return rect
+}
+
+function measureCharInner(cm, prepared, ch, bias) {
+ var place = nodeAndOffsetInLineMap(prepared.map, ch, bias)
+ var node = place.node, start = place.start, end = place.end, collapse = place.collapse
+
+ var rect
+ if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
+ for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned
+ while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start }
+ while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end }
+ if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)
+ { rect = node.parentNode.getBoundingClientRect() }
+ else
+ { rect = getUsefulRect(range(node, start, end).getClientRects(), bias) }
+ if (rect.left || rect.right || start == 0) { break }
+ end = start
+ start = start - 1
+ collapse = "right"
+ }
+ if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect) }
+ } else { // If it is a widget, simply get the box for the whole widget.
+ if (start > 0) { collapse = bias = "right" }
+ var rects
+ if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
+ { rect = rects[bias == "right" ? rects.length - 1 : 0] }
+ else
+ { rect = node.getBoundingClientRect() }
+ }
+ if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
+ var rSpan = node.parentNode.getClientRects()[0]
+ if (rSpan)
+ { rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom} }
+ else
+ { rect = nullRect }
+ }
+
+ var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top
+ var mid = (rtop + rbot) / 2
+ var heights = prepared.view.measure.heights
+ var i = 0
+ for (; i < heights.length - 1; i++)
+ { if (mid < heights[i]) { break } }
+ var top = i ? heights[i - 1] : 0, bot = heights[i]
+ var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
+ right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
+ top: top, bottom: bot}
+ if (!rect.left && !rect.right) { result.bogus = true }
+ if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot }
+
+ return result
+}
+
+// Work around problem with bounding client rects on ranges being
+// returned incorrectly when zoomed on IE10 and below.
+function maybeUpdateRectForZooming(measure, rect) {
+ if (!window.screen || screen.logicalXDPI == null ||
+ screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
+ { return rect }
+ var scaleX = screen.logicalXDPI / screen.deviceXDPI
+ var scaleY = screen.logicalYDPI / screen.deviceYDPI
+ return {left: rect.left * scaleX, right: rect.right * scaleX,
+ top: rect.top * scaleY, bottom: rect.bottom * scaleY}
+}
+
+function clearLineMeasurementCacheFor(lineView) {
+ if (lineView.measure) {
+ lineView.measure.cache = {}
+ lineView.measure.heights = null
+ if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
+ { lineView.measure.caches[i] = {} } }
+ }
+}
+
+function clearLineMeasurementCache(cm) {
+ cm.display.externalMeasure = null
+ removeChildren(cm.display.lineMeasure)
+ for (var i = 0; i < cm.display.view.length; i++)
+ { clearLineMeasurementCacheFor(cm.display.view[i]) }
+}
+
+function clearCaches(cm) {
+ clearLineMeasurementCache(cm)
+ cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null
+ if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true }
+ cm.display.lineNumChars = null
+}
+
+function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft }
+function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop }
+
+// Converts a {top, bottom, left, right} box from line-local
+// coordinates into another coordinate system. Context may be one of
+// "line", "div" (display.lineDiv), "local"./null (editor), "window",
+// or "page".
+function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {
+ if (!includeWidgets && lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above) {
+ var size = widgetHeight(lineObj.widgets[i])
+ rect.top += size; rect.bottom += size
+ } } }
+ if (context == "line") { return rect }
+ if (!context) { context = "local" }
+ var yOff = heightAtLine(lineObj)
+ if (context == "local") { yOff += paddingTop(cm.display) }
+ else { yOff -= cm.display.viewOffset }
+ if (context == "page" || context == "window") {
+ var lOff = cm.display.lineSpace.getBoundingClientRect()
+ yOff += lOff.top + (context == "window" ? 0 : pageScrollY())
+ var xOff = lOff.left + (context == "window" ? 0 : pageScrollX())
+ rect.left += xOff; rect.right += xOff
+ }
+ rect.top += yOff; rect.bottom += yOff
+ return rect
+}
+
+// Coverts a box from "div" coords to another coordinate system.
+// Context may be "window", "page", "div", or "local"./null.
+function fromCoordSystem(cm, coords, context) {
+ if (context == "div") { return coords }
+ var left = coords.left, top = coords.top
+ // First move into "page" coordinate system
+ if (context == "page") {
+ left -= pageScrollX()
+ top -= pageScrollY()
+ } else if (context == "local" || !context) {
+ var localBox = cm.display.sizer.getBoundingClientRect()
+ left += localBox.left
+ top += localBox.top
+ }
+
+ var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect()
+ return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}
+}
+
+function charCoords(cm, pos, context, lineObj, bias) {
+ if (!lineObj) { lineObj = getLine(cm.doc, pos.line) }
+ return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context)
+}
+
+// Returns a box for a given cursor position, which may have an
+// 'other' property containing the position of the secondary cursor
+// on a bidi boundary.
+// A cursor Pos(line, char, "before") is on the same visual line as `char - 1`
+// and after `char - 1` in writing order of `char - 1`
+// A cursor Pos(line, char, "after") is on the same visual line as `char`
+// and before `char` in writing order of `char`
+// Examples (upper-case letters are RTL, lower-case are LTR):
+// Pos(0, 1, ...)
+// before after
+// ab a|b a|b
+// aB a|B aB|
+// Ab |Ab A|b
+// AB B|A B|A
+// Every position after the last character on a line is considered to stick
+// to the last character on the line.
+function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
+ lineObj = lineObj || getLine(cm.doc, pos.line)
+ if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj) }
+ function get(ch, right) {
+ var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight)
+ if (right) { m.left = m.right; } else { m.right = m.left }
+ return intoCoordSystem(cm, lineObj, m, context)
+ }
+ var order = getOrder(lineObj), ch = pos.ch, sticky = pos.sticky
+ if (ch >= lineObj.text.length) {
+ ch = lineObj.text.length
+ sticky = "before"
+ } else if (ch <= 0) {
+ ch = 0
+ sticky = "after"
+ }
+ if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") }
+
+ function getBidi(ch, partPos, invert) {
+ var part = order[partPos], right = (part.level % 2) != 0
+ return get(invert ? ch - 1 : ch, right != invert)
+ }
+ var partPos = getBidiPartAt(order, ch, sticky)
+ var other = bidiOther
+ var val = getBidi(ch, partPos, sticky == "before")
+ if (other != null) { val.other = getBidi(ch, other, sticky != "before") }
+ return val
+}
+
+// Used to cheaply estimate the coordinates for a position. Used for
+// intermediate scroll updates.
+function estimateCoords(cm, pos) {
+ var left = 0
+ pos = clipPos(cm.doc, pos)
+ if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch }
+ var lineObj = getLine(cm.doc, pos.line)
+ var top = heightAtLine(lineObj) + paddingTop(cm.display)
+ return {left: left, right: left, top: top, bottom: top + lineObj.height}
+}
+
+// Positions returned by coordsChar contain some extra information.
+// xRel is the relative x position of the input coordinates compared
+// to the found position (so xRel > 0 means the coordinates are to
+// the right of the character position, for example). When outside
+// is true, that means the coordinates lie outside the line's
+// vertical range.
+function PosWithInfo(line, ch, sticky, outside, xRel) {
+ var pos = Pos(line, ch, sticky)
+ pos.xRel = xRel
+ if (outside) { pos.outside = true }
+ return pos
+}
+
+// Compute the character position closest to the given coordinates.
+// Input must be lineSpace-local ("div" coordinate system).
+function coordsChar(cm, x, y) {
+ var doc = cm.doc
+ y += cm.display.viewOffset
+ if (y < 0) { return PosWithInfo(doc.first, 0, null, true, -1) }
+ var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1
+ if (lineN > last)
+ { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, true, 1) }
+ if (x < 0) { x = 0 }
+
+ var lineObj = getLine(doc, lineN)
+ for (;;) {
+ var found = coordsCharInner(cm, lineObj, lineN, x, y)
+ var merged = collapsedSpanAtEnd(lineObj)
+ var mergedPos = merged && merged.find(0, true)
+ if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
+ { lineN = lineNo(lineObj = mergedPos.to.line) }
+ else
+ { return found }
+ }
+}
- // Prevent normal selection in the editor (we handle our own)
- on(display.lineSpace, "selectstart", function(e) {
- if (!eventInWidget(display, e)) e_preventDefault(e);
- });
+function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
+ var measure = function (ch) { return intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, ch), "line"); }
+ var end = lineObj.text.length
+ var begin = findFirst(function (ch) { return measure(ch - 1).bottom <= y; }, end, 0)
+ end = findFirst(function (ch) { return measure(ch).top > y; }, begin, end)
+ return {begin: begin, end: end}
+}
- on(te, "compositionstart", function() {
- var start = cm.getCursor("from");
- if (input.composing) input.composing.range.clear()
- input.composing = {
- start: start,
- range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
- };
- });
- on(te, "compositionend", function() {
- if (input.composing) {
- input.poll();
- input.composing.range.clear();
- input.composing = null;
- }
- });
- },
+function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {
+ var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top
+ return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop)
+}
- prepareSelection: function() {
- // Redraw the selection and/or cursor
- var cm = this.cm, display = cm.display, doc = cm.doc;
- var result = prepareSelection(cm);
+function coordsCharInner(cm, lineObj, lineNo, x, y) {
+ y -= heightAtLine(lineObj)
+ var begin = 0, end = lineObj.text.length
+ var preparedMeasure = prepareMeasureForLine(cm, lineObj)
+ var pos
+ var order = getOrder(lineObj)
+ if (order) {
+ if (cm.options.lineWrapping) {
+ ;var assign;
+ ((assign = wrappedLineExtent(cm, lineObj, preparedMeasure, y), begin = assign.begin, end = assign.end, assign))
+ }
+ pos = new Pos(lineNo, begin)
+ var beginLeft = cursorCoords(cm, pos, "line", lineObj, preparedMeasure).left
+ var dir = beginLeft < x ? 1 : -1
+ var prevDiff, diff = beginLeft - x, prevPos
+ do {
+ prevDiff = diff
+ prevPos = pos
+ pos = moveVisually(cm, lineObj, pos, dir)
+ if (pos == null || pos.ch < begin || end <= (pos.sticky == "before" ? pos.ch - 1 : pos.ch)) {
+ pos = prevPos
+ break
+ }
+ diff = cursorCoords(cm, pos, "line", lineObj, preparedMeasure).left - x
+ } while ((dir < 0) != (diff < 0) && (Math.abs(diff) <= Math.abs(prevDiff)))
+ if (Math.abs(diff) > Math.abs(prevDiff)) {
+ if ((diff < 0) == (prevDiff < 0)) { throw new Error("Broke out of infinite loop in coordsCharInner") }
+ pos = prevPos
+ }
+ } else {
+ var ch = findFirst(function (ch) {
+ var box = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, ch), "line")
+ if (box.top > y) {
+ // For the cursor stickiness
+ end = Math.min(ch, end)
+ return true
+ }
+ else if (box.bottom <= y) { return false }
+ else if (box.left > x) { return true }
+ else if (box.right < x) { return false }
+ else { return (x - box.left < box.right - x) }
+ }, begin, end)
+ ch = skipExtendingChars(lineObj.text, ch, 1)
+ pos = new Pos(lineNo, ch, ch == end ? "before" : "after")
+ }
+ var coords = cursorCoords(cm, pos, "line", lineObj, preparedMeasure)
+ if (y < coords.top || coords.bottom < y) { pos.outside = true }
+ pos.xRel = x < coords.left ? -1 : (x > coords.right ? 1 : 0)
+ return pos
+}
+
+var measureText
+// Compute the default text height.
+function textHeight(display) {
+ if (display.cachedTextHeight != null) { return display.cachedTextHeight }
+ if (measureText == null) {
+ measureText = elt("pre")
+ // Measure a bunch of lines, for browsers that compute
+ // fractional heights.
+ for (var i = 0; i < 49; ++i) {
+ measureText.appendChild(document.createTextNode("x"))
+ measureText.appendChild(elt("br"))
+ }
+ measureText.appendChild(document.createTextNode("x"))
+ }
+ removeChildrenAndAdd(display.measure, measureText)
+ var height = measureText.offsetHeight / 50
+ if (height > 3) { display.cachedTextHeight = height }
+ removeChildren(display.measure)
+ return height || 1
+}
+
+// Compute the default character width.
+function charWidth(display) {
+ if (display.cachedCharWidth != null) { return display.cachedCharWidth }
+ var anchor = elt("span", "xxxxxxxxxx")
+ var pre = elt("pre", [anchor])
+ removeChildrenAndAdd(display.measure, pre)
+ var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10
+ if (width > 2) { display.cachedCharWidth = width }
+ return width || 10
+}
+
+// Do a bulk-read of the DOM positions and sizes needed to draw the
+// view, so that we don't interleave reading and writing to the DOM.
+function getDimensions(cm) {
+ var d = cm.display, left = {}, width = {}
+ var gutterLeft = d.gutters.clientLeft
+ for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
+ left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft
+ width[cm.options.gutters[i]] = n.clientWidth
+ }
+ return {fixedPos: compensateForHScroll(d),
+ gutterTotalWidth: d.gutters.offsetWidth,
+ gutterLeft: left,
+ gutterWidth: width,
+ wrapperWidth: d.wrapper.clientWidth}
+}
+
+// Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
+// but using getBoundingClientRect to get a sub-pixel-accurate
+// result.
+function compensateForHScroll(display) {
+ return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left
+}
+
+// Returns a function that estimates the height of a line, to use as
+// first approximation until the line becomes visible (and is thus
+// properly measurable).
+function estimateHeight(cm) {
+ var th = textHeight(cm.display), wrapping = cm.options.lineWrapping
+ var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3)
+ return function (line) {
+ if (lineIsHidden(cm.doc, line)) { return 0 }
+
+ var widgetsHeight = 0
+ if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) {
+ if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height }
+ } }
+
+ if (wrapping)
+ { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th }
+ else
+ { return widgetsHeight + th }
+ }
+}
- // Move the hidden textarea near the cursor to prevent scrolling artifacts
- if (cm.options.moveInputWithCursor) {
- var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
- var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
- result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
- headPos.top + lineOff.top - wrapOff.top));
- result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
- headPos.left + lineOff.left - wrapOff.left));
- }
+function estimateLineHeights(cm) {
+ var doc = cm.doc, est = estimateHeight(cm)
+ doc.iter(function (line) {
+ var estHeight = est(line)
+ if (estHeight != line.height) { updateLineHeight(line, estHeight) }
+ })
+}
- return result;
- },
+// Given a mouse event, find the corresponding position. If liberal
+// is false, it checks whether a gutter or scrollbar was clicked,
+// and returns null if it was. forRect is used by rectangular
+// selections, and tries to estimate a character position even for
+// coordinates beyond the right of the text.
+function posFromMouse(cm, e, liberal, forRect) {
+ var display = cm.display
+ if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null }
- showSelection: function(drawn) {
- var cm = this.cm, display = cm.display;
- removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
- removeChildrenAndAdd(display.selectionDiv, drawn.selection);
- if (drawn.teTop != null) {
- this.wrapper.style.top = drawn.teTop + "px";
- this.wrapper.style.left = drawn.teLeft + "px";
- }
- },
+ var x, y, space = display.lineSpace.getBoundingClientRect()
+ // Fails unpredictably on IE[67] when mouse is dragged around quickly.
+ try { x = e.clientX - space.left; y = e.clientY - space.top }
+ catch (e) { return null }
+ var coords = coordsChar(cm, x, y), line
+ if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
+ var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length
+ coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff))
+ }
+ return coords
+}
- // Reset the input to correspond to the selection (or to be empty,
- // when not typing and nothing is selected)
- reset: function(typing) {
- if (this.contextMenuPending) return;
- var minimal, selected, cm = this.cm, doc = cm.doc;
- if (cm.somethingSelected()) {
- this.prevInput = "";
- var range = doc.sel.primary();
- minimal = hasCopyEvent &&
- (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000);
- var content = minimal ? "-" : selected || cm.getSelection();
- this.textarea.value = content;
- if (cm.state.focused) selectInput(this.textarea);
- if (ie && ie_version >= 9) this.hasSelection = content;
- } else if (!typing) {
- this.prevInput = this.textarea.value = "";
- if (ie && ie_version >= 9) this.hasSelection = null;
- }
- this.inaccurateSelection = minimal;
- },
+// Find the view element corresponding to a given line. Return null
+// when the line isn't visible.
+function findViewIndex(cm, n) {
+ if (n >= cm.display.viewTo) { return null }
+ n -= cm.display.viewFrom
+ if (n < 0) { return null }
+ var view = cm.display.view
+ for (var i = 0; i < view.length; i++) {
+ n -= view[i].size
+ if (n < 0) { return i }
+ }
+}
- getField: function() { return this.textarea; },
+function updateSelection(cm) {
+ cm.display.input.showSelection(cm.display.input.prepareSelection())
+}
- supportsTouch: function() { return false; },
+function prepareSelection(cm, primary) {
+ var doc = cm.doc, result = {}
+ var curFragment = result.cursors = document.createDocumentFragment()
+ var selFragment = result.selection = document.createDocumentFragment()
- focus: function() {
- if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
- try { this.textarea.focus(); }
- catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
- }
- },
+ for (var i = 0; i < doc.sel.ranges.length; i++) {
+ if (primary === false && i == doc.sel.primIndex) { continue }
+ var range = doc.sel.ranges[i]
+ if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue }
+ var collapsed = range.empty()
+ if (collapsed || cm.options.showCursorWhenSelecting)
+ { drawSelectionCursor(cm, range.head, curFragment) }
+ if (!collapsed)
+ { drawSelectionRange(cm, range, selFragment) }
+ }
+ return result
+}
- blur: function() { this.textarea.blur(); },
+// Draws a cursor for the given range
+function drawSelectionCursor(cm, head, output) {
+ var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine)
- resetPosition: function() {
- this.wrapper.style.top = this.wrapper.style.left = 0;
- },
+ var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"))
+ cursor.style.left = pos.left + "px"
+ cursor.style.top = pos.top + "px"
+ cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"
- receivedFocus: function() { this.slowPoll(); },
+ if (pos.other) {
+ // Secondary cursor, shown when on a 'jump' in bi-directional text
+ var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"))
+ otherCursor.style.display = ""
+ otherCursor.style.left = pos.other.left + "px"
+ otherCursor.style.top = pos.other.top + "px"
+ otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"
+ }
+}
- // Poll for input changes, using the normal rate of polling. This
- // runs as long as the editor is focused.
- slowPoll: function() {
- var input = this;
- if (input.pollingFast) return;
- input.polling.set(this.cm.options.pollInterval, function() {
- input.poll();
- if (input.cm.state.focused) input.slowPoll();
- });
- },
+// Draws the given range as a highlighted selection
+function drawSelectionRange(cm, range, output) {
+ var display = cm.display, doc = cm.doc
+ var fragment = document.createDocumentFragment()
+ var padding = paddingH(cm.display), leftSide = padding.left
+ var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right
- // When an event has just come in that is likely to add or change
- // something in the input textarea, we poll faster, to ensure that
- // the change appears on the screen quickly.
- fastPoll: function() {
- var missed = false, input = this;
- input.pollingFast = true;
- function p() {
- var changed = input.poll();
- if (!changed && !missed) {missed = true; input.polling.set(60, p);}
- else {input.pollingFast = false; input.slowPoll();}
- }
- input.polling.set(20, p);
- },
+ function add(left, top, width, bottom) {
+ if (top < 0) { top = 0 }
+ top = Math.round(top)
+ bottom = Math.round(bottom)
+ fragment.appendChild(elt("div", null, "CodeMirror-selected", ("position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px")))
+ }
- // Read input from the textarea, and update the document to match.
- // When something is selected, it is present in the textarea, and
- // selected (unless it is huge, in which case a placeholder is
- // used). When nothing is selected, the cursor sits after previously
- // seen text (can be empty), which is stored in prevInput (we must
- // not reset the textarea when typing, because that breaks IME).
- poll: function() {
- var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
- // Since this is called a *lot*, try to bail out as cheaply as
- // possible when it is clear that nothing happened. hasSelection
- // will be the case when there is a lot of text in the textarea,
- // in which case reading its value would be expensive.
- if (this.contextMenuPending || !cm.state.focused ||
- (hasSelection(input) && !prevInput && !this.composing) ||
- cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
- return false;
+ function drawForLine(line, fromArg, toArg) {
+ var lineObj = getLine(doc, line)
+ var lineLen = lineObj.text.length
+ var start, end
+ function coords(ch, bias) {
+ return charCoords(cm, Pos(line, ch), "div", lineObj, bias)
+ }
+
+ iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir) {
+ var leftPos = coords(from, "left"), rightPos, left, right
+ if (from == to) {
+ rightPos = leftPos
+ left = right = leftPos.left
+ } else {
+ rightPos = coords(to - 1, "right")
+ if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp }
+ left = leftPos.left
+ right = rightPos.right
+ }
+ if (fromArg == null && from == 0) { left = leftSide }
+ if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
+ add(left, leftPos.top, null, leftPos.bottom)
+ left = leftSide
+ if (leftPos.bottom < rightPos.top) { add(left, leftPos.bottom, null, rightPos.top) }
+ }
+ if (toArg == null && to == lineLen) { right = rightSide }
+ if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
+ { start = leftPos }
+ if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
+ { end = rightPos }
+ if (left < leftSide + 1) { left = leftSide }
+ add(left, rightPos.top, right - left, rightPos.bottom)
+ })
+ return {start: start, end: end}
+ }
+
+ var sFrom = range.from(), sTo = range.to()
+ if (sFrom.line == sTo.line) {
+ drawForLine(sFrom.line, sFrom.ch, sTo.ch)
+ } else {
+ var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line)
+ var singleVLine = visualLine(fromLine) == visualLine(toLine)
+ var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end
+ var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start
+ if (singleVLine) {
+ if (leftEnd.top < rightStart.top - 2) {
+ add(leftEnd.right, leftEnd.top, null, leftEnd.bottom)
+ add(leftSide, rightStart.top, rightStart.left, rightStart.bottom)
+ } else {
+ add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom)
+ }
+ }
+ if (leftEnd.bottom < rightStart.top)
+ { add(leftSide, leftEnd.bottom, null, rightStart.top) }
+ }
+
+ output.appendChild(fragment)
+}
+
+// Cursor-blinking
+function restartBlink(cm) {
+ if (!cm.state.focused) { return }
+ var display = cm.display
+ clearInterval(display.blinker)
+ var on = true
+ display.cursorDiv.style.visibility = ""
+ if (cm.options.cursorBlinkRate > 0)
+ { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; },
+ cm.options.cursorBlinkRate) }
+ else if (cm.options.cursorBlinkRate < 0)
+ { display.cursorDiv.style.visibility = "hidden" }
+}
+
+function ensureFocus(cm) {
+ if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm) }
+}
+
+function delayBlurEvent(cm) {
+ cm.state.delayingBlurEvent = true
+ setTimeout(function () { if (cm.state.delayingBlurEvent) {
+ cm.state.delayingBlurEvent = false
+ onBlur(cm)
+ } }, 100)
+}
+
+function onFocus(cm, e) {
+ if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false }
+
+ if (cm.options.readOnly == "nocursor") { return }
+ if (!cm.state.focused) {
+ signal(cm, "focus", cm, e)
+ cm.state.focused = true
+ addClass(cm.display.wrapper, "CodeMirror-focused")
+ // This test prevents this from firing when a context
+ // menu is closed (since the input reset would kill the
+ // select-all detection hack)
+ if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
+ cm.display.input.reset()
+ if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20) } // Issue #1730
+ }
+ cm.display.input.receivedFocus()
+ }
+ restartBlink(cm)
+}
+function onBlur(cm, e) {
+ if (cm.state.delayingBlurEvent) { return }
+
+ if (cm.state.focused) {
+ signal(cm, "blur", cm, e)
+ cm.state.focused = false
+ rmClass(cm.display.wrapper, "CodeMirror-focused")
+ }
+ clearInterval(cm.display.blinker)
+ setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false } }, 150)
+}
+
+// Re-align line numbers and gutter marks to compensate for
+// horizontal scrolling.
+function alignHorizontally(cm) {
+ var display = cm.display, view = display.view
+ if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return }
+ var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft
+ var gutterW = display.gutters.offsetWidth, left = comp + "px"
+ for (var i = 0; i < view.length; i++) { if (!view[i].hidden) {
+ if (cm.options.fixedGutter) {
+ if (view[i].gutter)
+ { view[i].gutter.style.left = left }
+ if (view[i].gutterBackground)
+ { view[i].gutterBackground.style.left = left }
+ }
+ var align = view[i].alignable
+ if (align) { for (var j = 0; j < align.length; j++)
+ { align[j].style.left = left } }
+ } }
+ if (cm.options.fixedGutter)
+ { display.gutters.style.left = (comp + gutterW) + "px" }
+}
+
+// Used to ensure that the line number gutter is still the right
+// size for the current document size. Returns true when an update
+// is needed.
+function maybeUpdateLineNumberWidth(cm) {
+ if (!cm.options.lineNumbers) { return false }
+ var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display
+ if (last.length != display.lineNumChars) {
+ var test = display.measure.appendChild(elt("div", [elt("div", last)],
+ "CodeMirror-linenumber CodeMirror-gutter-elt"))
+ var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW
+ display.lineGutter.style.width = ""
+ display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1
+ display.lineNumWidth = display.lineNumInnerWidth + padding
+ display.lineNumChars = display.lineNumInnerWidth ? last.length : -1
+ display.lineGutter.style.width = display.lineNumWidth + "px"
+ updateGutterSpace(cm)
+ return true
+ }
+ return false
+}
+
+// Read the actual heights of the rendered lines, and update their
+// stored heights to match.
+function updateHeightsInViewport(cm) {
+ var display = cm.display
+ var prevBottom = display.lineDiv.offsetTop
+ for (var i = 0; i < display.view.length; i++) {
+ var cur = display.view[i], height = (void 0)
+ if (cur.hidden) { continue }
+ if (ie && ie_version < 8) {
+ var bot = cur.node.offsetTop + cur.node.offsetHeight
+ height = bot - prevBottom
+ prevBottom = bot
+ } else {
+ var box = cur.node.getBoundingClientRect()
+ height = box.bottom - box.top
+ }
+ var diff = cur.line.height - height
+ if (height < 2) { height = textHeight(display) }
+ if (diff > .001 || diff < -.001) {
+ updateLineHeight(cur.line, height)
+ updateWidgetHeight(cur.line)
+ if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)
+ { updateWidgetHeight(cur.rest[j]) } }
+ }
+ }
+}
+
+// Read and store the height of line widgets associated with the
+// given line.
+function updateWidgetHeight(line) {
+ if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i)
+ { line.widgets[i].height = line.widgets[i].node.parentNode.offsetHeight } }
+}
+
+// Compute the lines that are visible in a given viewport (defaults
+// the the current scroll position). viewport may contain top,
+// height, and ensure (see op.scrollToPos) properties.
+function visibleLines(display, doc, viewport) {
+ var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop
+ top = Math.floor(top - paddingTop(display))
+ var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight
+
+ var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom)
+ // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
+ // forces those lines into the viewport (if possible).
+ if (viewport && viewport.ensure) {
+ var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line
+ if (ensureFrom < from) {
+ from = ensureFrom
+ to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)
+ } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
+ from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight)
+ to = ensureTo
+ }
+ }
+ return {from: from, to: Math.max(to, from + 1)}
+}
+
+// Sync the scrollable area and scrollbars, ensure the viewport
+// covers the visible area.
+function setScrollTop(cm, val) {
+ if (Math.abs(cm.doc.scrollTop - val) < 2) { return }
+ cm.doc.scrollTop = val
+ if (!gecko) { updateDisplaySimple(cm, {top: val}) }
+ if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val }
+ cm.display.scrollbars.setScrollTop(val)
+ if (gecko) { updateDisplaySimple(cm) }
+ startWorker(cm, 100)
+}
+// Sync scroller and scrollbar, ensure the gutter elements are
+// aligned.
+function setScrollLeft(cm, val, isScroller) {
+ if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) { return }
+ val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth)
+ cm.doc.scrollLeft = val
+ alignHorizontally(cm)
+ if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val }
+ cm.display.scrollbars.setScrollLeft(val)
+}
+
+// Since the delta values reported on mouse wheel events are
+// unstandardized between browsers and even browser versions, and
+// generally horribly unpredictable, this code starts by measuring
+// the scroll effect that the first few mouse wheel events have,
+// and, from that, detects the way it can convert deltas to pixel
+// offsets afterwards.
+//
+// The reason we want to know the amount a wheel event will scroll
+// is that it gives us a chance to update the display before the
+// actual scrolling happens, reducing flickering.
+
+var wheelSamples = 0;
+var wheelPixelsPerUnit = null;
+// Fill in a browser-detected starting value on browsers where we
+// know one. These don't have to be accurate -- the result of them
+// being wrong would just be a slight flicker on the first wheel
+// scroll (if it is large enough).
+if (ie) { wheelPixelsPerUnit = -.53 }
+else if (gecko) { wheelPixelsPerUnit = 15 }
+else if (chrome) { wheelPixelsPerUnit = -.7 }
+else if (safari) { wheelPixelsPerUnit = -1/3 }
+
+function wheelEventDelta(e) {
+ var dx = e.wheelDeltaX, dy = e.wheelDeltaY
+ if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail }
+ if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail }
+ else if (dy == null) { dy = e.wheelDelta }
+ return {x: dx, y: dy}
+}
+function wheelEventPixels(e) {
+ var delta = wheelEventDelta(e)
+ delta.x *= wheelPixelsPerUnit
+ delta.y *= wheelPixelsPerUnit
+ return delta
+}
+
+function onScrollWheel(cm, e) {
+ var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y
+
+ var display = cm.display, scroll = display.scroller
+ // Quit if there's nothing to scroll here
+ var canScrollX = scroll.scrollWidth > scroll.clientWidth
+ var canScrollY = scroll.scrollHeight > scroll.clientHeight
+ if (!(dx && canScrollX || dy && canScrollY)) { return }
+
+ // Webkit browsers on OS X abort momentum scrolls when the target
+ // of the scroll event is removed from the scrollable element.
+ // This hack (see related code in patchDisplay) makes sure the
+ // element is kept around.
+ if (dy && mac && webkit) {
+ outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
+ for (var i = 0; i < view.length; i++) {
+ if (view[i].node == cur) {
+ cm.display.currentWheelTarget = cur
+ break outer
+ }
+ }
+ }
+ }
+
+ // On some browsers, horizontal scrolling will cause redraws to
+ // happen before the gutter has been realigned, causing it to
+ // wriggle around in a most unseemly way. When we have an
+ // estimated pixels/delta value, we just handle horizontal
+ // scrolling entirely here. It'll be slightly off from native, but
+ // better than glitching out.
+ if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
+ if (dy && canScrollY)
+ { setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight))) }
+ setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)))
+ // Only prevent default scrolling if vertical scrolling is
+ // actually possible. Otherwise, it causes vertical scroll
+ // jitter on OSX trackpads when deltaX is small and deltaY
+ // is large (issue #3579)
+ if (!dy || (dy && canScrollY))
+ { e_preventDefault(e) }
+ display.wheelStartX = null // Abort measurement, if in progress
+ return
+ }
+
+ // 'Project' the visible viewport to cover the area that is being
+ // scrolled into view (if we know enough to estimate it).
+ if (dy && wheelPixelsPerUnit != null) {
+ var pixels = dy * wheelPixelsPerUnit
+ var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight
+ if (pixels < 0) { top = Math.max(0, top + pixels - 50) }
+ else { bot = Math.min(cm.doc.height, bot + pixels + 50) }
+ updateDisplaySimple(cm, {top: top, bottom: bot})
+ }
+
+ if (wheelSamples < 20) {
+ if (display.wheelStartX == null) {
+ display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop
+ display.wheelDX = dx; display.wheelDY = dy
+ setTimeout(function () {
+ if (display.wheelStartX == null) { return }
+ var movedX = scroll.scrollLeft - display.wheelStartX
+ var movedY = scroll.scrollTop - display.wheelStartY
+ var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
+ (movedX && display.wheelDX && movedX / display.wheelDX)
+ display.wheelStartX = display.wheelStartY = null
+ if (!sample) { return }
+ wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1)
+ ++wheelSamples
+ }, 200)
+ } else {
+ display.wheelDX += dx; display.wheelDY += dy
+ }
+ }
+}
- var text = input.value;
- // If nothing changed, bail.
- if (text == prevInput && !cm.somethingSelected()) return false;
- // Work around nonsensical selection resetting in IE9/10, and
- // inexplicable appearance of private area unicode characters on
- // some key combos in Mac (#2689).
- if (ie && ie_version >= 9 && this.hasSelection === text ||
- mac && /[\uf700-\uf7ff]/.test(text)) {
- cm.display.input.reset();
- return false;
- }
+// SCROLLBARS
- if (cm.doc.sel == cm.display.selForContextMenu) {
- var first = text.charCodeAt(0);
- if (first == 0x200b && !prevInput) prevInput = "\u200b";
- if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo"); }
- }
- // Find the part of the input that is actually new
- var same = 0, l = Math.min(prevInput.length, text.length);
- while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same;
+// Prepare DOM reads needed to update the scrollbars. Done in one
+// shot to minimize update/measure roundtrips.
+function measureForScrollbars(cm) {
+ var d = cm.display, gutterW = d.gutters.offsetWidth
+ var docH = Math.round(cm.doc.height + paddingVert(cm.display))
+ return {
+ clientHeight: d.scroller.clientHeight,
+ viewHeight: d.wrapper.clientHeight,
+ scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
+ viewWidth: d.wrapper.clientWidth,
+ barLeft: cm.options.fixedGutter ? gutterW : 0,
+ docHeight: docH,
+ scrollHeight: docH + scrollGap(cm) + d.barHeight,
+ nativeBarWidth: d.nativeBarWidth,
+ gutterWidth: gutterW
+ }
+}
+
+var NativeScrollbars = function(place, scroll, cm) {
+ this.cm = cm
+ var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar")
+ var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar")
+ place(vert); place(horiz)
+
+ on(vert, "scroll", function () {
+ if (vert.clientHeight) { scroll(vert.scrollTop, "vertical") }
+ })
+ on(horiz, "scroll", function () {
+ if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal") }
+ })
+
+ this.checkedZeroWidth = false
+ // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
+ if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px" }
+};
- var self = this;
- runInOp(cm, function() {
- applyTextInput(cm, text.slice(same), prevInput.length - same,
- null, self.composing ? "*compose" : null);
+NativeScrollbars.prototype.update = function (measure) {
+ var needsH = measure.scrollWidth > measure.clientWidth + 1
+ var needsV = measure.scrollHeight > measure.clientHeight + 1
+ var sWidth = measure.nativeBarWidth
+
+ if (needsV) {
+ this.vert.style.display = "block"
+ this.vert.style.bottom = needsH ? sWidth + "px" : "0"
+ var totalHeight = measure.viewHeight - (needsH ? sWidth : 0)
+ // A bug in IE8 can cause this value to be negative, so guard it.
+ this.vert.firstChild.style.height =
+ Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"
+ } else {
+ this.vert.style.display = ""
+ this.vert.firstChild.style.height = "0"
+ }
- // Don't leave long text in the textarea, since it makes further polling slow
- if (text.length > 1000 || text.indexOf("\n") > -1) input.value = self.prevInput = "";
- else self.prevInput = text;
+ if (needsH) {
+ this.horiz.style.display = "block"
+ this.horiz.style.right = needsV ? sWidth + "px" : "0"
+ this.horiz.style.left = measure.barLeft + "px"
+ var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0)
+ this.horiz.firstChild.style.width =
+ Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px"
+ } else {
+ this.horiz.style.display = ""
+ this.horiz.firstChild.style.width = "0"
+ }
- if (self.composing) {
- self.composing.range.clear();
- self.composing.range = cm.markText(self.composing.start, cm.getCursor("to"),
- {className: "CodeMirror-composing"});
- }
- });
- return true;
- },
+ if (!this.checkedZeroWidth && measure.clientHeight > 0) {
+ if (sWidth == 0) { this.zeroWidthHack() }
+ this.checkedZeroWidth = true
+ }
- ensurePolled: function() {
- if (this.pollingFast && this.poll()) this.pollingFast = false;
- },
+ return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}
+};
- onKeyPress: function() {
- if (ie && ie_version >= 9) this.hasSelection = null;
- this.fastPoll();
- },
+NativeScrollbars.prototype.setScrollLeft = function (pos) {
+ if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos }
+ if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz) }
+};
- onContextMenu: function(e) {
- var input = this, cm = input.cm, display = cm.display, te = input.textarea;
- var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
- if (!pos || presto) return; // Opera is difficult.
-
- // Reset the current text selection only if the click is done outside of the selection
- // and 'resetSelectionOnContextMenu' option is true.
- var reset = cm.options.resetSelectionOnContextMenu;
- if (reset && cm.doc.sel.contains(pos) == -1)
- operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll);
-
- var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
- input.wrapper.style.cssText = "position: absolute"
- var wrapperBox = input.wrapper.getBoundingClientRect()
- te.style.cssText = "position: absolute; width: 30px; height: 30px; top: " + (e.clientY - wrapperBox.top - 5) +
- "px; left: " + (e.clientX - wrapperBox.left - 5) + "px; z-index: 1000; background: " +
- (ie ? "rgba(255, 255, 255, .05)" : "transparent") +
- "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);";
- if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712)
- display.input.focus();
- if (webkit) window.scrollTo(null, oldScrollY);
- display.input.reset();
- // Adds "Select all" to context menu in FF
- if (!cm.somethingSelected()) te.value = input.prevInput = " ";
- input.contextMenuPending = true;
- display.selForContextMenu = cm.doc.sel;
- clearTimeout(display.detectingSelectAll);
-
- // Select-all will be greyed out if there's nothing to select, so
- // this adds a zero-width space so that we can later check whether
- // it got selected.
- function prepareSelectAllHack() {
- if (te.selectionStart != null) {
- var selected = cm.somethingSelected();
- var extval = "\u200b" + (selected ? te.value : "");
- te.value = "\u21da"; // Used to catch context-menu undo
- te.value = extval;
- input.prevInput = selected ? "" : "\u200b";
- te.selectionStart = 1; te.selectionEnd = extval.length;
- // Re-set this, in case some other handler touched the
- // selection in the meantime.
- display.selForContextMenu = cm.doc.sel;
- }
- }
- function rehide() {
- input.contextMenuPending = false;
- input.wrapper.style.cssText = oldWrapperCSS
- te.style.cssText = oldCSS;
- if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos);
-
- // Try to detect the user choosing select-all
- if (te.selectionStart != null) {
- if (!ie || (ie && ie_version < 9)) prepareSelectAllHack();
- var i = 0, poll = function() {
- if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
- te.selectionEnd > 0 && input.prevInput == "\u200b")
- operation(cm, commands.selectAll)(cm);
- else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500);
- else display.input.reset();
- };
- display.detectingSelectAll = setTimeout(poll, 200);
- }
- }
+NativeScrollbars.prototype.setScrollTop = function (pos) {
+ if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos }
+ if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert) }
+};
- if (ie && ie_version >= 9) prepareSelectAllHack();
- if (captureRightClick) {
- e_stop(e);
- var mouseup = function() {
- off(window, "mouseup", mouseup);
- setTimeout(rehide, 20);
- };
- on(window, "mouseup", mouseup);
- } else {
- setTimeout(rehide, 50);
- }
- },
+NativeScrollbars.prototype.zeroWidthHack = function () {
+ var w = mac && !mac_geMountainLion ? "12px" : "18px"
+ this.horiz.style.height = this.vert.style.width = w
+ this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none"
+ this.disableHoriz = new Delayed
+ this.disableVert = new Delayed
+};
- readOnlyChanged: function(val) {
- if (!val) this.reset();
- },
+NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay) {
+ bar.style.pointerEvents = "auto"
+ function maybeDisable() {
+ // To find out whether the scrollbar is still visible, we
+ // check whether the element under the pixel in the bottom
+ // left corner of the scrollbar box is the scrollbar box
+ // itself (when the bar is still visible) or its filler child
+ // (when the bar is hidden). If it is still visible, we keep
+ // it enabled, if it's hidden, we disable pointer events.
+ var box = bar.getBoundingClientRect()
+ var elt = document.elementFromPoint(box.left + 1, box.bottom - 1)
+ if (elt != bar) { bar.style.pointerEvents = "none" }
+ else { delay.set(1000, maybeDisable) }
+ }
+ delay.set(1000, maybeDisable)
+};
- setUneditable: nothing,
+NativeScrollbars.prototype.clear = function () {
+ var parent = this.horiz.parentNode
+ parent.removeChild(this.horiz)
+ parent.removeChild(this.vert)
+};
- needsContentAttribute: false
- }, TextareaInput.prototype);
+var NullScrollbars = function () {};
- // CONTENTEDITABLE INPUT STYLE
+NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} };
+NullScrollbars.prototype.setScrollLeft = function () {};
+NullScrollbars.prototype.setScrollTop = function () {};
+NullScrollbars.prototype.clear = function () {};
- function ContentEditableInput(cm) {
- this.cm = cm;
- this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
- this.polling = new Delayed();
- this.gracePeriod = false;
+function updateScrollbars(cm, measure) {
+ if (!measure) { measure = measureForScrollbars(cm) }
+ var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight
+ updateScrollbarsInner(cm, measure)
+ for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
+ if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
+ { updateHeightsInViewport(cm) }
+ updateScrollbarsInner(cm, measureForScrollbars(cm))
+ startWidth = cm.display.barWidth; startHeight = cm.display.barHeight
}
+}
- ContentEditableInput.prototype = copyObj({
- init: function(display) {
- var input = this, cm = input.cm;
- var div = input.div = display.lineDiv;
- disableBrowserMagic(div);
-
- on(div, "paste", function(e) {
- if (!signalDOMEvent(cm, e)) handlePaste(e, cm);
- })
-
- on(div, "compositionstart", function(e) {
- var data = e.data;
- input.composing = {sel: cm.doc.sel, data: data, startData: data};
- if (!data) return;
- var prim = cm.doc.sel.primary();
- var line = cm.getLine(prim.head.line);
- var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length));
- if (found > -1 && found <= prim.head.ch)
- input.composing.sel = simpleSelection(Pos(prim.head.line, found),
- Pos(prim.head.line, found + data.length));
- });
- on(div, "compositionupdate", function(e) {
- input.composing.data = e.data;
- });
- on(div, "compositionend", function(e) {
- var ours = input.composing;
- if (!ours) return;
- if (e.data != ours.startData && !/\u200b/.test(e.data))
- ours.data = e.data;
- // Need a small delay to prevent other code (input event,
- // selection polling) from doing damage when fired right after
- // compositionend.
- setTimeout(function() {
- if (!ours.handled)
- input.applyComposition(ours);
- if (input.composing == ours)
- input.composing = null;
- }, 50);
- });
-
- on(div, "touchstart", function() {
- input.forceCompositionEnd();
- });
+// Re-synchronize the fake scrollbars with the actual size of the
+// content.
+function updateScrollbarsInner(cm, measure) {
+ var d = cm.display
+ var sizes = d.scrollbars.update(measure)
- on(div, "input", function() {
- if (input.composing) return;
- if (cm.isReadOnly() || !input.pollContent())
- runInOp(input.cm, function() {regChange(cm);});
- });
-
- function onCopyCut(e) {
- if (signalDOMEvent(cm, e)) return
- if (cm.somethingSelected()) {
- lastCopied = {lineWise: false, text: cm.getSelections()};
- if (e.type == "cut") cm.replaceSelection("", null, "cut");
- } else if (!cm.options.lineWiseCopyCut) {
- return;
- } else {
- var ranges = copyableRanges(cm);
- lastCopied = {lineWise: true, text: ranges.text};
- if (e.type == "cut") {
- cm.operation(function() {
- cm.setSelections(ranges.ranges, 0, sel_dontScroll);
- cm.replaceSelection("", null, "cut");
- });
- }
- }
- // iOS exposes the clipboard API, but seems to discard content inserted into it
- if (e.clipboardData && !ios) {
- e.preventDefault();
- e.clipboardData.clearData();
- e.clipboardData.setData("text/plain", lastCopied.text.join("\n"));
- } else {
- // Old-fashioned briefly-focus-a-textarea hack
- var kludge = hiddenTextarea(), te = kludge.firstChild;
- cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
- te.value = lastCopied.text.join("\n");
- var hadFocus = document.activeElement;
- selectInput(te);
- setTimeout(function() {
- cm.display.lineSpace.removeChild(kludge);
- hadFocus.focus();
- }, 50);
- }
- }
- on(div, "copy", onCopyCut);
- on(div, "cut", onCopyCut);
- },
+ d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"
+ d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"
+ d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"
- prepareSelection: function() {
- var result = prepareSelection(this.cm, false);
- result.focus = this.cm.state.focused;
- return result;
- },
+ if (sizes.right && sizes.bottom) {
+ d.scrollbarFiller.style.display = "block"
+ d.scrollbarFiller.style.height = sizes.bottom + "px"
+ d.scrollbarFiller.style.width = sizes.right + "px"
+ } else { d.scrollbarFiller.style.display = "" }
+ if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
+ d.gutterFiller.style.display = "block"
+ d.gutterFiller.style.height = sizes.bottom + "px"
+ d.gutterFiller.style.width = measure.gutterWidth + "px"
+ } else { d.gutterFiller.style.display = "" }
+}
- showSelection: function(info, takeFocus) {
- if (!info || !this.cm.display.view.length) return;
- if (info.focus || takeFocus) this.showPrimarySelection();
- this.showMultipleSelections(info);
- },
+var scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars}
- showPrimarySelection: function() {
- var sel = window.getSelection(), prim = this.cm.doc.sel.primary();
- var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset);
- var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset);
- if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
- cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
- cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
- return;
+function initScrollbars(cm) {
+ if (cm.display.scrollbars) {
+ cm.display.scrollbars.clear()
+ if (cm.display.scrollbars.addClass)
+ { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass) }
+ }
+
+ cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) {
+ cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller)
+ // Prevent clicks in the scrollbars from killing focus
+ on(node, "mousedown", function () {
+ if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0) }
+ })
+ node.setAttribute("cm-not-content", "true")
+ }, function (pos, axis) {
+ if (axis == "horizontal") { setScrollLeft(cm, pos) }
+ else { setScrollTop(cm, pos) }
+ }, cm)
+ if (cm.display.scrollbars.addClass)
+ { addClass(cm.display.wrapper, cm.display.scrollbars.addClass) }
+}
+
+// SCROLLING THINGS INTO VIEW
+
+// If an editor sits on the top or bottom of the window, partially
+// scrolled out of view, this ensures that the cursor is visible.
+function maybeScrollWindow(cm, coords) {
+ if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
+
+ var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null
+ if (coords.top + box.top < 0) { doScroll = true }
+ else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false }
+ if (doScroll != null && !phantom) {
+ var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (coords.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (coords.left) + "px; width: 2px;"))
+ cm.display.lineSpace.appendChild(scrollNode)
+ scrollNode.scrollIntoView(doScroll)
+ cm.display.lineSpace.removeChild(scrollNode)
+ }
+}
+
+// Scroll a given position into view (immediately), verifying that
+// it actually became visible (as line heights are accurately
+// measured, the position of something may 'drift' during drawing).
+function scrollPosIntoView(cm, pos, end, margin) {
+ if (margin == null) { margin = 0 }
+ var coords
+ for (var limit = 0; limit < 5; limit++) {
+ var changed = false
+ coords = cursorCoords(cm, pos)
+ var endCoords = !end || end == pos ? coords : cursorCoords(cm, end)
+ var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
+ Math.min(coords.top, endCoords.top) - margin,
+ Math.max(coords.left, endCoords.left),
+ Math.max(coords.bottom, endCoords.bottom) + margin)
+ var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft
+ if (scrollPos.scrollTop != null) {
+ setScrollTop(cm, scrollPos.scrollTop)
+ if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true }
+ }
+ if (scrollPos.scrollLeft != null) {
+ setScrollLeft(cm, scrollPos.scrollLeft)
+ if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true }
+ }
+ if (!changed) { break }
+ }
+ return coords
+}
+
+// Scroll a given set of coordinates into view (immediately).
+function scrollIntoView(cm, x1, y1, x2, y2) {
+ var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2)
+ if (scrollPos.scrollTop != null) { setScrollTop(cm, scrollPos.scrollTop) }
+ if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft) }
+}
+
+// Calculate a new scroll position needed to scroll the given
+// rectangle into view. Returns an object with scrollTop and
+// scrollLeft properties. When these are undefined, the
+// vertical/horizontal position does not need to be adjusted.
+function calculateScrollPos(cm, x1, y1, x2, y2) {
+ var display = cm.display, snapMargin = textHeight(cm.display)
+ if (y1 < 0) { y1 = 0 }
+ var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop
+ var screen = displayHeight(cm), result = {}
+ if (y2 - y1 > screen) { y2 = y1 + screen }
+ var docBottom = cm.doc.height + paddingVert(display)
+ var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin
+ if (y1 < screentop) {
+ result.scrollTop = atTop ? 0 : y1
+ } else if (y2 > screentop + screen) {
+ var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen)
+ if (newTop != screentop) { result.scrollTop = newTop }
+ }
+
+ var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft
+ var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0)
+ var tooWide = x2 - x1 > screenw
+ if (tooWide) { x2 = x1 + screenw }
+ if (x1 < 10)
+ { result.scrollLeft = 0 }
+ else if (x1 < screenleft)
+ { result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10)) }
+ else if (x2 > screenw + screenleft - 3)
+ { result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw }
+ return result
+}
+
+// Store a relative adjustment to the scroll position in the current
+// operation (to be applied when the operation finishes).
+function addToScrollPos(cm, left, top) {
+ if (left != null || top != null) { resolveScrollToPos(cm) }
+ if (left != null)
+ { cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left }
+ if (top != null)
+ { cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top }
+}
+
+// Make sure that at the end of the operation the current cursor is
+// shown.
+function ensureCursorVisible(cm) {
+ resolveScrollToPos(cm)
+ var cur = cm.getCursor(), from = cur, to = cur
+ if (!cm.options.lineWrapping) {
+ from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur
+ to = Pos(cur.line, cur.ch + 1)
+ }
+ cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true}
+}
+
+// When an operation has its scrollToPos property set, and another
+// scroll action is applied before the end of the operation, this
+// 'simulates' scrolling that position into view in a cheap way, so
+// that the effect of intermediate scroll commands is not ignored.
+function resolveScrollToPos(cm) {
+ var range = cm.curOp.scrollToPos
+ if (range) {
+ cm.curOp.scrollToPos = null
+ var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to)
+ var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),
+ Math.min(from.top, to.top) - range.margin,
+ Math.max(from.right, to.right),
+ Math.max(from.bottom, to.bottom) + range.margin)
+ cm.scrollTo(sPos.scrollLeft, sPos.scrollTop)
+ }
+}
+
+// Operations are used to wrap a series of changes to the editor
+// state in such a way that each change won't have to update the
+// cursor and display (which would be awkward, slow, and
+// error-prone). Instead, display updates are batched and then all
+// combined and executed at once.
+
+var nextOpId = 0
+// Start a new operation.
+function startOperation(cm) {
+ cm.curOp = {
+ cm: cm,
+ viewChanged: false, // Flag that indicates that lines might need to be redrawn
+ startHeight: cm.doc.height, // Used to detect need to update scrollbar
+ forceUpdate: false, // Used to force a redraw
+ updateInput: null, // Whether to reset the input textarea
+ typing: false, // Whether this reset should be careful to leave existing text (for compositing)
+ changeObjs: null, // Accumulated changes, for firing change events
+ cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
+ cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
+ selectionChanged: false, // Whether the selection needs to be redrawn
+ updateMaxLine: false, // Set when the widest line needs to be determined anew
+ scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
+ scrollToPos: null, // Used to scroll to a specific position
+ focus: false,
+ id: ++nextOpId // Unique ID
+ }
+ pushOperation(cm.curOp)
+}
+
+// Finish an operation, updating the display and signalling delayed events
+function endOperation(cm) {
+ var op = cm.curOp
+ finishOperation(op, function (group) {
+ for (var i = 0; i < group.ops.length; i++)
+ { group.ops[i].cm.curOp = null }
+ endOperations(group)
+ })
+}
+
+// The DOM updates done when an operation finishes are batched so
+// that the minimum number of relayouts are required.
+function endOperations(group) {
+ var ops = group.ops
+ for (var i = 0; i < ops.length; i++) // Read DOM
+ { endOperation_R1(ops[i]) }
+ for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe)
+ { endOperation_W1(ops[i$1]) }
+ for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM
+ { endOperation_R2(ops[i$2]) }
+ for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe)
+ { endOperation_W2(ops[i$3]) }
+ for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM
+ { endOperation_finish(ops[i$4]) }
+}
+
+function endOperation_R1(op) {
+ var cm = op.cm, display = cm.display
+ maybeClipScrollbars(cm)
+ if (op.updateMaxLine) { findMaxLine(cm) }
+
+ op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
+ op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
+ op.scrollToPos.to.line >= display.viewTo) ||
+ display.maxLineChanged && cm.options.lineWrapping
+ op.update = op.mustUpdate &&
+ new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate)
+}
+
+function endOperation_W1(op) {
+ op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update)
+}
+
+function endOperation_R2(op) {
+ var cm = op.cm, display = cm.display
+ if (op.updatedDisplay) { updateHeightsInViewport(cm) }
+
+ op.barMeasure = measureForScrollbars(cm)
+
+ // If the max line changed since it was last measured, measure it,
+ // and ensure the document's width matches it.
+ // updateDisplay_W2 will use these properties to do the actual resizing
+ if (display.maxLineChanged && !cm.options.lineWrapping) {
+ op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3
+ cm.display.sizerWidth = op.adjustWidthTo
+ op.barMeasure.scrollWidth =
+ Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth)
+ op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm))
+ }
+
+ if (op.updatedDisplay || op.selectionChanged)
+ { op.preparedSelection = display.input.prepareSelection(op.focus) }
+}
+
+function endOperation_W2(op) {
+ var cm = op.cm
+
+ if (op.adjustWidthTo != null) {
+ cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"
+ if (op.maxScrollLeft < cm.doc.scrollLeft)
+ { setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true) }
+ cm.display.maxLineChanged = false
+ }
+
+ var takeFocus = op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus())
+ if (op.preparedSelection)
+ { cm.display.input.showSelection(op.preparedSelection, takeFocus) }
+ if (op.updatedDisplay || op.startHeight != cm.doc.height)
+ { updateScrollbars(cm, op.barMeasure) }
+ if (op.updatedDisplay)
+ { setDocumentHeight(cm, op.barMeasure) }
+
+ if (op.selectionChanged) { restartBlink(cm) }
+
+ if (cm.state.focused && op.updateInput)
+ { cm.display.input.reset(op.typing) }
+ if (takeFocus) { ensureFocus(op.cm) }
+}
+
+function endOperation_finish(op) {
+ var cm = op.cm, display = cm.display, doc = cm.doc
+
+ if (op.updatedDisplay) { postUpdateDisplay(cm, op.update) }
+
+ // Abort mouse wheel delta measurement, when scrolling explicitly
+ if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
+ { display.wheelStartX = display.wheelStartY = null }
+
+ // Propagate the scroll position to the actual DOM scroller
+ if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) {
+ doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop))
+ display.scrollbars.setScrollTop(doc.scrollTop)
+ display.scroller.scrollTop = doc.scrollTop
+ }
+ if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
+ doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft))
+ display.scrollbars.setScrollLeft(doc.scrollLeft)
+ display.scroller.scrollLeft = doc.scrollLeft
+ alignHorizontally(cm)
+ }
+ // If we need to scroll a specific position into view, do so.
+ if (op.scrollToPos) {
+ var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
+ clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin)
+ if (op.scrollToPos.isCursor && cm.state.focused) { maybeScrollWindow(cm, coords) }
+ }
+
+ // Fire events for markers that are hidden/unidden by editing or
+ // undoing
+ var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers
+ if (hidden) { for (var i = 0; i < hidden.length; ++i)
+ { if (!hidden[i].lines.length) { signal(hidden[i], "hide") } } }
+ if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1)
+ { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide") } } }
- var start = posToDOM(this.cm, prim.from());
- var end = posToDOM(this.cm, prim.to());
- if (!start && !end) return;
-
- var view = this.cm.display.view;
- var old = sel.rangeCount && sel.getRangeAt(0);
- if (!start) {
- start = {node: view[0].measure.map[2], offset: 0};
- } else if (!end) { // FIXME dangerously hacky
- var measure = view[view.length - 1].measure;
- var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
- end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]};
- }
-
- try { var rng = range(start.node, start.offset, end.offset, end.node); }
- catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
- if (rng) {
- if (!gecko && this.cm.state.focused) {
- sel.collapse(start.node, start.offset);
- if (!rng.collapsed) sel.addRange(rng);
- } else {
- sel.removeAllRanges();
- sel.addRange(rng);
- }
- if (old && sel.anchorNode == null) sel.addRange(old);
- else if (gecko) this.startGracePeriod();
- }
- this.rememberSelection();
- },
+ if (display.wrapper.offsetHeight)
+ { doc.scrollTop = cm.display.scroller.scrollTop }
+
+ // Fire change events, and delayed event handlers
+ if (op.changeObjs)
+ { signal(cm, "changes", cm, op.changeObjs) }
+ if (op.update)
+ { op.update.finish() }
+}
+
+// Run the given function in an operation
+function runInOp(cm, f) {
+ if (cm.curOp) { return f() }
+ startOperation(cm)
+ try { return f() }
+ finally { endOperation(cm) }
+}
+// Wraps a function in an operation. Returns the wrapped function.
+function operation(cm, f) {
+ return function() {
+ if (cm.curOp) { return f.apply(cm, arguments) }
+ startOperation(cm)
+ try { return f.apply(cm, arguments) }
+ finally { endOperation(cm) }
+ }
+}
+// Used to add methods to editor and doc instances, wrapping them in
+// operations.
+function methodOp(f) {
+ return function() {
+ if (this.curOp) { return f.apply(this, arguments) }
+ startOperation(this)
+ try { return f.apply(this, arguments) }
+ finally { endOperation(this) }
+ }
+}
+function docMethodOp(f) {
+ return function() {
+ var cm = this.cm
+ if (!cm || cm.curOp) { return f.apply(this, arguments) }
+ startOperation(cm)
+ try { return f.apply(this, arguments) }
+ finally { endOperation(cm) }
+ }
+}
+
+// Updates the display.view data structure for a given change to the
+// document. From and to are in pre-change coordinates. Lendiff is
+// the amount of lines added or subtracted by the change. This is
+// used for changes that span multiple lines, or change the way
+// lines are divided into visual lines. regLineChange (below)
+// registers single-line changes.
+function regChange(cm, from, to, lendiff) {
+ if (from == null) { from = cm.doc.first }
+ if (to == null) { to = cm.doc.first + cm.doc.size }
+ if (!lendiff) { lendiff = 0 }
+
+ var display = cm.display
+ if (lendiff && to < display.viewTo &&
+ (display.updateLineNumbers == null || display.updateLineNumbers > from))
+ { display.updateLineNumbers = from }
+
+ cm.curOp.viewChanged = true
+
+ if (from >= display.viewTo) { // Change after
+ if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
+ { resetView(cm) }
+ } else if (to <= display.viewFrom) { // Change before
+ if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
+ resetView(cm)
+ } else {
+ display.viewFrom += lendiff
+ display.viewTo += lendiff
+ }
+ } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
+ resetView(cm)
+ } else if (from <= display.viewFrom) { // Top overlap
+ var cut = viewCuttingPoint(cm, to, to + lendiff, 1)
+ if (cut) {
+ display.view = display.view.slice(cut.index)
+ display.viewFrom = cut.lineN
+ display.viewTo += lendiff
+ } else {
+ resetView(cm)
+ }
+ } else if (to >= display.viewTo) { // Bottom overlap
+ var cut$1 = viewCuttingPoint(cm, from, from, -1)
+ if (cut$1) {
+ display.view = display.view.slice(0, cut$1.index)
+ display.viewTo = cut$1.lineN
+ } else {
+ resetView(cm)
+ }
+ } else { // Gap in the middle
+ var cutTop = viewCuttingPoint(cm, from, from, -1)
+ var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1)
+ if (cutTop && cutBot) {
+ display.view = display.view.slice(0, cutTop.index)
+ .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
+ .concat(display.view.slice(cutBot.index))
+ display.viewTo += lendiff
+ } else {
+ resetView(cm)
+ }
+ }
- startGracePeriod: function() {
- var input = this;
- clearTimeout(this.gracePeriod);
- this.gracePeriod = setTimeout(function() {
- input.gracePeriod = false;
- if (input.selectionChanged())
- input.cm.operation(function() { input.cm.curOp.selectionChanged = true; });
- }, 20);
- },
+ var ext = display.externalMeasured
+ if (ext) {
+ if (to < ext.lineN)
+ { ext.lineN += lendiff }
+ else if (from < ext.lineN + ext.size)
+ { display.externalMeasured = null }
+ }
+}
- showMultipleSelections: function(info) {
- removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
- removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
- },
+// Register a change to a single line. Type must be one of "text",
+// "gutter", "class", "widget"
+function regLineChange(cm, line, type) {
+ cm.curOp.viewChanged = true
+ var display = cm.display, ext = cm.display.externalMeasured
+ if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
+ { display.externalMeasured = null }
- rememberSelection: function() {
- var sel = window.getSelection();
- this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
- this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
- },
+ if (line < display.viewFrom || line >= display.viewTo) { return }
+ var lineView = display.view[findViewIndex(cm, line)]
+ if (lineView.node == null) { return }
+ var arr = lineView.changes || (lineView.changes = [])
+ if (indexOf(arr, type) == -1) { arr.push(type) }
+}
- selectionInEditor: function() {
- var sel = window.getSelection();
- if (!sel.rangeCount) return false;
- var node = sel.getRangeAt(0).commonAncestorContainer;
- return contains(this.div, node);
- },
+// Clear the view.
+function resetView(cm) {
+ cm.display.viewFrom = cm.display.viewTo = cm.doc.first
+ cm.display.view = []
+ cm.display.viewOffset = 0
+}
- focus: function() {
- if (this.cm.options.readOnly != "nocursor") this.div.focus();
- },
- blur: function() { this.div.blur(); },
- getField: function() { return this.div; },
+function viewCuttingPoint(cm, oldN, newN, dir) {
+ var index = findViewIndex(cm, oldN), diff, view = cm.display.view
+ if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
+ { return {index: index, lineN: newN} }
+ var n = cm.display.viewFrom
+ for (var i = 0; i < index; i++)
+ { n += view[i].size }
+ if (n != oldN) {
+ if (dir > 0) {
+ if (index == view.length - 1) { return null }
+ diff = (n + view[index].size) - oldN
+ index++
+ } else {
+ diff = n - oldN
+ }
+ oldN += diff; newN += diff
+ }
+ while (visualLineNo(cm.doc, newN) != newN) {
+ if (index == (dir < 0 ? 0 : view.length - 1)) { return null }
+ newN += dir * view[index - (dir < 0 ? 1 : 0)].size
+ index += dir
+ }
+ return {index: index, lineN: newN}
+}
- supportsTouch: function() { return true; },
+// Force the view to cover a given range, adding empty view element
+// or clipping off existing ones as needed.
+function adjustView(cm, from, to) {
+ var display = cm.display, view = display.view
+ if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
+ display.view = buildViewArray(cm, from, to)
+ display.viewFrom = from
+ } else {
+ if (display.viewFrom > from)
+ { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view) }
+ else if (display.viewFrom < from)
+ { display.view = display.view.slice(findViewIndex(cm, from)) }
+ display.viewFrom = from
+ if (display.viewTo < to)
+ { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)) }
+ else if (display.viewTo > to)
+ { display.view = display.view.slice(0, findViewIndex(cm, to)) }
+ }
+ display.viewTo = to
+}
+
+// Count the number of lines in the view whose DOM representation is
+// out of date (or nonexistent).
+function countDirtyView(cm) {
+ var view = cm.display.view, dirty = 0
+ for (var i = 0; i < view.length; i++) {
+ var lineView = view[i]
+ if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty }
+ }
+ return dirty
+}
+
+// HIGHLIGHT WORKER
+
+function startWorker(cm, time) {
+ if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
+ { cm.state.highlight.set(time, bind(highlightWorker, cm)) }
+}
+
+function highlightWorker(cm) {
+ var doc = cm.doc
+ if (doc.frontier < doc.first) { doc.frontier = doc.first }
+ if (doc.frontier >= cm.display.viewTo) { return }
+ var end = +new Date + cm.options.workTime
+ var state = copyState(doc.mode, getStateBefore(cm, doc.frontier))
+ var changedLines = []
+
+ doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) {
+ if (doc.frontier >= cm.display.viewFrom) { // Visible
+ var oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength
+ var highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true)
+ line.styles = highlighted.styles
+ var oldCls = line.styleClasses, newCls = highlighted.classes
+ if (newCls) { line.styleClasses = newCls }
+ else if (oldCls) { line.styleClasses = null }
+ var ischange = !oldStyles || oldStyles.length != line.styles.length ||
+ oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass)
+ for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i] }
+ if (ischange) { changedLines.push(doc.frontier) }
+ line.stateAfter = tooLong ? state : copyState(doc.mode, state)
+ } else {
+ if (line.text.length <= cm.options.maxHighlightLength)
+ { processLine(cm, line.text, state) }
+ line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null
+ }
+ ++doc.frontier
+ if (+new Date > end) {
+ startWorker(cm, cm.options.workDelay)
+ return true
+ }
+ })
+ if (changedLines.length) { runInOp(cm, function () {
+ for (var i = 0; i < changedLines.length; i++)
+ { regLineChange(cm, changedLines[i], "text") }
+ }) }
+}
+
+// DISPLAY DRAWING
+
+var DisplayUpdate = function(cm, viewport, force) {
+ var display = cm.display
+
+ this.viewport = viewport
+ // Store some values that we'll need later (but don't want to force a relayout for)
+ this.visible = visibleLines(display, cm.doc, viewport)
+ this.editorIsHidden = !display.wrapper.offsetWidth
+ this.wrapperHeight = display.wrapper.clientHeight
+ this.wrapperWidth = display.wrapper.clientWidth
+ this.oldDisplayWidth = displayWidth(cm)
+ this.force = force
+ this.dims = getDimensions(cm)
+ this.events = []
+};
- receivedFocus: function() {
- var input = this;
- if (this.selectionInEditor())
- this.pollSelection();
- else
- runInOp(this.cm, function() { input.cm.curOp.selectionChanged = true; });
+DisplayUpdate.prototype.signal = function (emitter, type) {
+ if (hasHandler(emitter, type))
+ { this.events.push(arguments) }
+};
+DisplayUpdate.prototype.finish = function () {
+ var this$1 = this;
- function poll() {
- if (input.cm.state.focused) {
- input.pollSelection();
- input.polling.set(input.cm.options.pollInterval, poll);
- }
- }
- this.polling.set(this.cm.options.pollInterval, poll);
- },
+ for (var i = 0; i < this.events.length; i++)
+ { signal.apply(null, this$1.events[i]) }
+};
- selectionChanged: function() {
- var sel = window.getSelection();
- return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
- sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset;
- },
+function maybeClipScrollbars(cm) {
+ var display = cm.display
+ if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
+ display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth
+ display.heightForcer.style.height = scrollGap(cm) + "px"
+ display.sizer.style.marginBottom = -display.nativeBarWidth + "px"
+ display.sizer.style.borderRightWidth = scrollGap(cm) + "px"
+ display.scrollbarsClipped = true
+ }
+}
+
+// Does the actual updating of the line display. Bails out
+// (returning false) when there is nothing to be done and forced is
+// false.
+function updateDisplayIfNeeded(cm, update) {
+ var display = cm.display, doc = cm.doc
- pollSelection: function() {
- if (!this.composing && !this.gracePeriod && this.selectionChanged()) {
- var sel = window.getSelection(), cm = this.cm;
- this.rememberSelection();
- var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
- var head = domToPos(cm, sel.focusNode, sel.focusOffset);
- if (anchor && head) runInOp(cm, function() {
- setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
- if (anchor.bad || head.bad) cm.curOp.selectionChanged = true;
- });
- }
- },
+ if (update.editorIsHidden) {
+ resetView(cm)
+ return false
+ }
+
+ // Bail out if the visible area is already rendered and nothing changed.
+ if (!update.force &&
+ update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
+ (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
+ display.renderedView == display.view && countDirtyView(cm) == 0)
+ { return false }
- pollContent: function() {
- var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
- var from = sel.from(), to = sel.to();
- if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false;
+ if (maybeUpdateLineNumberWidth(cm)) {
+ resetView(cm)
+ update.dims = getDimensions(cm)
+ }
+
+ // Compute a suitable new viewport (from & to)
+ var end = doc.first + doc.size
+ var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first)
+ var to = Math.min(end, update.visible.to + cm.options.viewportMargin)
+ if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom) }
+ if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo) }
+ if (sawCollapsedSpans) {
+ from = visualLineNo(cm.doc, from)
+ to = visualLineEndNo(cm.doc, to)
+ }
+
+ var different = from != display.viewFrom || to != display.viewTo ||
+ display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth
+ adjustView(cm, from, to)
+
+ display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom))
+ // Position the mover div to align with the current scroll position
+ cm.display.mover.style.top = display.viewOffset + "px"
+
+ var toUpdate = countDirtyView(cm)
+ if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
+ (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
+ { return false }
+
+ // For big changes, we hide the enclosing element during the
+ // update, since that speeds up the operations on most browsers.
+ var focused = activeElt()
+ if (toUpdate > 4) { display.lineDiv.style.display = "none" }
+ patchDisplay(cm, display.updateLineNumbers, update.dims)
+ if (toUpdate > 4) { display.lineDiv.style.display = "" }
+ display.renderedView = display.view
+ // There might have been a widget with a focused element that got
+ // hidden or updated, if so re-focus it.
+ if (focused && activeElt() != focused && focused.offsetHeight) { focused.focus() }
+
+ // Prevent selection and cursors from interfering with the scroll
+ // width and height.
+ removeChildren(display.cursorDiv)
+ removeChildren(display.selectionDiv)
+ display.gutters.style.height = display.sizer.style.minHeight = 0
+
+ if (different) {
+ display.lastWrapHeight = update.wrapperHeight
+ display.lastWrapWidth = update.wrapperWidth
+ startWorker(cm, 400)
+ }
+
+ display.updateLineNumbers = null
+
+ return true
+}
+
+function postUpdateDisplay(cm, update) {
+ var viewport = update.viewport
+
+ for (var first = true;; first = false) {
+ if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
+ // Clip forced viewport to actual scrollable area.
+ if (viewport && viewport.top != null)
+ { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)} }
+ // Updated line heights might result in the drawn area not
+ // actually covering the viewport. Keep looping until it does.
+ update.visible = visibleLines(cm.display, cm.doc, viewport)
+ if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
+ { break }
+ }
+ if (!updateDisplayIfNeeded(cm, update)) { break }
+ updateHeightsInViewport(cm)
+ var barMeasure = measureForScrollbars(cm)
+ updateSelection(cm)
+ updateScrollbars(cm, barMeasure)
+ setDocumentHeight(cm, barMeasure)
+ }
+
+ update.signal(cm, "update", cm)
+ if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
+ update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo)
+ cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo
+ }
+}
+
+function updateDisplaySimple(cm, viewport) {
+ var update = new DisplayUpdate(cm, viewport)
+ if (updateDisplayIfNeeded(cm, update)) {
+ updateHeightsInViewport(cm)
+ postUpdateDisplay(cm, update)
+ var barMeasure = measureForScrollbars(cm)
+ updateSelection(cm)
+ updateScrollbars(cm, barMeasure)
+ setDocumentHeight(cm, barMeasure)
+ update.finish()
+ }
+}
+
+// Sync the actual display DOM structure with display.view, removing
+// nodes for lines that are no longer in view, and creating the ones
+// that are not there yet, and updating the ones that are out of
+// date.
+function patchDisplay(cm, updateNumbersFrom, dims) {
+ var display = cm.display, lineNumbers = cm.options.lineNumbers
+ var container = display.lineDiv, cur = container.firstChild
+
+ function rm(node) {
+ var next = node.nextSibling
+ // Works around a throw-scroll bug in OS X Webkit
+ if (webkit && mac && cm.display.currentWheelTarget == node)
+ { node.style.display = "none" }
+ else
+ { node.parentNode.removeChild(node) }
+ return next
+ }
+
+ var view = display.view, lineN = display.viewFrom
+ // Loop over the elements in the view, syncing cur (the DOM nodes
+ // in display.lineDiv) with the view as we go.
+ for (var i = 0; i < view.length; i++) {
+ var lineView = view[i]
+ if (lineView.hidden) {
+ } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
+ var node = buildLineElement(cm, lineView, lineN, dims)
+ container.insertBefore(node, cur)
+ } else { // Already drawn
+ while (cur != lineView.node) { cur = rm(cur) }
+ var updateNumber = lineNumbers && updateNumbersFrom != null &&
+ updateNumbersFrom <= lineN && lineView.lineNumber
+ if (lineView.changes) {
+ if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false }
+ updateLineForChanges(cm, lineView, lineN, dims)
+ }
+ if (updateNumber) {
+ removeChildren(lineView.lineNumber)
+ lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)))
+ }
+ cur = lineView.node.nextSibling
+ }
+ lineN += lineView.size
+ }
+ while (cur) { cur = rm(cur) }
+}
+
+function updateGutterSpace(cm) {
+ var width = cm.display.gutters.offsetWidth
+ cm.display.sizer.style.marginLeft = width + "px"
+}
+
+function setDocumentHeight(cm, measure) {
+ cm.display.sizer.style.minHeight = measure.docHeight + "px"
+ cm.display.heightForcer.style.top = measure.docHeight + "px"
+ cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px"
+}
+
+// Rebuild the gutter elements, ensure the margin to the left of the
+// code matches their width.
+function updateGutters(cm) {
+ var gutters = cm.display.gutters, specs = cm.options.gutters
+ removeChildren(gutters)
+ var i = 0
+ for (; i < specs.length; ++i) {
+ var gutterClass = specs[i]
+ var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass))
+ if (gutterClass == "CodeMirror-linenumbers") {
+ cm.display.lineGutter = gElt
+ gElt.style.width = (cm.display.lineNumWidth || 1) + "px"
+ }
+ }
+ gutters.style.display = i ? "" : "none"
+ updateGutterSpace(cm)
+}
+
+// Make sure the gutters options contains the element
+// "CodeMirror-linenumbers" when the lineNumbers option is true.
+function setGuttersForLineNumbers(options) {
+ var found = indexOf(options.gutters, "CodeMirror-linenumbers")
+ if (found == -1 && options.lineNumbers) {
+ options.gutters = options.gutters.concat(["CodeMirror-linenumbers"])
+ } else if (found > -1 && !options.lineNumbers) {
+ options.gutters = options.gutters.slice(0)
+ options.gutters.splice(found, 1)
+ }
+}
+
+// Selection objects are immutable. A new one is created every time
+// the selection changes. A selection is one or more non-overlapping
+// (and non-touching) ranges, sorted, and an integer that indicates
+// which one is the primary selection (the one that's scrolled into
+// view, that getCursor returns, etc).
+var Selection = function(ranges, primIndex) {
+ this.ranges = ranges
+ this.primIndex = primIndex
+};
- var fromIndex;
- if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
- var fromLine = lineNo(display.view[0].line);
- var fromNode = display.view[0].node;
- } else {
- var fromLine = lineNo(display.view[fromIndex].line);
- var fromNode = display.view[fromIndex - 1].node.nextSibling;
- }
- var toIndex = findViewIndex(cm, to.line);
- if (toIndex == display.view.length - 1) {
- var toLine = display.viewTo - 1;
- var toNode = display.lineDiv.lastChild;
- } else {
- var toLine = lineNo(display.view[toIndex + 1].line) - 1;
- var toNode = display.view[toIndex + 1].node.previousSibling;
- }
-
- var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
- var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
- while (newText.length > 1 && oldText.length > 1) {
- if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
- else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
- else break;
- }
-
- var cutFront = 0, cutEnd = 0;
- var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
- while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
- ++cutFront;
- var newBot = lst(newText), oldBot = lst(oldText);
- var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
- oldBot.length - (oldText.length == 1 ? cutFront : 0));
- while (cutEnd < maxCutEnd &&
- newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
- ++cutEnd;
-
- newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd);
- newText[0] = newText[0].slice(cutFront);
-
- var chFrom = Pos(fromLine, cutFront);
- var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
- if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
- replaceRange(cm.doc, newText, chFrom, chTo, "+input");
- return true;
- }
- },
+Selection.prototype.primary = function () { return this.ranges[this.primIndex] };
- ensurePolled: function() {
- this.forceCompositionEnd();
- },
- reset: function() {
- this.forceCompositionEnd();
- },
- forceCompositionEnd: function() {
- if (!this.composing || this.composing.handled) return;
- this.applyComposition(this.composing);
- this.composing.handled = true;
- this.div.blur();
- this.div.focus();
- },
- applyComposition: function(composing) {
- if (this.cm.isReadOnly())
- operation(this.cm, regChange)(this.cm)
- else if (composing.data && composing.data != composing.startData)
- operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel);
- },
+Selection.prototype.equals = function (other) {
+ var this$1 = this;
- setUneditable: function(node) {
- node.contentEditable = "false"
- },
+ if (other == this) { return true }
+ if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }
+ for (var i = 0; i < this.ranges.length; i++) {
+ var here = this$1.ranges[i], there = other.ranges[i]
+ if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false }
+ }
+ return true
+};
- onKeyPress: function(e) {
- e.preventDefault();
- if (!this.cm.isReadOnly())
- operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0);
- },
+Selection.prototype.deepCopy = function () {
+ var this$1 = this;
- readOnlyChanged: function(val) {
- this.div.contentEditable = String(val != "nocursor")
- },
+ var out = []
+ for (var i = 0; i < this.ranges.length; i++)
+ { out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)) }
+ return new Selection(out, this.primIndex)
+};
- onContextMenu: nothing,
- resetPosition: nothing,
+Selection.prototype.somethingSelected = function () {
+ var this$1 = this;
- needsContentAttribute: true
- }, ContentEditableInput.prototype);
+ for (var i = 0; i < this.ranges.length; i++)
+ { if (!this$1.ranges[i].empty()) { return true } }
+ return false
+};
- function posToDOM(cm, pos) {
- var view = findViewForLine(cm, pos.line);
- if (!view || view.hidden) return null;
- var line = getLine(cm.doc, pos.line);
- var info = mapFromLineView(view, line, pos.line);
+Selection.prototype.contains = function (pos, end) {
+ var this$1 = this;
- var order = getOrder(line), side = "left";
- if (order) {
- var partPos = getBidiPartAt(order, pos.ch);
- side = partPos % 2 ? "right" : "left";
- }
- var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
- result.offset = result.collapse == "right" ? result.end : result.start;
- return result;
+ if (!end) { end = pos }
+ for (var i = 0; i < this.ranges.length; i++) {
+ var range = this$1.ranges[i]
+ if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
+ { return i }
}
+ return -1
+};
- function badPos(pos, bad) { if (bad) pos.bad = true; return pos; }
+var Range = function(anchor, head) {
+ this.anchor = anchor; this.head = head
+};
- function domToPos(cm, node, offset) {
- var lineNode;
- if (node == cm.display.lineDiv) {
- lineNode = cm.display.lineDiv.childNodes[offset];
- if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true);
- node = null; offset = 0;
+Range.prototype.from = function () { return minPos(this.anchor, this.head) };
+Range.prototype.to = function () { return maxPos(this.anchor, this.head) };
+Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch };
+
+// Take an unsorted, potentially overlapping set of ranges, and
+// build a selection out of it. 'Consumes' ranges array (modifying
+// it).
+function normalizeSelection(ranges, primIndex) {
+ var prim = ranges[primIndex]
+ ranges.sort(function (a, b) { return cmp(a.from(), b.from()); })
+ primIndex = indexOf(ranges, prim)
+ for (var i = 1; i < ranges.length; i++) {
+ var cur = ranges[i], prev = ranges[i - 1]
+ if (cmp(prev.to(), cur.from()) >= 0) {
+ var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to())
+ var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head
+ if (i <= primIndex) { --primIndex }
+ ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to))
+ }
+ }
+ return new Selection(ranges, primIndex)
+}
+
+function simpleSelection(anchor, head) {
+ return new Selection([new Range(anchor, head || anchor)], 0)
+}
+
+// Compute the position of the end of a change (its 'to' property
+// refers to the pre-change end).
+function changeEnd(change) {
+ if (!change.text) { return change.to }
+ return Pos(change.from.line + change.text.length - 1,
+ lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0))
+}
+
+// Adjust a position to refer to the post-change position of the
+// same text, or the end of the change if the change covers it.
+function adjustForChange(pos, change) {
+ if (cmp(pos, change.from) < 0) { return pos }
+ if (cmp(pos, change.to) <= 0) { return changeEnd(change) }
+
+ var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch
+ if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch }
+ return Pos(line, ch)
+}
+
+function computeSelAfterChange(doc, change) {
+ var out = []
+ for (var i = 0; i < doc.sel.ranges.length; i++) {
+ var range = doc.sel.ranges[i]
+ out.push(new Range(adjustForChange(range.anchor, change),
+ adjustForChange(range.head, change)))
+ }
+ return normalizeSelection(out, doc.sel.primIndex)
+}
+
+function offsetPos(pos, old, nw) {
+ if (pos.line == old.line)
+ { return Pos(nw.line, pos.ch - old.ch + nw.ch) }
+ else
+ { return Pos(nw.line + (pos.line - old.line), pos.ch) }
+}
+
+// Used by replaceSelections to allow moving the selection to the
+// start or around the replaced test. Hint may be "start" or "around".
+function computeReplacedSel(doc, changes, hint) {
+ var out = []
+ var oldPrev = Pos(doc.first, 0), newPrev = oldPrev
+ for (var i = 0; i < changes.length; i++) {
+ var change = changes[i]
+ var from = offsetPos(change.from, oldPrev, newPrev)
+ var to = offsetPos(changeEnd(change), oldPrev, newPrev)
+ oldPrev = change.to
+ newPrev = to
+ if (hint == "around") {
+ var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0
+ out[i] = new Range(inv ? to : from, inv ? from : to)
} else {
- for (lineNode = node;; lineNode = lineNode.parentNode) {
- if (!lineNode || lineNode == cm.display.lineDiv) return null;
- if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break;
- }
- }
- for (var i = 0; i < cm.display.view.length; i++) {
- var lineView = cm.display.view[i];
- if (lineView.node == lineNode)
- return locateNodeInLineView(lineView, node, offset);
+ out[i] = new Range(from, from)
}
}
+ return new Selection(out, doc.sel.primIndex)
+}
- function locateNodeInLineView(lineView, node, offset) {
- var wrapper = lineView.text.firstChild, bad = false;
- if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true);
- if (node == wrapper) {
- bad = true;
- node = wrapper.childNodes[offset];
- offset = 0;
- if (!node) {
- var line = lineView.rest ? lst(lineView.rest) : lineView.line;
- return badPos(Pos(lineNo(line), line.text.length), bad);
- }
- }
-
- var textNode = node.nodeType == 3 ? node : null, topNode = node;
- if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
- textNode = node.firstChild;
- if (offset) offset = textNode.nodeValue.length;
- }
- while (topNode.parentNode != wrapper) topNode = topNode.parentNode;
- var measure = lineView.measure, maps = measure.maps;
+// Used to get the editor into a consistent state again when options change.
- function find(textNode, topNode, offset) {
- for (var i = -1; i < (maps ? maps.length : 0); i++) {
- var map = i < 0 ? measure.map : maps[i];
- for (var j = 0; j < map.length; j += 3) {
- var curNode = map[j + 2];
- if (curNode == textNode || curNode == topNode) {
- var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
- var ch = map[j] + offset;
- if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)];
- return Pos(line, ch);
- }
- }
- }
- }
- var found = find(textNode, topNode, offset);
- if (found) return badPos(found, bad);
+function loadMode(cm) {
+ cm.doc.mode = getMode(cm.options, cm.doc.modeOption)
+ resetModeState(cm)
+}
- // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
- for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
- found = find(after, after.firstChild, 0);
- if (found)
- return badPos(Pos(found.line, found.ch - dist), bad);
- else
- dist += after.textContent.length;
- }
- for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) {
- found = find(before, before.firstChild, -1);
- if (found)
- return badPos(Pos(found.line, found.ch + dist), bad);
- else
- dist += after.textContent.length;
- }
- }
-
- function domTextBetween(cm, from, to, fromLine, toLine) {
- var text = "", closing = false, lineSep = cm.doc.lineSeparator();
- function recognizeMarker(id) { return function(marker) { return marker.id == id; }; }
- function walk(node) {
- if (node.nodeType == 1) {
- var cmText = node.getAttribute("cm-text");
- if (cmText != null) {
- if (cmText == "") cmText = node.textContent.replace(/\u200b/g, "");
- text += cmText;
- return;
- }
- var markerID = node.getAttribute("cm-marker"), range;
- if (markerID) {
- var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
- if (found.length && (range = found[0].find()))
- text += getBetween(cm.doc, range.from, range.to).join(lineSep);
- return;
- }
- if (node.getAttribute("contenteditable") == "false") return;
- for (var i = 0; i < node.childNodes.length; i++)
- walk(node.childNodes[i]);
- if (/^(pre|div|p)$/i.test(node.nodeName))
- closing = true;
- } else if (node.nodeType == 3) {
- var val = node.nodeValue;
- if (!val) return;
- if (closing) {
- text += lineSep;
- closing = false;
- }
- text += val;
- }
- }
- for (;;) {
- walk(from);
- if (from == to) break;
- from = from.nextSibling;
- }
- return text;
- }
+function resetModeState(cm) {
+ cm.doc.iter(function (line) {
+ if (line.stateAfter) { line.stateAfter = null }
+ if (line.styles) { line.styles = null }
+ })
+ cm.doc.frontier = cm.doc.first
+ startWorker(cm, 100)
+ cm.state.modeGen++
+ if (cm.curOp) { regChange(cm) }
+}
- CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
+// DOCUMENT DATA STRUCTURE
- // SELECTION / CURSOR
+// By default, updates that start and end at the beginning of a line
+// are treated specially, in order to make the association of line
+// widgets and marker elements with the text behave more intuitive.
+function isWholeLineUpdate(doc, change) {
+ return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
+ (!doc.cm || doc.cm.options.wholeLineUpdateBefore)
+}
- // Selection objects are immutable. A new one is created every time
- // the selection changes. A selection is one or more non-overlapping
- // (and non-touching) ranges, sorted, and an integer that indicates
- // which one is the primary selection (the one that's scrolled into
- // view, that getCursor returns, etc).
- function Selection(ranges, primIndex) {
- this.ranges = ranges;
- this.primIndex = primIndex;
+// Perform a change on the document data structure.
+function updateDoc(doc, change, markedSpans, estimateHeight) {
+ function spansFor(n) {return markedSpans ? markedSpans[n] : null}
+ function update(line, text, spans) {
+ updateLine(line, text, spans, estimateHeight)
+ signalLater(line, "change", line, change)
}
-
- Selection.prototype = {
- primary: function() { return this.ranges[this.primIndex]; },
- equals: function(other) {
- if (other == this) return true;
- if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false;
- for (var i = 0; i < this.ranges.length; i++) {
- var here = this.ranges[i], there = other.ranges[i];
- if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false;
- }
- return true;
- },
- deepCopy: function() {
- for (var out = [], i = 0; i < this.ranges.length; i++)
- out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head));
- return new Selection(out, this.primIndex);
- },
- somethingSelected: function() {
- for (var i = 0; i < this.ranges.length; i++)
- if (!this.ranges[i].empty()) return true;
- return false;
- },
- contains: function(pos, end) {
- if (!end) end = pos;
- for (var i = 0; i < this.ranges.length; i++) {
- var range = this.ranges[i];
- if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
- return i;
- }
- return -1;
- }
- };
-
- function Range(anchor, head) {
- this.anchor = anchor; this.head = head;
+ function linesFor(start, end) {
+ var result = []
+ for (var i = start; i < end; ++i)
+ { result.push(new Line(text[i], spansFor(i), estimateHeight)) }
+ return result
}
- Range.prototype = {
- from: function() { return minPos(this.anchor, this.head); },
- to: function() { return maxPos(this.anchor, this.head); },
- empty: function() {
- return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch;
- }
- };
+ var from = change.from, to = change.to, text = change.text
+ var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line)
+ var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line
- // Take an unsorted, potentially overlapping set of ranges, and
- // build a selection out of it. 'Consumes' ranges array (modifying
- // it).
- function normalizeSelection(ranges, primIndex) {
- var prim = ranges[primIndex];
- ranges.sort(function(a, b) { return cmp(a.from(), b.from()); });
- primIndex = indexOf(ranges, prim);
- for (var i = 1; i < ranges.length; i++) {
- var cur = ranges[i], prev = ranges[i - 1];
- if (cmp(prev.to(), cur.from()) >= 0) {
- var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
- var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
- if (i <= primIndex) --primIndex;
- ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
- }
- }
- return new Selection(ranges, primIndex);
- }
-
- function simpleSelection(anchor, head) {
- return new Selection([new Range(anchor, head || anchor)], 0);
- }
-
- // Most of the external API clips given positions to make sure they
- // actually exist within the document.
- function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));}
- function clipPos(doc, pos) {
- if (pos.line < doc.first) return Pos(doc.first, 0);
- var last = doc.first + doc.size - 1;
- if (pos.line > last) return Pos(last, getLine(doc, last).text.length);
- return clipToLen(pos, getLine(doc, pos.line).text.length);
- }
- function clipToLen(pos, linelen) {
- var ch = pos.ch;
- if (ch == null || ch > linelen) return Pos(pos.line, linelen);
- else if (ch < 0) return Pos(pos.line, 0);
- else return pos;
- }
- function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;}
- function clipPosArray(doc, array) {
- for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]);
- return out;
- }
-
- // SELECTION UPDATES
-
- // The 'scroll' parameter given to many of these indicated whether
- // the new cursor position should be scrolled into view after
- // modifying the selection.
-
- // If shift is held or the extend flag is set, extends a range to
- // include a given position (and optionally a second position).
- // Otherwise, simply returns the range between the given positions.
- // Used for cursor motion and such.
- function extendRange(doc, range, head, other) {
- if (doc.cm && doc.cm.display.shift || doc.extend) {
- var anchor = range.anchor;
- if (other) {
- var posBefore = cmp(head, anchor) < 0;
- if (posBefore != (cmp(other, anchor) < 0)) {
- anchor = head;
- head = other;
- } else if (posBefore != (cmp(head, other) < 0)) {
- head = other;
- }
- }
- return new Range(anchor, head);
+ // Adjust the line structure
+ if (change.full) {
+ doc.insert(0, linesFor(0, text.length))
+ doc.remove(text.length, doc.size - text.length)
+ } else if (isWholeLineUpdate(doc, change)) {
+ // This is a whole-line replace. Treated specially to make
+ // sure line objects move the way they are supposed to.
+ var added = linesFor(0, text.length - 1)
+ update(lastLine, lastLine.text, lastSpans)
+ if (nlines) { doc.remove(from.line, nlines) }
+ if (added.length) { doc.insert(from.line, added) }
+ } else if (firstLine == lastLine) {
+ if (text.length == 1) {
+ update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans)
} else {
- return new Range(other || head, head);
+ var added$1 = linesFor(1, text.length - 1)
+ added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight))
+ update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0))
+ doc.insert(from.line + 1, added$1)
+ }
+ } else if (text.length == 1) {
+ update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0))
+ doc.remove(from.line + 1, nlines)
+ } else {
+ update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0))
+ update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans)
+ var added$2 = linesFor(1, text.length - 1)
+ if (nlines > 1) { doc.remove(from.line + 1, nlines - 1) }
+ doc.insert(from.line + 1, added$2)
+ }
+
+ signalLater(doc, "change", doc, change)
+}
+
+// Call f for all linked documents.
+function linkedDocs(doc, f, sharedHistOnly) {
+ function propagate(doc, skip, sharedHist) {
+ if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) {
+ var rel = doc.linked[i]
+ if (rel.doc == skip) { continue }
+ var shared = sharedHist && rel.sharedHist
+ if (sharedHistOnly && !shared) { continue }
+ f(rel.doc, shared)
+ propagate(rel.doc, doc, shared)
+ } }
+ }
+ propagate(doc, null, true)
+}
+
+// Attach a document to an editor.
+function attachDoc(cm, doc) {
+ if (doc.cm) { throw new Error("This document is already in use.") }
+ cm.doc = doc
+ doc.cm = cm
+ estimateLineHeights(cm)
+ loadMode(cm)
+ if (!cm.options.lineWrapping) { findMaxLine(cm) }
+ cm.options.mode = doc.modeOption
+ regChange(cm)
+}
+
+function History(startGen) {
+ // Arrays of change events and selections. Doing something adds an
+ // event to done and clears undo. Undoing moves events from done
+ // to undone, redoing moves them in the other direction.
+ this.done = []; this.undone = []
+ this.undoDepth = Infinity
+ // Used to track when changes can be merged into a single undo
+ // event
+ this.lastModTime = this.lastSelTime = 0
+ this.lastOp = this.lastSelOp = null
+ this.lastOrigin = this.lastSelOrigin = null
+ // Used by the isClean() method
+ this.generation = this.maxGeneration = startGen || 1
+}
+
+// Create a history change event from an updateDoc-style change
+// object.
+function historyChangeFromChange(doc, change) {
+ var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}
+ attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1)
+ linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true)
+ return histChange
+}
+
+// Pop all selection events off the end of a history array. Stop at
+// a change event.
+function clearSelectionEvents(array) {
+ while (array.length) {
+ var last = lst(array)
+ if (last.ranges) { array.pop() }
+ else { break }
+ }
+}
+
+// Find the top change event in the history. Pop off selection
+// events that are in the way.
+function lastChangeEvent(hist, force) {
+ if (force) {
+ clearSelectionEvents(hist.done)
+ return lst(hist.done)
+ } else if (hist.done.length && !lst(hist.done).ranges) {
+ return lst(hist.done)
+ } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
+ hist.done.pop()
+ return lst(hist.done)
+ }
+}
+
+// Register a change in the history. Merges changes that are within
+// a single operation, or are close together with an origin that
+// allows merging (starting with "+") into a single event.
+function addChangeToHistory(doc, change, selAfter, opId) {
+ var hist = doc.history
+ hist.undone.length = 0
+ var time = +new Date, cur
+ var last
+
+ if ((hist.lastOp == opId ||
+ hist.lastOrigin == change.origin && change.origin &&
+ ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
+ change.origin.charAt(0) == "*")) &&
+ (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
+ // Merge this change into the last event
+ last = lst(cur.changes)
+ if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
+ // Optimized case for simple insertion -- don't want to add
+ // new changesets for every character typed
+ last.to = changeEnd(change)
+ } else {
+ // Add new sub-event
+ cur.changes.push(historyChangeFromChange(doc, change))
}
+ } else {
+ // Can not be merged, start a new event.
+ var before = lst(hist.done)
+ if (!before || !before.ranges)
+ { pushSelectionToHistory(doc.sel, hist.done) }
+ cur = {changes: [historyChangeFromChange(doc, change)],
+ generation: hist.generation}
+ hist.done.push(cur)
+ while (hist.done.length > hist.undoDepth) {
+ hist.done.shift()
+ if (!hist.done[0].ranges) { hist.done.shift() }
+ }
+ }
+ hist.done.push(selAfter)
+ hist.generation = ++hist.maxGeneration
+ hist.lastModTime = hist.lastSelTime = time
+ hist.lastOp = hist.lastSelOp = opId
+ hist.lastOrigin = hist.lastSelOrigin = change.origin
+
+ if (!last) { signal(doc, "historyAdded") }
+}
+
+function selectionEventCanBeMerged(doc, origin, prev, sel) {
+ var ch = origin.charAt(0)
+ return ch == "*" ||
+ ch == "+" &&
+ prev.ranges.length == sel.ranges.length &&
+ prev.somethingSelected() == sel.somethingSelected() &&
+ new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500)
+}
+
+// Called whenever the selection changes, sets the new selection as
+// the pending selection in the history, and pushes the old pending
+// selection into the 'done' array when it was significantly
+// different (in number of selected ranges, emptiness, or time).
+function addSelectionToHistory(doc, sel, opId, options) {
+ var hist = doc.history, origin = options && options.origin
+
+ // A new event is started when the previous origin does not match
+ // the current, or the origins don't allow matching. Origins
+ // starting with * are always merged, those starting with + are
+ // merged when similar and close together in time.
+ if (opId == hist.lastSelOp ||
+ (origin && hist.lastSelOrigin == origin &&
+ (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
+ selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
+ { hist.done[hist.done.length - 1] = sel }
+ else
+ { pushSelectionToHistory(sel, hist.done) }
+
+ hist.lastSelTime = +new Date
+ hist.lastSelOrigin = origin
+ hist.lastSelOp = opId
+ if (options && options.clearRedo !== false)
+ { clearSelectionEvents(hist.undone) }
+}
+
+function pushSelectionToHistory(sel, dest) {
+ var top = lst(dest)
+ if (!(top && top.ranges && top.equals(sel)))
+ { dest.push(sel) }
+}
+
+// Used to store marked span information in the history.
+function attachLocalSpans(doc, change, from, to) {
+ var existing = change["spans_" + doc.id], n = 0
+ doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) {
+ if (line.markedSpans)
+ { (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans }
+ ++n
+ })
+}
+
+// When un/re-doing restores text containing marked spans, those
+// that have been explicitly cleared should not be restored.
+function removeClearedSpans(spans) {
+ if (!spans) { return null }
+ var out
+ for (var i = 0; i < spans.length; ++i) {
+ if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i) } }
+ else if (out) { out.push(spans[i]) }
+ }
+ return !out ? spans : out.length ? out : null
+}
+
+// Retrieve and filter the old marked spans stored in a change event.
+function getOldSpans(doc, change) {
+ var found = change["spans_" + doc.id]
+ if (!found) { return null }
+ var nw = []
+ for (var i = 0; i < change.text.length; ++i)
+ { nw.push(removeClearedSpans(found[i])) }
+ return nw
+}
+
+// Used for un/re-doing changes from the history. Combines the
+// result of computing the existing spans with the set of spans that
+// existed in the history (so that deleting around a span and then
+// undoing brings back the span).
+function mergeOldSpans(doc, change) {
+ var old = getOldSpans(doc, change)
+ var stretched = stretchSpansOverChange(doc, change)
+ if (!old) { return stretched }
+ if (!stretched) { return old }
+
+ for (var i = 0; i < old.length; ++i) {
+ var oldCur = old[i], stretchCur = stretched[i]
+ if (oldCur && stretchCur) {
+ spans: for (var j = 0; j < stretchCur.length; ++j) {
+ var span = stretchCur[j]
+ for (var k = 0; k < oldCur.length; ++k)
+ { if (oldCur[k].marker == span.marker) { continue spans } }
+ oldCur.push(span)
+ }
+ } else if (stretchCur) {
+ old[i] = stretchCur
+ }
+ }
+ return old
+}
+
+// Used both to provide a JSON-safe object in .getHistory, and, when
+// detaching a document, to split the history in two
+function copyHistoryArray(events, newGroup, instantiateSel) {
+ var copy = []
+ for (var i = 0; i < events.length; ++i) {
+ var event = events[i]
+ if (event.ranges) {
+ copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event)
+ continue
+ }
+ var changes = event.changes, newChanges = []
+ copy.push({changes: newChanges})
+ for (var j = 0; j < changes.length; ++j) {
+ var change = changes[j], m = (void 0)
+ newChanges.push({from: change.from, to: change.to, text: change.text})
+ if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) {
+ if (indexOf(newGroup, Number(m[1])) > -1) {
+ lst(newChanges)[prop] = change[prop]
+ delete change[prop]
+ }
+ } } }
+ }
+ }
+ return copy
+}
+
+// The 'scroll' parameter given to many of these indicated whether
+// the new cursor position should be scrolled into view after
+// modifying the selection.
+
+// If shift is held or the extend flag is set, extends a range to
+// include a given position (and optionally a second position).
+// Otherwise, simply returns the range between the given positions.
+// Used for cursor motion and such.
+function extendRange(doc, range, head, other) {
+ if (doc.cm && doc.cm.display.shift || doc.extend) {
+ var anchor = range.anchor
+ if (other) {
+ var posBefore = cmp(head, anchor) < 0
+ if (posBefore != (cmp(other, anchor) < 0)) {
+ anchor = head
+ head = other
+ } else if (posBefore != (cmp(head, other) < 0)) {
+ head = other
+ }
+ }
+ return new Range(anchor, head)
+ } else {
+ return new Range(other || head, head)
}
+}
- // Extend the primary selection range, discard the rest.
- function extendSelection(doc, head, other, options) {
- setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options);
- }
+// Extend the primary selection range, discard the rest.
+function extendSelection(doc, head, other, options) {
+ setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options)
+}
- // Extend all selections (pos is an array of selections with length
- // equal the number of selections)
- function extendSelections(doc, heads, options) {
- for (var out = [], i = 0; i < doc.sel.ranges.length; i++)
- out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null);
- var newSel = normalizeSelection(out, doc.sel.primIndex);
- setSelection(doc, newSel, options);
- }
+// Extend all selections (pos is an array of selections with length
+// equal the number of selections)
+function extendSelections(doc, heads, options) {
+ var out = []
+ for (var i = 0; i < doc.sel.ranges.length; i++)
+ { out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null) }
+ var newSel = normalizeSelection(out, doc.sel.primIndex)
+ setSelection(doc, newSel, options)
+}
- // Updates a single range in the selection.
- function replaceOneSelection(doc, i, range, options) {
- var ranges = doc.sel.ranges.slice(0);
- ranges[i] = range;
- setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
- }
+// Updates a single range in the selection.
+function replaceOneSelection(doc, i, range, options) {
+ var ranges = doc.sel.ranges.slice(0)
+ ranges[i] = range
+ setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options)
+}
- // Reset the selection to a single range.
- function setSimpleSelection(doc, anchor, head, options) {
- setSelection(doc, simpleSelection(anchor, head), options);
- }
+// Reset the selection to a single range.
+function setSimpleSelection(doc, anchor, head, options) {
+ setSelection(doc, simpleSelection(anchor, head), options)
+}
- // Give beforeSelectionChange handlers a change to influence a
- // selection update.
- function filterSelectionChange(doc, sel, options) {
- var obj = {
- ranges: sel.ranges,
- update: function(ranges) {
- this.ranges = [];
- for (var i = 0; i < ranges.length; i++)
- this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
- clipPos(doc, ranges[i].head));
- },
- origin: options && options.origin
- };
- signal(doc, "beforeSelectionChange", doc, obj);
- if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj);
- if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1);
- else return sel;
- }
+// Give beforeSelectionChange handlers a change to influence a
+// selection update.
+function filterSelectionChange(doc, sel, options) {
+ var obj = {
+ ranges: sel.ranges,
+ update: function(ranges) {
+ var this$1 = this;
- function setSelectionReplaceHistory(doc, sel, options) {
- var done = doc.history.done, last = lst(done);
- if (last && last.ranges) {
- done[done.length - 1] = sel;
- setSelectionNoUndo(doc, sel, options);
- } else {
- setSelection(doc, sel, options);
- }
+ this.ranges = []
+ for (var i = 0; i < ranges.length; i++)
+ { this$1.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
+ clipPos(doc, ranges[i].head)) }
+ },
+ origin: options && options.origin
}
+ signal(doc, "beforeSelectionChange", doc, obj)
+ if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj) }
+ if (obj.ranges != sel.ranges) { return normalizeSelection(obj.ranges, obj.ranges.length - 1) }
+ else { return sel }
+}
- // Set a new selection.
- function setSelection(doc, sel, options) {
- setSelectionNoUndo(doc, sel, options);
- addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
+function setSelectionReplaceHistory(doc, sel, options) {
+ var done = doc.history.done, last = lst(done)
+ if (last && last.ranges) {
+ done[done.length - 1] = sel
+ setSelectionNoUndo(doc, sel, options)
+ } else {
+ setSelection(doc, sel, options)
}
+}
- function setSelectionNoUndo(doc, sel, options) {
- if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
- sel = filterSelectionChange(doc, sel, options);
+// Set a new selection.
+function setSelection(doc, sel, options) {
+ setSelectionNoUndo(doc, sel, options)
+ addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options)
+}
- var bias = options && options.bias ||
- (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
- setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
+function setSelectionNoUndo(doc, sel, options) {
+ if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
+ { sel = filterSelectionChange(doc, sel, options) }
- if (!(options && options.scroll === false) && doc.cm)
- ensureCursorVisible(doc.cm);
- }
+ var bias = options && options.bias ||
+ (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1)
+ setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true))
- function setSelectionInner(doc, sel) {
- if (sel.equals(doc.sel)) return;
+ if (!(options && options.scroll === false) && doc.cm)
+ { ensureCursorVisible(doc.cm) }
+}
- doc.sel = sel;
+function setSelectionInner(doc, sel) {
+ if (sel.equals(doc.sel)) { return }
- if (doc.cm) {
- doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
- signalCursorActivity(doc.cm);
- }
- signalLater(doc, "cursorActivity", doc);
- }
+ doc.sel = sel
- // Verify that the selection does not partially select any atomic
- // marked ranges.
- function reCheckSelection(doc) {
- setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll);
+ if (doc.cm) {
+ doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true
+ signalCursorActivity(doc.cm)
}
+ signalLater(doc, "cursorActivity", doc)
+}
- // Return a selection that does not partially select any atomic
- // ranges.
- function skipAtomicInSelection(doc, sel, bias, mayClear) {
- var out;
- for (var i = 0; i < sel.ranges.length; i++) {
- var range = sel.ranges[i];
- var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
- var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
- var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
- if (out || newAnchor != range.anchor || newHead != range.head) {
- if (!out) out = sel.ranges.slice(0, i);
- out[i] = new Range(newAnchor, newHead);
- }
- }
- return out ? normalizeSelection(out, sel.primIndex) : sel;
- }
-
- function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
- var line = getLine(doc, pos.line);
- if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
- var sp = line.markedSpans[i], m = sp.marker;
- if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
- (sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
- if (mayClear) {
- signal(m, "beforeCursorEnter");
- if (m.explicitlyCleared) {
- if (!line.markedSpans) break;
- else {--i; continue;}
- }
- }
- if (!m.atomic) continue;
-
- if (oldPos) {
- var near = m.find(dir < 0 ? 1 : -1), diff;
- if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
- near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null);
- if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
- return skipAtomicInner(doc, near, pos, dir, mayClear);
- }
+// Verify that the selection does not partially select any atomic
+// marked ranges.
+function reCheckSelection(doc) {
+ setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll)
+}
- var far = m.find(dir < 0 ? -1 : 1);
- if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
- far = movePos(doc, far, dir, far.line == pos.line ? line : null);
- return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null;
- }
+// Return a selection that does not partially select any atomic
+// ranges.
+function skipAtomicInSelection(doc, sel, bias, mayClear) {
+ var out
+ for (var i = 0; i < sel.ranges.length; i++) {
+ var range = sel.ranges[i]
+ var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i]
+ var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear)
+ var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear)
+ if (out || newAnchor != range.anchor || newHead != range.head) {
+ if (!out) { out = sel.ranges.slice(0, i) }
+ out[i] = new Range(newAnchor, newHead)
}
- return pos;
}
+ return out ? normalizeSelection(out, sel.primIndex) : sel
+}
- // Ensure a given position is not inside an atomic range.
- function skipAtomic(doc, pos, oldPos, bias, mayClear) {
- var dir = bias || 1;
- var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
- (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
- skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
- (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));
- if (!found) {
- doc.cantEdit = true;
- return Pos(doc.first, 0);
- }
- return found;
- }
+function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
+ var line = getLine(doc, pos.line)
+ if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
+ var sp = line.markedSpans[i], m = sp.marker
+ if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
+ (sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
+ if (mayClear) {
+ signal(m, "beforeCursorEnter")
+ if (m.explicitlyCleared) {
+ if (!line.markedSpans) { break }
+ else {--i; continue}
+ }
+ }
+ if (!m.atomic) { continue }
- function movePos(doc, pos, dir, line) {
- if (dir < 0 && pos.ch == 0) {
- if (pos.line > doc.first) return clipPos(doc, Pos(pos.line - 1));
- else return null;
- } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
- if (pos.line < doc.first + doc.size - 1) return Pos(pos.line + 1, 0);
- else return null;
- } else {
- return new Pos(pos.line, pos.ch + dir);
- }
- }
+ if (oldPos) {
+ var near = m.find(dir < 0 ? 1 : -1), diff = (void 0)
+ if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
+ { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null) }
+ if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
+ { return skipAtomicInner(doc, near, pos, dir, mayClear) }
+ }
- // SELECTION DRAWING
+ var far = m.find(dir < 0 ? -1 : 1)
+ if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
+ { far = movePos(doc, far, dir, far.line == pos.line ? line : null) }
+ return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null
+ }
+ } }
+ return pos
+}
- function updateSelection(cm) {
- cm.display.input.showSelection(cm.display.input.prepareSelection());
+// Ensure a given position is not inside an atomic range.
+function skipAtomic(doc, pos, oldPos, bias, mayClear) {
+ var dir = bias || 1
+ var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
+ (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
+ skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
+ (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true))
+ if (!found) {
+ doc.cantEdit = true
+ return Pos(doc.first, 0)
}
+ return found
+}
- function prepareSelection(cm, primary) {
- var doc = cm.doc, result = {};
- var curFragment = result.cursors = document.createDocumentFragment();
- var selFragment = result.selection = document.createDocumentFragment();
-
- for (var i = 0; i < doc.sel.ranges.length; i++) {
- if (primary === false && i == doc.sel.primIndex) continue;
- var range = doc.sel.ranges[i];
- if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) continue;
- var collapsed = range.empty();
- if (collapsed || cm.options.showCursorWhenSelecting)
- drawSelectionCursor(cm, range.head, curFragment);
- if (!collapsed)
- drawSelectionRange(cm, range, selFragment);
- }
- return result;
+function movePos(doc, pos, dir, line) {
+ if (dir < 0 && pos.ch == 0) {
+ if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) }
+ else { return null }
+ } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
+ if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) }
+ else { return null }
+ } else {
+ return new Pos(pos.line, pos.ch + dir)
}
+}
- // Draws a cursor for the given range
- function drawSelectionCursor(cm, head, output) {
- var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
+function selectAll(cm) {
+ cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll)
+}
- var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
- cursor.style.left = pos.left + "px";
- cursor.style.top = pos.top + "px";
- cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
+// UPDATING
- if (pos.other) {
- // Secondary cursor, shown when on a 'jump' in bi-directional text
- var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
- otherCursor.style.display = "";
- otherCursor.style.left = pos.other.left + "px";
- otherCursor.style.top = pos.other.top + "px";
- otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
- }
+// Allow "beforeChange" event handlers to influence a change
+function filterChange(doc, change, update) {
+ var obj = {
+ canceled: false,
+ from: change.from,
+ to: change.to,
+ text: change.text,
+ origin: change.origin,
+ cancel: function () { return obj.canceled = true; }
}
+ if (update) { obj.update = function (from, to, text, origin) {
+ if (from) { obj.from = clipPos(doc, from) }
+ if (to) { obj.to = clipPos(doc, to) }
+ if (text) { obj.text = text }
+ if (origin !== undefined) { obj.origin = origin }
+ } }
+ signal(doc, "beforeChange", doc, obj)
+ if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj) }
- // Draws the given range as a highlighted selection
- function drawSelectionRange(cm, range, output) {
- var display = cm.display, doc = cm.doc;
- var fragment = document.createDocumentFragment();
- var padding = paddingH(cm.display), leftSide = padding.left;
- var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
-
- function add(left, top, width, bottom) {
- if (top < 0) top = 0;
- top = Math.round(top);
- bottom = Math.round(bottom);
- fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left +
- "px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) +
- "px; height: " + (bottom - top) + "px"));
- }
-
- function drawForLine(line, fromArg, toArg) {
- var lineObj = getLine(doc, line);
- var lineLen = lineObj.text.length;
- var start, end;
- function coords(ch, bias) {
- return charCoords(cm, Pos(line, ch), "div", lineObj, bias);
- }
-
- iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) {
- var leftPos = coords(from, "left"), rightPos, left, right;
- if (from == to) {
- rightPos = leftPos;
- left = right = leftPos.left;
- } else {
- rightPos = coords(to - 1, "right");
- if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; }
- left = leftPos.left;
- right = rightPos.right;
- }
- if (fromArg == null && from == 0) left = leftSide;
- if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
- add(left, leftPos.top, null, leftPos.bottom);
- left = leftSide;
- if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top);
- }
- if (toArg == null && to == lineLen) right = rightSide;
- if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
- start = leftPos;
- if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
- end = rightPos;
- if (left < leftSide + 1) left = leftSide;
- add(left, rightPos.top, right - left, rightPos.bottom);
- });
- return {start: start, end: end};
- }
+ if (obj.canceled) { return null }
+ return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}
+}
- var sFrom = range.from(), sTo = range.to();
- if (sFrom.line == sTo.line) {
- drawForLine(sFrom.line, sFrom.ch, sTo.ch);
- } else {
- var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
- var singleVLine = visualLine(fromLine) == visualLine(toLine);
- var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
- var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
- if (singleVLine) {
- if (leftEnd.top < rightStart.top - 2) {
- add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
- add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
- } else {
- add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
- }
- }
- if (leftEnd.bottom < rightStart.top)
- add(leftSide, leftEnd.bottom, null, rightStart.top);
- }
-
- output.appendChild(fragment);
- }
-
- // Cursor-blinking
- function restartBlink(cm) {
- if (!cm.state.focused) return;
- var display = cm.display;
- clearInterval(display.blinker);
- var on = true;
- display.cursorDiv.style.visibility = "";
- if (cm.options.cursorBlinkRate > 0)
- display.blinker = setInterval(function() {
- display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden";
- }, cm.options.cursorBlinkRate);
- else if (cm.options.cursorBlinkRate < 0)
- display.cursorDiv.style.visibility = "hidden";
- }
-
- // HIGHLIGHT WORKER
-
- function startWorker(cm, time) {
- if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
- cm.state.highlight.set(time, bind(highlightWorker, cm));
- }
-
- function highlightWorker(cm) {
- var doc = cm.doc;
- if (doc.frontier < doc.first) doc.frontier = doc.first;
- if (doc.frontier >= cm.display.viewTo) return;
- var end = +new Date + cm.options.workTime;
- var state = copyState(doc.mode, getStateBefore(cm, doc.frontier));
- var changedLines = [];
-
- doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) {
- if (doc.frontier >= cm.display.viewFrom) { // Visible
- var oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength;
- var highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true);
- line.styles = highlighted.styles;
- var oldCls = line.styleClasses, newCls = highlighted.classes;
- if (newCls) line.styleClasses = newCls;
- else if (oldCls) line.styleClasses = null;
- var ischange = !oldStyles || oldStyles.length != line.styles.length ||
- oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
- for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i];
- if (ischange) changedLines.push(doc.frontier);
- line.stateAfter = tooLong ? state : copyState(doc.mode, state);
- } else {
- if (line.text.length <= cm.options.maxHighlightLength)
- processLine(cm, line.text, state);
- line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null;
- }
- ++doc.frontier;
- if (+new Date > end) {
- startWorker(cm, cm.options.workDelay);
- return true;
- }
- });
- if (changedLines.length) runInOp(cm, function() {
- for (var i = 0; i < changedLines.length; i++)
- regLineChange(cm, changedLines[i], "text");
- });
+// Apply a change to a document, and add it to the document's
+// history, and propagating it to all linked documents.
+function makeChange(doc, change, ignoreReadOnly) {
+ if (doc.cm) {
+ if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) }
+ if (doc.cm.state.suppressEdits) { return }
}
- // Finds the line to start with when starting a parse. Tries to
- // find a line with a stateAfter, so that it can start with a
- // valid state. If that fails, it returns the line with the
- // smallest indentation, which tends to need the least context to
- // parse correctly.
- function findStartLine(cm, n, precise) {
- var minindent, minline, doc = cm.doc;
- var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
- for (var search = n; search > lim; --search) {
- if (search <= doc.first) return doc.first;
- var line = getLine(doc, search - 1);
- if (line.stateAfter && (!precise || search <= doc.frontier)) return search;
- var indented = countColumn(line.text, null, cm.options.tabSize);
- if (minline == null || minindent > indented) {
- minline = search - 1;
- minindent = indented;
- }
- }
- return minline;
- }
-
- function getStateBefore(cm, n, precise) {
- var doc = cm.doc, display = cm.display;
- if (!doc.mode.startState) return true;
- var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter;
- if (!state) state = startState(doc.mode);
- else state = copyState(doc.mode, state);
- doc.iter(pos, n, function(line) {
- processLine(cm, line.text, state);
- var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo;
- line.stateAfter = save ? copyState(doc.mode, state) : null;
- ++pos;
- });
- if (precise) doc.frontier = pos;
- return state;
+ if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
+ change = filterChange(doc, change, true)
+ if (!change) { return }
}
- // POSITION MEASUREMENT
-
- function paddingTop(display) {return display.lineSpace.offsetTop;}
- function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;}
- function paddingH(display) {
- if (display.cachedPaddingH) return display.cachedPaddingH;
- var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
- var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
- var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
- if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data;
- return data;
- }
-
- function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; }
- function displayWidth(cm) {
- return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth;
- }
- function displayHeight(cm) {
- return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight;
- }
-
- // Ensure the lineView.wrapping.heights array is populated. This is
- // an array of bottom offsets for the lines that make up a drawn
- // line. When lineWrapping is on, there might be more than one
- // height.
- function ensureLineHeights(cm, lineView, rect) {
- var wrapping = cm.options.lineWrapping;
- var curWidth = wrapping && displayWidth(cm);
- if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
- var heights = lineView.measure.heights = [];
- if (wrapping) {
- lineView.measure.width = curWidth;
- var rects = lineView.text.firstChild.getClientRects();
- for (var i = 0; i < rects.length - 1; i++) {
- var cur = rects[i], next = rects[i + 1];
- if (Math.abs(cur.bottom - next.bottom) > 2)
- heights.push((cur.bottom + next.top) / 2 - rect.top);
- }
- }
- heights.push(rect.bottom - rect.top);
- }
- }
-
- // Find a line map (mapping character offsets to text nodes) and a
- // measurement cache for the given line number. (A line view might
- // contain multiple lines when collapsed ranges are present.)
- function mapFromLineView(lineView, line, lineN) {
- if (lineView.line == line)
- return {map: lineView.measure.map, cache: lineView.measure.cache};
- for (var i = 0; i < lineView.rest.length; i++)
- if (lineView.rest[i] == line)
- return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]};
- for (var i = 0; i < lineView.rest.length; i++)
- if (lineNo(lineView.rest[i]) > lineN)
- return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true};
- }
-
- // Render a line into the hidden node display.externalMeasured. Used
- // when measurement is needed for a line that's not in the viewport.
- function updateExternalMeasurement(cm, line) {
- line = visualLine(line);
- var lineN = lineNo(line);
- var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
- view.lineN = lineN;
- var built = view.built = buildLineContent(cm, view);
- view.text = built.pre;
- removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
- return view;
- }
-
- // Get a {top, bottom, left, right} box (in line-local coordinates)
- // for a given character.
- function measureChar(cm, line, ch, bias) {
- return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias);
- }
-
- // Find a line view that corresponds to the given line number.
- function findViewForLine(cm, lineN) {
- if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
- return cm.display.view[findViewIndex(cm, lineN)];
- var ext = cm.display.externalMeasured;
- if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
- return ext;
- }
-
- // Measurement can be split in two steps, the set-up work that
- // applies to the whole line, and the measurement of the actual
- // character. Functions like coordsChar, that need to do a lot of
- // measurements in a row, can thus ensure that the set-up work is
- // only done once.
- function prepareMeasureForLine(cm, line) {
- var lineN = lineNo(line);
- var view = findViewForLine(cm, lineN);
- if (view && !view.text) {
- view = null;
- } else if (view && view.changes) {
- updateLineForChanges(cm, view, lineN, getDimensions(cm));
- cm.curOp.forceUpdate = true;
- }
- if (!view)
- view = updateExternalMeasurement(cm, line);
-
- var info = mapFromLineView(view, line, lineN);
- return {
- line: line, view: view, rect: null,
- map: info.map, cache: info.cache, before: info.before,
- hasHeights: false
- };
+ // Possibly split or suppress the update based on the presence
+ // of read-only spans in its range.
+ var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to)
+ if (split) {
+ for (var i = split.length - 1; i >= 0; --i)
+ { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text}) }
+ } else {
+ makeChangeInner(doc, change)
}
+}
- // Given a prepared measurement object, measures the position of an
- // actual character (or fetches it from the cache).
- function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
- if (prepared.before) ch = -1;
- var key = ch + (bias || ""), found;
- if (prepared.cache.hasOwnProperty(key)) {
- found = prepared.cache[key];
- } else {
- if (!prepared.rect)
- prepared.rect = prepared.view.text.getBoundingClientRect();
- if (!prepared.hasHeights) {
- ensureLineHeights(cm, prepared.view, prepared.rect);
- prepared.hasHeights = true;
- }
- found = measureCharInner(cm, prepared, ch, bias);
- if (!found.bogus) prepared.cache[key] = found;
- }
- return {left: found.left, right: found.right,
- top: varHeight ? found.rtop : found.top,
- bottom: varHeight ? found.rbottom : found.bottom};
- }
-
- var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
-
- function nodeAndOffsetInLineMap(map, ch, bias) {
- var node, start, end, collapse;
- // First, search the line map for the text node corresponding to,
- // or closest to, the target character.
- for (var i = 0; i < map.length; i += 3) {
- var mStart = map[i], mEnd = map[i + 1];
- if (ch < mStart) {
- start = 0; end = 1;
- collapse = "left";
- } else if (ch < mEnd) {
- start = ch - mStart;
- end = start + 1;
- } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
- end = mEnd - mStart;
- start = end - 1;
- if (ch >= mEnd) collapse = "right";
- }
- if (start != null) {
- node = map[i + 2];
- if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
- collapse = bias;
- if (bias == "left" && start == 0)
- while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
- node = map[(i -= 3) + 2];
- collapse = "left";
- }
- if (bias == "right" && start == mEnd - mStart)
- while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
- node = map[(i += 3) + 2];
- collapse = "right";
- }
- break;
- }
- }
- return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd};
- }
+function makeChangeInner(doc, change) {
+ if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return }
+ var selAfter = computeSelAfterChange(doc, change)
+ addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN)
- function measureCharInner(cm, prepared, ch, bias) {
- var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
- var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
+ makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change))
+ var rebased = []
- var rect;
- if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
- for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned
- while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start;
- while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end;
- if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) {
- rect = node.parentNode.getBoundingClientRect();
- } else if (ie && cm.options.lineWrapping) {
- var rects = range(node, start, end).getClientRects();
- if (rects.length)
- rect = rects[bias == "right" ? rects.length - 1 : 0];
- else
- rect = nullRect;
- } else {
- rect = range(node, start, end).getBoundingClientRect() || nullRect;
- }
- if (rect.left || rect.right || start == 0) break;
- end = start;
- start = start - 1;
- collapse = "right";
- }
- if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect);
- } else { // If it is a widget, simply get the box for the whole widget.
- if (start > 0) collapse = bias = "right";
- var rects;
- if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
- rect = rects[bias == "right" ? rects.length - 1 : 0];
- else
- rect = node.getBoundingClientRect();
- }
- if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
- var rSpan = node.parentNode.getClientRects()[0];
- if (rSpan)
- rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom};
- else
- rect = nullRect;
+ linkedDocs(doc, function (doc, sharedHist) {
+ if (!sharedHist && indexOf(rebased, doc.history) == -1) {
+ rebaseHist(doc.history, change)
+ rebased.push(doc.history)
}
+ makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change))
+ })
+}
- var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
- var mid = (rtop + rbot) / 2;
- var heights = prepared.view.measure.heights;
- for (var i = 0; i < heights.length - 1; i++)
- if (mid < heights[i]) break;
- var top = i ? heights[i - 1] : 0, bot = heights[i];
- var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
- right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
- top: top, bottom: bot};
- if (!rect.left && !rect.right) result.bogus = true;
- if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
+// Revert a change stored in a document's history.
+function makeChangeFromHistory(doc, type, allowSelectionOnly) {
+ if (doc.cm && doc.cm.state.suppressEdits && !allowSelectionOnly) { return }
- return result;
- }
+ var hist = doc.history, event, selAfter = doc.sel
+ var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done
- // Work around problem with bounding client rects on ranges being
- // returned incorrectly when zoomed on IE10 and below.
- function maybeUpdateRectForZooming(measure, rect) {
- if (!window.screen || screen.logicalXDPI == null ||
- screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
- return rect;
- var scaleX = screen.logicalXDPI / screen.deviceXDPI;
- var scaleY = screen.logicalYDPI / screen.deviceYDPI;
- return {left: rect.left * scaleX, right: rect.right * scaleX,
- top: rect.top * scaleY, bottom: rect.bottom * scaleY};
- }
-
- function clearLineMeasurementCacheFor(lineView) {
- if (lineView.measure) {
- lineView.measure.cache = {};
- lineView.measure.heights = null;
- if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++)
- lineView.measure.caches[i] = {};
- }
- }
-
- function clearLineMeasurementCache(cm) {
- cm.display.externalMeasure = null;
- removeChildren(cm.display.lineMeasure);
- for (var i = 0; i < cm.display.view.length; i++)
- clearLineMeasurementCacheFor(cm.display.view[i]);
- }
-
- function clearCaches(cm) {
- clearLineMeasurementCache(cm);
- cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
- if (!cm.options.lineWrapping) cm.display.maxLineChanged = true;
- cm.display.lineNumChars = null;
- }
-
- function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; }
- function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; }
-
- // Converts a {top, bottom, left, right} box from line-local
- // coordinates into another coordinate system. Context may be one of
- // "line", "div" (display.lineDiv), "local"/null (editor), "window",
- // or "page".
- function intoCoordSystem(cm, lineObj, rect, context) {
- if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) {
- var size = widgetHeight(lineObj.widgets[i]);
- rect.top += size; rect.bottom += size;
- }
- if (context == "line") return rect;
- if (!context) context = "local";
- var yOff = heightAtLine(lineObj);
- if (context == "local") yOff += paddingTop(cm.display);
- else yOff -= cm.display.viewOffset;
- if (context == "page" || context == "window") {
- var lOff = cm.display.lineSpace.getBoundingClientRect();
- yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
- var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
- rect.left += xOff; rect.right += xOff;
- }
- rect.top += yOff; rect.bottom += yOff;
- return rect;
- }
-
- // Coverts a box from "div" coords to another coordinate system.
- // Context may be "window", "page", "div", or "local"/null.
- function fromCoordSystem(cm, coords, context) {
- if (context == "div") return coords;
- var left = coords.left, top = coords.top;
- // First move into "page" coordinate system
- if (context == "page") {
- left -= pageScrollX();
- top -= pageScrollY();
- } else if (context == "local" || !context) {
- var localBox = cm.display.sizer.getBoundingClientRect();
- left += localBox.left;
- top += localBox.top;
- }
-
- var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
- return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top};
- }
-
- function charCoords(cm, pos, context, lineObj, bias) {
- if (!lineObj) lineObj = getLine(cm.doc, pos.line);
- return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context);
- }
-
- // Returns a box for a given cursor position, which may have an
- // 'other' property containing the position of the secondary cursor
- // on a bidi boundary.
- function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
- lineObj = lineObj || getLine(cm.doc, pos.line);
- if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj);
- function get(ch, right) {
- var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
- if (right) m.left = m.right; else m.right = m.left;
- return intoCoordSystem(cm, lineObj, m, context);
- }
- function getBidi(ch, partPos) {
- var part = order[partPos], right = part.level % 2;
- if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
- part = order[--partPos];
- ch = bidiRight(part) - (part.level % 2 ? 0 : 1);
- right = true;
- } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
- part = order[++partPos];
- ch = bidiLeft(part) - part.level % 2;
- right = false;
- }
- if (right && ch == part.to && ch > part.from) return get(ch - 1);
- return get(ch, right);
- }
- var order = getOrder(lineObj), ch = pos.ch;
- if (!order) return get(ch);
- var partPos = getBidiPartAt(order, ch);
- var val = getBidi(ch, partPos);
- if (bidiOther != null) val.other = getBidi(ch, bidiOther);
- return val;
+ // Verify that there is a useable event (so that ctrl-z won't
+ // needlessly clear selection events)
+ var i = 0
+ for (; i < source.length; i++) {
+ event = source[i]
+ if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
+ { break }
}
+ if (i == source.length) { return }
+ hist.lastOrigin = hist.lastSelOrigin = null
- // Used to cheaply estimate the coordinates for a position. Used for
- // intermediate scroll updates.
- function estimateCoords(cm, pos) {
- var left = 0, pos = clipPos(cm.doc, pos);
- if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch;
- var lineObj = getLine(cm.doc, pos.line);
- var top = heightAtLine(lineObj) + paddingTop(cm.display);
- return {left: left, right: left, top: top, bottom: top + lineObj.height};
- }
-
- // Positions returned by coordsChar contain some extra information.
- // xRel is the relative x position of the input coordinates compared
- // to the found position (so xRel > 0 means the coordinates are to
- // the right of the character position, for example). When outside
- // is true, that means the coordinates lie outside the line's
- // vertical range.
- function PosWithInfo(line, ch, outside, xRel) {
- var pos = Pos(line, ch);
- pos.xRel = xRel;
- if (outside) pos.outside = true;
- return pos;
- }
-
- // Compute the character position closest to the given coordinates.
- // Input must be lineSpace-local ("div" coordinate system).
- function coordsChar(cm, x, y) {
- var doc = cm.doc;
- y += cm.display.viewOffset;
- if (y < 0) return PosWithInfo(doc.first, 0, true, -1);
- var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
- if (lineN > last)
- return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1);
- if (x < 0) x = 0;
-
- var lineObj = getLine(doc, lineN);
- for (;;) {
- var found = coordsCharInner(cm, lineObj, lineN, x, y);
- var merged = collapsedSpanAtEnd(lineObj);
- var mergedPos = merged && merged.find(0, true);
- if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
- lineN = lineNo(lineObj = mergedPos.to.line);
- else
- return found;
+ for (;;) {
+ event = source.pop()
+ if (event.ranges) {
+ pushSelectionToHistory(event, dest)
+ if (allowSelectionOnly && !event.equals(doc.sel)) {
+ setSelection(doc, event, {clearRedo: false})
+ return
+ }
+ selAfter = event
}
+ else { break }
}
- function coordsCharInner(cm, lineObj, lineNo, x, y) {
- var innerOff = y - heightAtLine(lineObj);
- var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth;
- var preparedMeasure = prepareMeasureForLine(cm, lineObj);
+ // Build up a reverse change object to add to the opposite history
+ // stack (redo when undoing, and vice versa).
+ var antiChanges = []
+ pushSelectionToHistory(selAfter, dest)
+ dest.push({changes: antiChanges, generation: hist.generation})
+ hist.generation = event.generation || ++hist.maxGeneration
+
+ var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")
- function getX(ch) {
- var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure);
- wrongLine = true;
- if (innerOff > sp.bottom) return sp.left - adjust;
- else if (innerOff < sp.top) return sp.left + adjust;
- else wrongLine = false;
- return sp.left;
+ var loop = function ( i ) {
+ var change = event.changes[i]
+ change.origin = type
+ if (filter && !filterChange(doc, change, false)) {
+ source.length = 0
+ return {}
}
- var bidi = getOrder(lineObj), dist = lineObj.text.length;
- var from = lineLeft(lineObj), to = lineRight(lineObj);
- var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine;
+ antiChanges.push(historyChangeFromChange(doc, change))
- if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1);
- // Do a binary search between these bounds.
- for (;;) {
- if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
- var ch = x < fromX || x - fromX <= toX - x ? from : to;
- var outside = ch == from ? fromOutside : toOutside
- var xDiff = x - (ch == from ? fromX : toX);
- // This is a kludge to handle the case where the coordinates
- // are after a line-wrapped line. We should replace it with a
- // more general handling of cursor positions around line
- // breaks. (Issue #4078)
- if (toOutside && !bidi && !/\s/.test(lineObj.text.charAt(ch)) && xDiff > 0 &&
- ch < lineObj.text.length && preparedMeasure.view.measure.heights.length > 1) {
- var charSize = measureCharPrepared(cm, preparedMeasure, ch, "right");
- if (innerOff <= charSize.bottom && innerOff >= charSize.top && Math.abs(x - charSize.right) < xDiff) {
- outside = false
- ch++
- xDiff = x - charSize.right
- }
- }
- while (isExtendingChar(lineObj.text.charAt(ch))) ++ch;
- var pos = PosWithInfo(lineNo, ch, outside, xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0);
- return pos;
- }
- var step = Math.ceil(dist / 2), middle = from + step;
- if (bidi) {
- middle = from;
- for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1);
- }
- var middleX = getX(middle);
- if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;}
- else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;}
- }
- }
-
- var measureText;
- // Compute the default text height.
- function textHeight(display) {
- if (display.cachedTextHeight != null) return display.cachedTextHeight;
- if (measureText == null) {
- measureText = elt("pre");
- // Measure a bunch of lines, for browsers that compute
- // fractional heights.
- for (var i = 0; i < 49; ++i) {
- measureText.appendChild(document.createTextNode("x"));
- measureText.appendChild(elt("br"));
- }
- measureText.appendChild(document.createTextNode("x"));
- }
- removeChildrenAndAdd(display.measure, measureText);
- var height = measureText.offsetHeight / 50;
- if (height > 3) display.cachedTextHeight = height;
- removeChildren(display.measure);
- return height || 1;
- }
-
- // Compute the default character width.
- function charWidth(display) {
- if (display.cachedCharWidth != null) return display.cachedCharWidth;
- var anchor = elt("span", "xxxxxxxxxx");
- var pre = elt("pre", [anchor]);
- removeChildrenAndAdd(display.measure, pre);
- var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
- if (width > 2) display.cachedCharWidth = width;
- return width || 10;
- }
-
- // OPERATIONS
-
- // Operations are used to wrap a series of changes to the editor
- // state in such a way that each change won't have to update the
- // cursor and display (which would be awkward, slow, and
- // error-prone). Instead, display updates are batched and then all
- // combined and executed at once.
-
- var operationGroup = null;
-
- var nextOpId = 0;
- // Start a new operation.
- function startOperation(cm) {
- cm.curOp = {
- cm: cm,
- viewChanged: false, // Flag that indicates that lines might need to be redrawn
- startHeight: cm.doc.height, // Used to detect need to update scrollbar
- forceUpdate: false, // Used to force a redraw
- updateInput: null, // Whether to reset the input textarea
- typing: false, // Whether this reset should be careful to leave existing text (for compositing)
- changeObjs: null, // Accumulated changes, for firing change events
- cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
- cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
- selectionChanged: false, // Whether the selection needs to be redrawn
- updateMaxLine: false, // Set when the widest line needs to be determined anew
- scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
- scrollToPos: null, // Used to scroll to a specific position
- focus: false,
- id: ++nextOpId // Unique ID
- };
- if (operationGroup) {
- operationGroup.ops.push(cm.curOp);
- } else {
- cm.curOp.ownsGroup = operationGroup = {
- ops: [cm.curOp],
- delayedCallbacks: []
- };
- }
- }
+ var after = i ? computeSelAfterChange(doc, change) : lst(source)
+ makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change))
+ if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}) }
+ var rebased = []
- function fireCallbacksForOps(group) {
- // Calls delayed callbacks and cursorActivity handlers until no
- // new ones appear
- var callbacks = group.delayedCallbacks, i = 0;
- do {
- for (; i < callbacks.length; i++)
- callbacks[i].call(null);
- for (var j = 0; j < group.ops.length; j++) {
- var op = group.ops[j];
- if (op.cursorActivityHandlers)
- while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
- op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm);
+ // Propagate to the linked documents
+ linkedDocs(doc, function (doc, sharedHist) {
+ if (!sharedHist && indexOf(rebased, doc.history) == -1) {
+ rebaseHist(doc.history, change)
+ rebased.push(doc.history)
}
- } while (i < callbacks.length);
- }
+ makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change))
+ })
+ };
- // Finish an operation, updating the display and signalling delayed events
- function endOperation(cm) {
- var op = cm.curOp, group = op.ownsGroup;
- if (!group) return;
+ for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) {
+ var returned = loop( i$1 );
- try { fireCallbacksForOps(group); }
- finally {
- operationGroup = null;
- for (var i = 0; i < group.ops.length; i++)
- group.ops[i].cm.curOp = null;
- endOperations(group);
- }
+ if ( returned ) return returned.v;
}
+}
- // The DOM updates done when an operation finishes are batched so
- // that the minimum number of relayouts are required.
- function endOperations(group) {
- var ops = group.ops;
- for (var i = 0; i < ops.length; i++) // Read DOM
- endOperation_R1(ops[i]);
- for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
- endOperation_W1(ops[i]);
- for (var i = 0; i < ops.length; i++) // Read DOM
- endOperation_R2(ops[i]);
- for (var i = 0; i < ops.length; i++) // Write DOM (maybe)
- endOperation_W2(ops[i]);
- for (var i = 0; i < ops.length; i++) // Read DOM
- endOperation_finish(ops[i]);
+// Sub-views need their line numbers shifted when text is added
+// above or below them in the parent document.
+function shiftDoc(doc, distance) {
+ if (distance == 0) { return }
+ doc.first += distance
+ doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range(
+ Pos(range.anchor.line + distance, range.anchor.ch),
+ Pos(range.head.line + distance, range.head.ch)
+ ); }), doc.sel.primIndex)
+ if (doc.cm) {
+ regChange(doc.cm, doc.first, doc.first - distance, distance)
+ for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
+ { regLineChange(doc.cm, l, "gutter") }
}
+}
- function endOperation_R1(op) {
- var cm = op.cm, display = cm.display;
- maybeClipScrollbars(cm);
- if (op.updateMaxLine) findMaxLine(cm);
+// More lower-level change function, handling only a single document
+// (not linked ones).
+function makeChangeSingleDoc(doc, change, selAfter, spans) {
+ if (doc.cm && !doc.cm.curOp)
+ { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) }
- op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
- op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
- op.scrollToPos.to.line >= display.viewTo) ||
- display.maxLineChanged && cm.options.lineWrapping;
- op.update = op.mustUpdate &&
- new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
+ if (change.to.line < doc.first) {
+ shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line))
+ return
}
+ if (change.from.line > doc.lastLine()) { return }
- function endOperation_W1(op) {
- op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
+ // Clip the change to the size of this doc
+ if (change.from.line < doc.first) {
+ var shift = change.text.length - 1 - (doc.first - change.from.line)
+ shiftDoc(doc, shift)
+ change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
+ text: [lst(change.text)], origin: change.origin}
+ }
+ var last = doc.lastLine()
+ if (change.to.line > last) {
+ change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
+ text: [change.text[0]], origin: change.origin}
}
- function endOperation_R2(op) {
- var cm = op.cm, display = cm.display;
- if (op.updatedDisplay) updateHeightsInViewport(cm);
-
- op.barMeasure = measureForScrollbars(cm);
-
- // If the max line changed since it was last measured, measure it,
- // and ensure the document's width matches it.
- // updateDisplay_W2 will use these properties to do the actual resizing
- if (display.maxLineChanged && !cm.options.lineWrapping) {
- op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
- cm.display.sizerWidth = op.adjustWidthTo;
- op.barMeasure.scrollWidth =
- Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
- op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
- }
-
- if (op.updatedDisplay || op.selectionChanged)
- op.preparedSelection = display.input.prepareSelection(op.focus);
- }
-
- function endOperation_W2(op) {
- var cm = op.cm;
-
- if (op.adjustWidthTo != null) {
- cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
- if (op.maxScrollLeft < cm.doc.scrollLeft)
- setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true);
- cm.display.maxLineChanged = false;
- }
-
- var takeFocus = op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus())
- if (op.preparedSelection)
- cm.display.input.showSelection(op.preparedSelection, takeFocus);
- if (op.updatedDisplay || op.startHeight != cm.doc.height)
- updateScrollbars(cm, op.barMeasure);
- if (op.updatedDisplay)
- setDocumentHeight(cm, op.barMeasure);
-
- if (op.selectionChanged) restartBlink(cm);
-
- if (cm.state.focused && op.updateInput)
- cm.display.input.reset(op.typing);
- if (takeFocus) ensureFocus(op.cm);
- }
-
- function endOperation_finish(op) {
- var cm = op.cm, display = cm.display, doc = cm.doc;
+ change.removed = getBetween(doc, change.from, change.to)
- if (op.updatedDisplay) postUpdateDisplay(cm, op.update);
-
- // Abort mouse wheel delta measurement, when scrolling explicitly
- if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
- display.wheelStartX = display.wheelStartY = null;
-
- // Propagate the scroll position to the actual DOM scroller
- if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) {
- doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop));
- display.scrollbars.setScrollTop(doc.scrollTop);
- display.scroller.scrollTop = doc.scrollTop;
- }
- if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
- doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft));
- display.scrollbars.setScrollLeft(doc.scrollLeft);
- display.scroller.scrollLeft = doc.scrollLeft;
- alignHorizontally(cm);
- }
- // If we need to scroll a specific position into view, do so.
- if (op.scrollToPos) {
- var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
- clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
- if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords);
- }
-
- // Fire events for markers that are hidden/unidden by editing or
- // undoing
- var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
- if (hidden) for (var i = 0; i < hidden.length; ++i)
- if (!hidden[i].lines.length) signal(hidden[i], "hide");
- if (unhidden) for (var i = 0; i < unhidden.length; ++i)
- if (unhidden[i].lines.length) signal(unhidden[i], "unhide");
+ if (!selAfter) { selAfter = computeSelAfterChange(doc, change) }
+ if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans) }
+ else { updateDoc(doc, change, spans) }
+ setSelectionNoUndo(doc, selAfter, sel_dontScroll)
+}
- if (display.wrapper.offsetHeight)
- doc.scrollTop = cm.display.scroller.scrollTop;
+// Handle the interaction of a change to a document with the editor
+// that this document is part of.
+function makeChangeSingleDocInEditor(cm, change, spans) {
+ var doc = cm.doc, display = cm.display, from = change.from, to = change.to
- // Fire change events, and delayed event handlers
- if (op.changeObjs)
- signal(cm, "changes", cm, op.changeObjs);
- if (op.update)
- op.update.finish();
+ var recomputeMaxLength = false, checkWidthStart = from.line
+ if (!cm.options.lineWrapping) {
+ checkWidthStart = lineNo(visualLine(getLine(doc, from.line)))
+ doc.iter(checkWidthStart, to.line + 1, function (line) {
+ if (line == display.maxLine) {
+ recomputeMaxLength = true
+ return true
+ }
+ })
}
- // Run the given function in an operation
- function runInOp(cm, f) {
- if (cm.curOp) return f();
- startOperation(cm);
- try { return f(); }
- finally { endOperation(cm); }
- }
- // Wraps a function in an operation. Returns the wrapped function.
- function operation(cm, f) {
- return function() {
- if (cm.curOp) return f.apply(cm, arguments);
- startOperation(cm);
- try { return f.apply(cm, arguments); }
- finally { endOperation(cm); }
- };
- }
- // Used to add methods to editor and doc instances, wrapping them in
- // operations.
- function methodOp(f) {
- return function() {
- if (this.curOp) return f.apply(this, arguments);
- startOperation(this);
- try { return f.apply(this, arguments); }
- finally { endOperation(this); }
- };
- }
- function docMethodOp(f) {
- return function() {
- var cm = this.cm;
- if (!cm || cm.curOp) return f.apply(this, arguments);
- startOperation(cm);
- try { return f.apply(this, arguments); }
- finally { endOperation(cm); }
- };
- }
+ if (doc.sel.contains(change.from, change.to) > -1)
+ { signalCursorActivity(cm) }
- // VIEW TRACKING
+ updateDoc(doc, change, spans, estimateHeight(cm))
- // These objects are used to represent the visible (currently drawn)
- // part of the document. A LineView may correspond to multiple
- // logical lines, if those are connected by collapsed ranges.
- function LineView(doc, line, lineN) {
- // The starting line
- this.line = line;
- // Continuing lines, if any
- this.rest = visualLineContinued(line);
- // Number of logical lines in this visual line
- this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
- this.node = this.text = null;
- this.hidden = lineIsHidden(doc, line);
+ if (!cm.options.lineWrapping) {
+ doc.iter(checkWidthStart, from.line + change.text.length, function (line) {
+ var len = lineLength(line)
+ if (len > display.maxLineLength) {
+ display.maxLine = line
+ display.maxLineLength = len
+ display.maxLineChanged = true
+ recomputeMaxLength = false
+ }
+ })
+ if (recomputeMaxLength) { cm.curOp.updateMaxLine = true }
}
- // Create a range of LineView objects for the given lines.
- function buildViewArray(cm, from, to) {
- var array = [], nextPos;
- for (var pos = from; pos < to; pos = nextPos) {
- var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
- nextPos = pos + view.size;
- array.push(view);
- }
- return array;
- }
+ // Adjust frontier, schedule worker
+ doc.frontier = Math.min(doc.frontier, from.line)
+ startWorker(cm, 400)
- // Updates the display.view data structure for a given change to the
- // document. From and to are in pre-change coordinates. Lendiff is
- // the amount of lines added or subtracted by the change. This is
- // used for changes that span multiple lines, or change the way
- // lines are divided into visual lines. regLineChange (below)
- // registers single-line changes.
- function regChange(cm, from, to, lendiff) {
- if (from == null) from = cm.doc.first;
- if (to == null) to = cm.doc.first + cm.doc.size;
- if (!lendiff) lendiff = 0;
-
- var display = cm.display;
- if (lendiff && to < display.viewTo &&
- (display.updateLineNumbers == null || display.updateLineNumbers > from))
- display.updateLineNumbers = from;
-
- cm.curOp.viewChanged = true;
-
- if (from >= display.viewTo) { // Change after
- if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
- resetView(cm);
- } else if (to <= display.viewFrom) { // Change before
- if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
- resetView(cm);
- } else {
- display.viewFrom += lendiff;
- display.viewTo += lendiff;
- }
- } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
- resetView(cm);
- } else if (from <= display.viewFrom) { // Top overlap
- var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
- if (cut) {
- display.view = display.view.slice(cut.index);
- display.viewFrom = cut.lineN;
- display.viewTo += lendiff;
- } else {
- resetView(cm);
- }
- } else if (to >= display.viewTo) { // Bottom overlap
- var cut = viewCuttingPoint(cm, from, from, -1);
- if (cut) {
- display.view = display.view.slice(0, cut.index);
- display.viewTo = cut.lineN;
- } else {
- resetView(cm);
- }
- } else { // Gap in the middle
- var cutTop = viewCuttingPoint(cm, from, from, -1);
- var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
- if (cutTop && cutBot) {
- display.view = display.view.slice(0, cutTop.index)
- .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
- .concat(display.view.slice(cutBot.index));
- display.viewTo += lendiff;
- } else {
- resetView(cm);
- }
- }
+ var lendiff = change.text.length - (to.line - from.line) - 1
+ // Remember that these lines changed, for updating the display
+ if (change.full)
+ { regChange(cm) }
+ else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
+ { regLineChange(cm, from.line, "text") }
+ else
+ { regChange(cm, from.line, to.line + 1, lendiff) }
- var ext = display.externalMeasured;
- if (ext) {
- if (to < ext.lineN)
- ext.lineN += lendiff;
- else if (from < ext.lineN + ext.size)
- display.externalMeasured = null;
+ var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change")
+ if (changeHandler || changesHandler) {
+ var obj = {
+ from: from, to: to,
+ text: change.text,
+ removed: change.removed,
+ origin: change.origin
}
+ if (changeHandler) { signalLater(cm, "change", cm, obj) }
+ if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj) }
}
+ cm.display.selForContextMenu = null
+}
- // Register a change to a single line. Type must be one of "text",
- // "gutter", "class", "widget"
- function regLineChange(cm, line, type) {
- cm.curOp.viewChanged = true;
- var display = cm.display, ext = cm.display.externalMeasured;
- if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
- display.externalMeasured = null;
+function replaceRange(doc, code, from, to, origin) {
+ if (!to) { to = from }
+ if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp }
+ if (typeof code == "string") { code = doc.splitLines(code) }
+ makeChange(doc, {from: from, to: to, text: code, origin: origin})
+}
- if (line < display.viewFrom || line >= display.viewTo) return;
- var lineView = display.view[findViewIndex(cm, line)];
- if (lineView.node == null) return;
- var arr = lineView.changes || (lineView.changes = []);
- if (indexOf(arr, type) == -1) arr.push(type);
- }
+// Rebasing/resetting history to deal with externally-sourced changes
- // Clear the view.
- function resetView(cm) {
- cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
- cm.display.view = [];
- cm.display.viewOffset = 0;
+function rebaseHistSelSingle(pos, from, to, diff) {
+ if (to < pos.line) {
+ pos.line += diff
+ } else if (from < pos.line) {
+ pos.line = from
+ pos.ch = 0
}
+}
- // Find the view element corresponding to a given line. Return null
- // when the line isn't visible.
- function findViewIndex(cm, n) {
- if (n >= cm.display.viewTo) return null;
- n -= cm.display.viewFrom;
- if (n < 0) return null;
- var view = cm.display.view;
- for (var i = 0; i < view.length; i++) {
- n -= view[i].size;
- if (n < 0) return i;
+// Tries to rebase an array of history events given a change in the
+// document. If the change touches the same lines as the event, the
+// event, and everything 'behind' it, is discarded. If the change is
+// before the event, the event's positions are updated. Uses a
+// copy-on-write scheme for the positions, to avoid having to
+// reallocate them all on every rebase, but also avoid problems with
+// shared position objects being unsafely updated.
+function rebaseHistArray(array, from, to, diff) {
+ for (var i = 0; i < array.length; ++i) {
+ var sub = array[i], ok = true
+ if (sub.ranges) {
+ if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true }
+ for (var j = 0; j < sub.ranges.length; j++) {
+ rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff)
+ rebaseHistSelSingle(sub.ranges[j].head, from, to, diff)
+ }
+ continue
}
- }
-
- function viewCuttingPoint(cm, oldN, newN, dir) {
- var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
- if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
- return {index: index, lineN: newN};
- for (var i = 0, n = cm.display.viewFrom; i < index; i++)
- n += view[i].size;
- if (n != oldN) {
- if (dir > 0) {
- if (index == view.length - 1) return null;
- diff = (n + view[index].size) - oldN;
- index++;
- } else {
- diff = n - oldN;
+ for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
+ var cur = sub.changes[j$1]
+ if (to < cur.from.line) {
+ cur.from = Pos(cur.from.line + diff, cur.from.ch)
+ cur.to = Pos(cur.to.line + diff, cur.to.ch)
+ } else if (from <= cur.to.line) {
+ ok = false
+ break
}
- oldN += diff; newN += diff;
}
- while (visualLineNo(cm.doc, newN) != newN) {
- if (index == (dir < 0 ? 0 : view.length - 1)) return null;
- newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
- index += dir;
+ if (!ok) {
+ array.splice(0, i + 1)
+ i = 0
}
- return {index: index, lineN: newN};
}
+}
- // Force the view to cover a given range, adding empty view element
- // or clipping off existing ones as needed.
- function adjustView(cm, from, to) {
- var display = cm.display, view = display.view;
- if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
- display.view = buildViewArray(cm, from, to);
- display.viewFrom = from;
- } else {
- if (display.viewFrom > from)
- display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view);
- else if (display.viewFrom < from)
- display.view = display.view.slice(findViewIndex(cm, from));
- display.viewFrom = from;
- if (display.viewTo < to)
- display.view = display.view.concat(buildViewArray(cm, display.viewTo, to));
- else if (display.viewTo > to)
- display.view = display.view.slice(0, findViewIndex(cm, to));
- }
- display.viewTo = to;
- }
-
- // Count the number of lines in the view whose DOM representation is
- // out of date (or nonexistent).
- function countDirtyView(cm) {
- var view = cm.display.view, dirty = 0;
- for (var i = 0; i < view.length; i++) {
- var lineView = view[i];
- if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty;
- }
- return dirty;
- }
-
- // EVENT HANDLERS
-
- // Attach the necessary event handlers when initializing the editor
- function registerEventHandlers(cm) {
- var d = cm.display;
- on(d.scroller, "mousedown", operation(cm, onMouseDown));
- // Older IE's will not fire a second mousedown for a double click
- if (ie && ie_version < 11)
- on(d.scroller, "dblclick", operation(cm, function(e) {
- if (signalDOMEvent(cm, e)) return;
- var pos = posFromMouse(cm, e);
- if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return;
- e_preventDefault(e);
- var word = cm.findWordAt(pos);
- extendSelection(cm.doc, word.anchor, word.head);
- }));
- else
- on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); });
- // Some browsers fire contextmenu *after* opening the menu, at
- // which point we can't mess with it anymore. Context menu is
- // handled in onMouseDown for these browsers.
- if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);});
-
- // Used to suppress mouse event handling when a touch happens
- var touchFinished, prevTouch = {end: 0};
- function finishTouch() {
- if (d.activeTouch) {
- touchFinished = setTimeout(function() {d.activeTouch = null;}, 1000);
- prevTouch = d.activeTouch;
- prevTouch.end = +new Date;
- }
- };
- function isMouseLikeTouchEvent(e) {
- if (e.touches.length != 1) return false;
- var touch = e.touches[0];
- return touch.radiusX <= 1 && touch.radiusY <= 1;
- }
- function farAway(touch, other) {
- if (other.left == null) return true;
- var dx = other.left - touch.left, dy = other.top - touch.top;
- return dx * dx + dy * dy > 20 * 20;
- }
- on(d.scroller, "touchstart", function(e) {
- if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e)) {
- clearTimeout(touchFinished);
- var now = +new Date;
- d.activeTouch = {start: now, moved: false,
- prev: now - prevTouch.end <= 300 ? prevTouch : null};
- if (e.touches.length == 1) {
- d.activeTouch.left = e.touches[0].pageX;
- d.activeTouch.top = e.touches[0].pageY;
- }
- }
- });
- on(d.scroller, "touchmove", function() {
- if (d.activeTouch) d.activeTouch.moved = true;
- });
- on(d.scroller, "touchend", function(e) {
- var touch = d.activeTouch;
- if (touch && !eventInWidget(d, e) && touch.left != null &&
- !touch.moved && new Date - touch.start < 300) {
- var pos = cm.coordsChar(d.activeTouch, "page"), range;
- if (!touch.prev || farAway(touch, touch.prev)) // Single tap
- range = new Range(pos, pos);
- else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
- range = cm.findWordAt(pos);
- else // Triple tap
- range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0)));
- cm.setSelection(range.anchor, range.head);
- cm.focus();
- e_preventDefault(e);
- }
- finishTouch();
- });
- on(d.scroller, "touchcancel", finishTouch);
-
- // Sync scrolling between fake scrollbars and real scrollable
- // area, ensure viewport is updated when scrolling.
- on(d.scroller, "scroll", function() {
- if (d.scroller.clientHeight) {
- setScrollTop(cm, d.scroller.scrollTop);
- setScrollLeft(cm, d.scroller.scrollLeft, true);
- signal(cm, "scroll", cm);
- }
- });
+function rebaseHist(hist, change) {
+ var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1
+ rebaseHistArray(hist.done, from, to, diff)
+ rebaseHistArray(hist.undone, from, to, diff)
+}
- // Listen to wheel events in order to try and update the viewport on time.
- on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
- on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
+// Utility for applying a change to a line by handle or number,
+// returning the number and optionally registering the line as
+// changed.
+function changeLine(doc, handle, changeType, op) {
+ var no = handle, line = handle
+ if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)) }
+ else { no = lineNo(handle) }
+ if (no == null) { return null }
+ if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType) }
+ return line
+}
- // Prevent wrapper from ever scrolling
- on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
+// The document is represented as a BTree consisting of leaves, with
+// chunk of lines in them, and branches, with up to ten leaves or
+// other branch nodes below them. The top node is always a branch
+// node, and is the document object itself (meaning it has
+// additional methods and properties).
+//
+// All nodes have parent links. The tree is used both to go from
+// line numbers to line objects, and to go from objects to numbers.
+// It also indexes by height, and is used to convert between height
+// and line object, and to find the total height of the document.
+//
+// See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
- d.dragFunctions = {
- enter: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);},
- over: function(e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
- start: function(e){onDragStart(cm, e);},
- drop: operation(cm, onDrop),
- leave: function(e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }}
- };
+var LeafChunk = function(lines) {
+ var this$1 = this;
- var inp = d.input.getField();
- on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
- on(inp, "keydown", operation(cm, onKeyDown));
- on(inp, "keypress", operation(cm, onKeyPress));
- on(inp, "focus", bind(onFocus, cm));
- on(inp, "blur", bind(onBlur, cm));
+ this.lines = lines
+ this.parent = null
+ var height = 0
+ for (var i = 0; i < lines.length; ++i) {
+ lines[i].parent = this$1
+ height += lines[i].height
}
+ this.height = height
+};
- function dragDropChanged(cm, value, old) {
- var wasOn = old && old != CodeMirror.Init;
- if (!value != !wasOn) {
- var funcs = cm.display.dragFunctions;
- var toggle = value ? on : off;
- toggle(cm.display.scroller, "dragstart", funcs.start);
- toggle(cm.display.scroller, "dragenter", funcs.enter);
- toggle(cm.display.scroller, "dragover", funcs.over);
- toggle(cm.display.scroller, "dragleave", funcs.leave);
- toggle(cm.display.scroller, "drop", funcs.drop);
- }
- }
+LeafChunk.prototype.chunkSize = function () { return this.lines.length };
- // Called when the window resizes
- function onResize(cm) {
- var d = cm.display;
- if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
- return;
- // Might be a text scaling operation, clear size caches.
- d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
- d.scrollbarsClipped = false;
- cm.setSize();
+// Remove the n lines at offset 'at'.
+LeafChunk.prototype.removeInner = function (at, n) {
+ var this$1 = this;
+
+ for (var i = at, e = at + n; i < e; ++i) {
+ var line = this$1.lines[i]
+ this$1.height -= line.height
+ cleanUpLine(line)
+ signalLater(line, "delete")
}
+ this.lines.splice(at, n)
+};
- // MOUSE EVENTS
+// Helper used to collapse a small branch into a single leaf.
+LeafChunk.prototype.collapse = function (lines) {
+ lines.push.apply(lines, this.lines)
+};
- // Return true when the given mouse event happened in a widget
- function eventInWidget(display, e) {
- for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
- if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
- (n.parentNode == display.sizer && n != display.mover))
- return true;
- }
- }
+// Insert the given array of lines at offset 'at', count them as
+// having the given height.
+LeafChunk.prototype.insertInner = function (at, lines, height) {
+ var this$1 = this;
- // Given a mouse event, find the corresponding position. If liberal
- // is false, it checks whether a gutter or scrollbar was clicked,
- // and returns null if it was. forRect is used by rectangular
- // selections, and tries to estimate a character position even for
- // coordinates beyond the right of the text.
- function posFromMouse(cm, e, liberal, forRect) {
- var display = cm.display;
- if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null;
-
- var x, y, space = display.lineSpace.getBoundingClientRect();
- // Fails unpredictably on IE[67] when mouse is dragged around quickly.
- try { x = e.clientX - space.left; y = e.clientY - space.top; }
- catch (e) { return null; }
- var coords = coordsChar(cm, x, y), line;
- if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
- var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
- coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
- }
- return coords;
- }
-
- // A mouse down can be a single click, double click, triple click,
- // start of selection drag, start of text drag, new cursor
- // (ctrl-click), rectangle drag (alt-drag), or xwin
- // middle-click-paste. Or it might be a click on something we should
- // not interfere with, such as a scrollbar or widget.
- function onMouseDown(e) {
- var cm = this, display = cm.display;
- if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) return;
- display.shift = e.shiftKey;
-
- if (eventInWidget(display, e)) {
- if (!webkit) {
- // Briefly turn off draggability, to allow widgets to do
- // normal dragging things.
- display.scroller.draggable = false;
- setTimeout(function(){display.scroller.draggable = true;}, 100);
- }
- return;
- }
- if (clickInGutter(cm, e)) return;
- var start = posFromMouse(cm, e);
- window.focus();
-
- switch (e_button(e)) {
- case 1:
- // #3261: make sure, that we're not starting a second selection
- if (cm.state.selectingText)
- cm.state.selectingText(e);
- else if (start)
- leftButtonDown(cm, e, start);
- else if (e_target(e) == display.scroller)
- e_preventDefault(e);
- break;
- case 2:
- if (webkit) cm.state.lastMiddleDown = +new Date;
- if (start) extendSelection(cm.doc, start);
- setTimeout(function() {display.input.focus();}, 20);
- e_preventDefault(e);
- break;
- case 3:
- if (captureRightClick) onContextMenu(cm, e);
- else delayBlurEvent(cm);
- break;
- }
- }
+ this.height += height
+ this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at))
+ for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1 }
+};
- var lastClick, lastDoubleClick;
- function leftButtonDown(cm, e, start) {
- if (ie) setTimeout(bind(ensureFocus, cm), 0);
- else cm.curOp.focus = activeElt();
+// Used to iterate over a part of the tree.
+LeafChunk.prototype.iterN = function (at, n, op) {
+ var this$1 = this;
- var now = +new Date, type;
- if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
- type = "triple";
- } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
- type = "double";
- lastDoubleClick = {time: now, pos: start};
- } else {
- type = "single";
- lastClick = {time: now, pos: start};
- }
+ for (var e = at + n; at < e; ++at)
+ { if (op(this$1.lines[at])) { return true } }
+};
- var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
- if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
- type == "single" && (contained = sel.contains(start)) > -1 &&
- (cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
- (cmp(contained.to(), start) > 0 || start.xRel < 0))
- leftButtonStartDrag(cm, e, start, modifier);
- else
- leftButtonSelect(cm, e, start, type, modifier);
- }
-
- // Start a text drag. When it ends, see if any dragging actually
- // happen, and treat as a click if it didn't.
- function leftButtonStartDrag(cm, e, start, modifier) {
- var display = cm.display, startTime = +new Date;
- var dragEnd = operation(cm, function(e2) {
- if (webkit) display.scroller.draggable = false;
- cm.state.draggingText = false;
- off(document, "mouseup", dragEnd);
- off(display.scroller, "drop", dragEnd);
- if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
- e_preventDefault(e2);
- if (!modifier && +new Date - 200 < startTime)
- extendSelection(cm.doc, start);
- // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
- if (webkit || ie && ie_version == 9)
- setTimeout(function() {document.body.focus(); display.input.focus();}, 20);
- else
- display.input.focus();
- }
- });
- // Let the drag handler handle this.
- if (webkit) display.scroller.draggable = true;
- cm.state.draggingText = dragEnd;
- dragEnd.copy = mac ? e.altKey : e.ctrlKey
- // IE's approach to draggable
- if (display.scroller.dragDrop) display.scroller.dragDrop();
- on(document, "mouseup", dragEnd);
- on(display.scroller, "drop", dragEnd);
- }
-
- // Normal selection, as opposed to text dragging.
- function leftButtonSelect(cm, e, start, type, addNew) {
- var display = cm.display, doc = cm.doc;
- e_preventDefault(e);
-
- var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
- if (addNew && !e.shiftKey) {
- ourIndex = doc.sel.contains(start);
- if (ourIndex > -1)
- ourRange = ranges[ourIndex];
- else
- ourRange = new Range(start, start);
- } else {
- ourRange = doc.sel.primary();
- ourIndex = doc.sel.primIndex;
- }
-
- if (chromeOS ? e.shiftKey && e.metaKey : e.altKey) {
- type = "rect";
- if (!addNew) ourRange = new Range(start, start);
- start = posFromMouse(cm, e, true, true);
- ourIndex = -1;
- } else if (type == "double") {
- var word = cm.findWordAt(start);
- if (cm.display.shift || doc.extend)
- ourRange = extendRange(doc, ourRange, word.anchor, word.head);
- else
- ourRange = word;
- } else if (type == "triple") {
- var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)));
- if (cm.display.shift || doc.extend)
- ourRange = extendRange(doc, ourRange, line.anchor, line.head);
- else
- ourRange = line;
- } else {
- ourRange = extendRange(doc, ourRange, start);
- }
-
- if (!addNew) {
- ourIndex = 0;
- setSelection(doc, new Selection([ourRange], 0), sel_mouse);
- startSel = doc.sel;
- } else if (ourIndex == -1) {
- ourIndex = ranges.length;
- setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
- {scroll: false, origin: "*mouse"});
- } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
- setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
- {scroll: false, origin: "*mouse"});
- startSel = doc.sel;
- } else {
- replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
- }
-
- var lastPos = start;
- function extendTo(pos) {
- if (cmp(lastPos, pos) == 0) return;
- lastPos = pos;
-
- if (type == "rect") {
- var ranges = [], tabSize = cm.options.tabSize;
- var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
- var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
- var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
- for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
- line <= end; line++) {
- var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
- if (left == right)
- ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
- else if (text.length > leftPos)
- ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
- }
- if (!ranges.length) ranges.push(new Range(start, start));
- setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
- {origin: "*mouse", scroll: false});
- cm.scrollIntoView(pos);
- } else {
- var oldRange = ourRange;
- var anchor = oldRange.anchor, head = pos;
- if (type != "single") {
- if (type == "double")
- var range = cm.findWordAt(pos);
- else
- var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
- if (cmp(range.anchor, anchor) > 0) {
- head = range.head;
- anchor = minPos(oldRange.from(), range.anchor);
- } else {
- head = range.anchor;
- anchor = maxPos(oldRange.to(), range.head);
- }
- }
- var ranges = startSel.ranges.slice(0);
- ranges[ourIndex] = new Range(clipPos(doc, anchor), head);
- setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse);
- }
- }
-
- var editorSize = display.wrapper.getBoundingClientRect();
- // Used to ensure timeout re-tries don't fire when another extend
- // happened in the meantime (clearTimeout isn't reliable -- at
- // least on Chrome, the timeouts still happen even when cleared,
- // if the clear happens after their scheduled firing time).
- var counter = 0;
-
- function extend(e) {
- var curCount = ++counter;
- var cur = posFromMouse(cm, e, true, type == "rect");
- if (!cur) return;
- if (cmp(cur, lastPos) != 0) {
- cm.curOp.focus = activeElt();
- extendTo(cur);
- var visible = visibleLines(display, doc);
- if (cur.line >= visible.to || cur.line < visible.from)
- setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
- } else {
- var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
- if (outside) setTimeout(operation(cm, function() {
- if (counter != curCount) return;
- display.scroller.scrollTop += outside;
- extend(e);
- }), 50);
- }
- }
+var BranchChunk = function(children) {
+ var this$1 = this;
- function done(e) {
- cm.state.selectingText = false;
- counter = Infinity;
- e_preventDefault(e);
- display.input.focus();
- off(document, "mousemove", move);
- off(document, "mouseup", up);
- doc.history.lastSelOrigin = null;
- }
+ this.children = children
+ var size = 0, height = 0
+ for (var i = 0; i < children.length; ++i) {
+ var ch = children[i]
+ size += ch.chunkSize(); height += ch.height
+ ch.parent = this$1
+ }
+ this.size = size
+ this.height = height
+ this.parent = null
+};
- var move = operation(cm, function(e) {
- if (!e_button(e)) done(e);
- else extend(e);
- });
- var up = operation(cm, done);
- cm.state.selectingText = up;
- on(document, "mousemove", move);
- on(document, "mouseup", up);
+BranchChunk.prototype.chunkSize = function () { return this.size };
+
+BranchChunk.prototype.removeInner = function (at, n) {
+ var this$1 = this;
+
+ this.size -= n
+ for (var i = 0; i < this.children.length; ++i) {
+ var child = this$1.children[i], sz = child.chunkSize()
+ if (at < sz) {
+ var rm = Math.min(n, sz - at), oldHeight = child.height
+ child.removeInner(at, rm)
+ this$1.height -= oldHeight - child.height
+ if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null }
+ if ((n -= rm) == 0) { break }
+ at = 0
+ } else { at -= sz }
+ }
+ // If the result is smaller than 25 lines, ensure that it is a
+ // single leaf node.
+ if (this.size - n < 25 &&
+ (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
+ var lines = []
+ this.collapse(lines)
+ this.children = [new LeafChunk(lines)]
+ this.children[0].parent = this
}
+};
- // Determines whether an event happened in the gutter, and fires the
- // handlers for the corresponding event.
- function gutterEvent(cm, e, type, prevent) {
- try { var mX = e.clientX, mY = e.clientY; }
- catch(e) { return false; }
- if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
- if (prevent) e_preventDefault(e);
+BranchChunk.prototype.collapse = function (lines) {
+ var this$1 = this;
- var display = cm.display;
- var lineBox = display.lineDiv.getBoundingClientRect();
+ for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines) }
+};
- if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
- mY -= lineBox.top - display.viewOffset;
+BranchChunk.prototype.insertInner = function (at, lines, height) {
+ var this$1 = this;
- for (var i = 0; i < cm.options.gutters.length; ++i) {
- var g = display.gutters.childNodes[i];
- if (g && g.getBoundingClientRect().right >= mX) {
- var line = lineAtHeight(cm.doc, mY);
- var gutter = cm.options.gutters[i];
- signal(cm, type, cm, line, gutter, e);
- return e_defaultPrevented(e);
+ this.size += lines.length
+ this.height += height
+ for (var i = 0; i < this.children.length; ++i) {
+ var child = this$1.children[i], sz = child.chunkSize()
+ if (at <= sz) {
+ child.insertInner(at, lines, height)
+ if (child.lines && child.lines.length > 50) {
+ // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
+ // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
+ var remaining = child.lines.length % 25 + 25
+ for (var pos = remaining; pos < child.lines.length;) {
+ var leaf = new LeafChunk(child.lines.slice(pos, pos += 25))
+ child.height -= leaf.height
+ this$1.children.splice(++i, 0, leaf)
+ leaf.parent = this$1
+ }
+ child.lines = child.lines.slice(0, remaining)
+ this$1.maybeSpill()
}
+ break
}
+ at -= sz
}
+};
- function clickInGutter(cm, e) {
- return gutterEvent(cm, e, "gutterClick", true);
- }
+// When a node has grown, check whether it should be split.
+BranchChunk.prototype.maybeSpill = function () {
+ if (this.children.length <= 10) { return }
+ var me = this
+ do {
+ var spilled = me.children.splice(me.children.length - 5, 5)
+ var sibling = new BranchChunk(spilled)
+ if (!me.parent) { // Become the parent node
+ var copy = new BranchChunk(me.children)
+ copy.parent = me
+ me.children = [copy, sibling]
+ me = copy
+ } else {
+ me.size -= sibling.size
+ me.height -= sibling.height
+ var myIndex = indexOf(me.parent.children, me)
+ me.parent.children.splice(myIndex + 1, 0, sibling)
+ }
+ sibling.parent = me.parent
+ } while (me.children.length > 10)
+ me.parent.maybeSpill()
+};
- // Kludge to work around strange IE behavior where it'll sometimes
- // re-fire a series of drag-related events right after the drop (#1551)
- var lastDrop = 0;
+BranchChunk.prototype.iterN = function (at, n, op) {
+ var this$1 = this;
- function onDrop(e) {
- var cm = this;
- clearDragCursor(cm);
- if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
- return;
- e_preventDefault(e);
- if (ie) lastDrop = +new Date;
- var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
- if (!pos || cm.isReadOnly()) return;
- // Might be a file drop, in which case we simply extract the text
- // and insert it.
- if (files && files.length && window.FileReader && window.File) {
- var n = files.length, text = Array(n), read = 0;
- var loadFile = function(file, i) {
- if (cm.options.allowDropFileTypes &&
- indexOf(cm.options.allowDropFileTypes, file.type) == -1)
- return;
-
- var reader = new FileReader;
- reader.onload = operation(cm, function() {
- var content = reader.result;
- if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = "";
- text[i] = content;
- if (++read == n) {
- pos = clipPos(cm.doc, pos);
- var change = {from: pos, to: pos,
- text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
- origin: "paste"};
- makeChange(cm.doc, change);
- setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
- }
- });
- reader.readAsText(file);
- };
- for (var i = 0; i < n; ++i) loadFile(files[i], i);
- } else { // Normal drop
- // Don't do a replace if the drop happened inside of the selected text.
- if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
- cm.state.draggingText(e);
- // Ensure the editor is re-focused
- setTimeout(function() {cm.display.input.focus();}, 20);
- return;
- }
- try {
- var text = e.dataTransfer.getData("Text");
- if (text) {
- if (cm.state.draggingText && !cm.state.draggingText.copy)
- var selected = cm.listSelections();
- setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
- if (selected) for (var i = 0; i < selected.length; ++i)
- replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag");
- cm.replaceSelection(text, "around", "paste");
- cm.display.input.focus();
- }
- }
- catch(e){}
- }
+ for (var i = 0; i < this.children.length; ++i) {
+ var child = this$1.children[i], sz = child.chunkSize()
+ if (at < sz) {
+ var used = Math.min(n, sz - at)
+ if (child.iterN(at, used, op)) { return true }
+ if ((n -= used) == 0) { break }
+ at = 0
+ } else { at -= sz }
}
+};
- function onDragStart(cm, e) {
- if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }
- if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
+// Line widgets are block elements displayed above or below a line.
- e.dataTransfer.setData("Text", cm.getSelection());
- e.dataTransfer.effectAllowed = "copyMove"
+var LineWidget = function(doc, node, options) {
+ var this$1 = this;
- // Use dummy image instead of default browsers image.
- // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
- if (e.dataTransfer.setDragImage && !safari) {
- var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
- img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
- if (presto) {
- img.width = img.height = 1;
- cm.display.wrapper.appendChild(img);
- // Force a relayout, or Opera won't use our image for some obscure reason
- img._top = img.offsetTop;
- }
- e.dataTransfer.setDragImage(img, 0, 0);
- if (presto) img.parentNode.removeChild(img);
- }
- }
+ if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
+ { this$1[opt] = options[opt] } } }
+ this.doc = doc
+ this.node = node
+};
- function onDragOver(cm, e) {
- var pos = posFromMouse(cm, e);
- if (!pos) return;
- var frag = document.createDocumentFragment();
- drawSelectionCursor(cm, pos, frag);
- if (!cm.display.dragCursor) {
- cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
- cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
- }
- removeChildrenAndAdd(cm.display.dragCursor, frag);
+LineWidget.prototype.clear = function () {
+ var this$1 = this;
+
+ var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line)
+ if (no == null || !ws) { return }
+ for (var i = 0; i < ws.length; ++i) { if (ws[i] == this$1) { ws.splice(i--, 1) } }
+ if (!ws.length) { line.widgets = null }
+ var height = widgetHeight(this)
+ updateLineHeight(line, Math.max(0, line.height - height))
+ if (cm) {
+ runInOp(cm, function () {
+ adjustScrollWhenAboveVisible(cm, line, -height)
+ regLineChange(cm, no, "widget")
+ })
+ signalLater(cm, "lineWidgetCleared", cm, this)
}
+};
- function clearDragCursor(cm) {
- if (cm.display.dragCursor) {
- cm.display.lineSpace.removeChild(cm.display.dragCursor);
- cm.display.dragCursor = null;
- }
- }
+LineWidget.prototype.changed = function () {
+ var oldH = this.height, cm = this.doc.cm, line = this.line
+ this.height = null
+ var diff = widgetHeight(this) - oldH
+ if (!diff) { return }
+ updateLineHeight(line, line.height + diff)
+ if (cm) { runInOp(cm, function () {
+ cm.curOp.forceUpdate = true
+ adjustScrollWhenAboveVisible(cm, line, diff)
+ }) }
+};
+eventMixin(LineWidget)
+
+function adjustScrollWhenAboveVisible(cm, line, diff) {
+ if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
+ { addToScrollPos(cm, null, diff) }
+}
+
+function addLineWidget(doc, handle, node, options) {
+ var widget = new LineWidget(doc, node, options)
+ var cm = doc.cm
+ if (cm && widget.noHScroll) { cm.display.alignWidgets = true }
+ changeLine(doc, handle, "widget", function (line) {
+ var widgets = line.widgets || (line.widgets = [])
+ if (widget.insertAt == null) { widgets.push(widget) }
+ else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget) }
+ widget.line = line
+ if (cm && !lineIsHidden(doc, line)) {
+ var aboveVisible = heightAtLine(line) < doc.scrollTop
+ updateLineHeight(line, line.height + widgetHeight(widget))
+ if (aboveVisible) { addToScrollPos(cm, null, widget.height) }
+ cm.curOp.forceUpdate = true
+ }
+ return true
+ })
+ signalLater(cm, "lineWidgetAdded", cm, widget)
+ return widget
+}
+
+// TEXTMARKERS
+
+// Created with markText and setBookmark methods. A TextMarker is a
+// handle that can be used to clear or find a marked position in the
+// document. Line objects hold arrays (markedSpans) containing
+// {from, to, marker} object pointing to such marker objects, and
+// indicating that such a marker is present on that line. Multiple
+// lines may point to the same marker when it spans across lines.
+// The spans will have null for their from/to properties when the
+// marker continues beyond the start/end of the line. Markers have
+// links back to the lines they currently touch.
+
+// Collapsed markers have unique ids, in order to be able to order
+// them, which is needed for uniquely determining an outer marker
+// when they overlap (they may nest, but not partially overlap).
+var nextMarkerId = 0
+
+var TextMarker = function(doc, type) {
+ this.lines = []
+ this.type = type
+ this.doc = doc
+ this.id = ++nextMarkerId
+};
- // SCROLL EVENTS
+// Clear the marker.
+TextMarker.prototype.clear = function () {
+ var this$1 = this;
+
+ if (this.explicitlyCleared) { return }
+ var cm = this.doc.cm, withOp = cm && !cm.curOp
+ if (withOp) { startOperation(cm) }
+ if (hasHandler(this, "clear")) {
+ var found = this.find()
+ if (found) { signalLater(this, "clear", found.from, found.to) }
+ }
+ var min = null, max = null
+ for (var i = 0; i < this.lines.length; ++i) {
+ var line = this$1.lines[i]
+ var span = getMarkedSpanFor(line.markedSpans, this$1)
+ if (cm && !this$1.collapsed) { regLineChange(cm, lineNo(line), "text") }
+ else if (cm) {
+ if (span.to != null) { max = lineNo(line) }
+ if (span.from != null) { min = lineNo(line) }
+ }
+ line.markedSpans = removeMarkedSpan(line.markedSpans, span)
+ if (span.from == null && this$1.collapsed && !lineIsHidden(this$1.doc, line) && cm)
+ { updateLineHeight(line, textHeight(cm.display)) }
+ }
+ if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) {
+ var visual = visualLine(this$1.lines[i$1]), len = lineLength(visual)
+ if (len > cm.display.maxLineLength) {
+ cm.display.maxLine = visual
+ cm.display.maxLineLength = len
+ cm.display.maxLineChanged = true
+ }
+ } }
+
+ if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1) }
+ this.lines.length = 0
+ this.explicitlyCleared = true
+ if (this.atomic && this.doc.cantEdit) {
+ this.doc.cantEdit = false
+ if (cm) { reCheckSelection(cm.doc) }
+ }
+ if (cm) { signalLater(cm, "markerCleared", cm, this) }
+ if (withOp) { endOperation(cm) }
+ if (this.parent) { this.parent.clear() }
+};
- // Sync the scrollable area and scrollbars, ensure the viewport
- // covers the visible area.
- function setScrollTop(cm, val) {
- if (Math.abs(cm.doc.scrollTop - val) < 2) return;
- cm.doc.scrollTop = val;
- if (!gecko) updateDisplaySimple(cm, {top: val});
- if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
- cm.display.scrollbars.setScrollTop(val);
- if (gecko) updateDisplaySimple(cm);
- startWorker(cm, 100);
- }
- // Sync scroller and scrollbar, ensure the gutter elements are
- // aligned.
- function setScrollLeft(cm, val, isScroller) {
- if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;
- val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
- cm.doc.scrollLeft = val;
- alignHorizontally(cm);
- if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
- cm.display.scrollbars.setScrollLeft(val);
+// Find the position of the marker in the document. Returns a {from,
+// to} object by default. Side can be passed to get a specific side
+// -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
+// Pos objects returned contain a line object, rather than a line
+// number (used to prevent looking up the same line twice).
+TextMarker.prototype.find = function (side, lineObj) {
+ var this$1 = this;
+
+ if (side == null && this.type == "bookmark") { side = 1 }
+ var from, to
+ for (var i = 0; i < this.lines.length; ++i) {
+ var line = this$1.lines[i]
+ var span = getMarkedSpanFor(line.markedSpans, this$1)
+ if (span.from != null) {
+ from = Pos(lineObj ? line : lineNo(line), span.from)
+ if (side == -1) { return from }
+ }
+ if (span.to != null) {
+ to = Pos(lineObj ? line : lineNo(line), span.to)
+ if (side == 1) { return to }
+ }
+ }
+ return from && {from: from, to: to}
+};
+
+// Signals that the marker's widget changed, and surrounding layout
+// should be recomputed.
+TextMarker.prototype.changed = function () {
+ var pos = this.find(-1, true), widget = this, cm = this.doc.cm
+ if (!pos || !cm) { return }
+ runInOp(cm, function () {
+ var line = pos.line, lineN = lineNo(pos.line)
+ var view = findViewForLine(cm, lineN)
+ if (view) {
+ clearLineMeasurementCacheFor(view)
+ cm.curOp.selectionChanged = cm.curOp.forceUpdate = true
+ }
+ cm.curOp.updateMaxLine = true
+ if (!lineIsHidden(widget.doc, line) && widget.height != null) {
+ var oldHeight = widget.height
+ widget.height = null
+ var dHeight = widgetHeight(widget) - oldHeight
+ if (dHeight)
+ { updateLineHeight(line, line.height + dHeight) }
+ }
+ })
+};
+
+TextMarker.prototype.attachLine = function (line) {
+ if (!this.lines.length && this.doc.cm) {
+ var op = this.doc.cm.curOp
+ if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
+ { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this) }
}
+ this.lines.push(line)
+};
- // Since the delta values reported on mouse wheel events are
- // unstandardized between browsers and even browser versions, and
- // generally horribly unpredictable, this code starts by measuring
- // the scroll effect that the first few mouse wheel events have,
- // and, from that, detects the way it can convert deltas to pixel
- // offsets afterwards.
- //
- // The reason we want to know the amount a wheel event will scroll
- // is that it gives us a chance to update the display before the
- // actual scrolling happens, reducing flickering.
-
- var wheelSamples = 0, wheelPixelsPerUnit = null;
- // Fill in a browser-detected starting value on browsers where we
- // know one. These don't have to be accurate -- the result of them
- // being wrong would just be a slight flicker on the first wheel
- // scroll (if it is large enough).
- if (ie) wheelPixelsPerUnit = -.53;
- else if (gecko) wheelPixelsPerUnit = 15;
- else if (chrome) wheelPixelsPerUnit = -.7;
- else if (safari) wheelPixelsPerUnit = -1/3;
-
- var wheelEventDelta = function(e) {
- var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
- if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail;
- if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail;
- else if (dy == null) dy = e.wheelDelta;
- return {x: dx, y: dy};
- };
- CodeMirror.wheelEventPixels = function(e) {
- var delta = wheelEventDelta(e);
- delta.x *= wheelPixelsPerUnit;
- delta.y *= wheelPixelsPerUnit;
- return delta;
- };
+TextMarker.prototype.detachLine = function (line) {
+ this.lines.splice(indexOf(this.lines, line), 1)
+ if (!this.lines.length && this.doc.cm) {
+ var op = this.doc.cm.curOp
+ ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this)
+ }
+};
+eventMixin(TextMarker)
+
+// Create a marker, wire it up to the right lines, and
+function markText(doc, from, to, options, type) {
+ // Shared markers (across linked documents) are handled separately
+ // (markTextShared will call out to this again, once per
+ // document).
+ if (options && options.shared) { return markTextShared(doc, from, to, options, type) }
+ // Ensure we are in an operation.
+ if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) }
+
+ var marker = new TextMarker(doc, type), diff = cmp(from, to)
+ if (options) { copyObj(options, marker, false) }
+ // Don't connect empty markers unless clearWhenEmpty is false
+ if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
+ { return marker }
+ if (marker.replacedWith) {
+ // Showing up as a widget implies collapsed (widget replaces text)
+ marker.collapsed = true
+ marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget")
+ marker.widgetNode.setAttribute("role", "presentation") // hide from accessibility tree
+ if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true") }
+ if (options.insertLeft) { marker.widgetNode.insertLeft = true }
+ }
+ if (marker.collapsed) {
+ if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
+ from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
+ { throw new Error("Inserting collapsed marker partially overlapping an existing one") }
+ seeCollapsedSpans()
+ }
+
+ if (marker.addToHistory)
+ { addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN) }
+
+ var curLine = from.line, cm = doc.cm, updateMaxLine
+ doc.iter(curLine, to.line + 1, function (line) {
+ if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
+ { updateMaxLine = true }
+ if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0) }
+ addMarkedSpan(line, new MarkedSpan(marker,
+ curLine == from.line ? from.ch : null,
+ curLine == to.line ? to.ch : null))
+ ++curLine
+ })
+ // lineIsHidden depends on the presence of the spans, so needs a second pass
+ if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) {
+ if (lineIsHidden(doc, line)) { updateLineHeight(line, 0) }
+ }) }
+
+ if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }) }
+
+ if (marker.readOnly) {
+ seeReadOnlySpans()
+ if (doc.history.done.length || doc.history.undone.length)
+ { doc.clearHistory() }
+ }
+ if (marker.collapsed) {
+ marker.id = ++nextMarkerId
+ marker.atomic = true
+ }
+ if (cm) {
+ // Sync editor state
+ if (updateMaxLine) { cm.curOp.updateMaxLine = true }
+ if (marker.collapsed)
+ { regChange(cm, from.line, to.line + 1) }
+ else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
+ { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text") } }
+ if (marker.atomic) { reCheckSelection(cm.doc) }
+ signalLater(cm, "markerAdded", cm, marker)
+ }
+ return marker
+}
+
+// SHARED TEXTMARKERS
+
+// A shared marker spans multiple linked documents. It is
+// implemented as a meta-marker-object controlling multiple normal
+// markers.
+var SharedTextMarker = function(markers, primary) {
+ var this$1 = this;
+
+ this.markers = markers
+ this.primary = primary
+ for (var i = 0; i < markers.length; ++i)
+ { markers[i].parent = this$1 }
+};
- function onScrollWheel(cm, e) {
- var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
-
- var display = cm.display, scroll = display.scroller;
- // Quit if there's nothing to scroll here
- var canScrollX = scroll.scrollWidth > scroll.clientWidth;
- var canScrollY = scroll.scrollHeight > scroll.clientHeight;
- if (!(dx && canScrollX || dy && canScrollY)) return;
-
- // Webkit browsers on OS X abort momentum scrolls when the target
- // of the scroll event is removed from the scrollable element.
- // This hack (see related code in patchDisplay) makes sure the
- // element is kept around.
- if (dy && mac && webkit) {
- outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
- for (var i = 0; i < view.length; i++) {
- if (view[i].node == cur) {
- cm.display.currentWheelTarget = cur;
- break outer;
- }
- }
- }
- }
+SharedTextMarker.prototype.clear = function () {
+ var this$1 = this;
- // On some browsers, horizontal scrolling will cause redraws to
- // happen before the gutter has been realigned, causing it to
- // wriggle around in a most unseemly way. When we have an
- // estimated pixels/delta value, we just handle horizontal
- // scrolling entirely here. It'll be slightly off from native, but
- // better than glitching out.
- if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
- if (dy && canScrollY)
- setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight)));
- setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)));
- // Only prevent default scrolling if vertical scrolling is
- // actually possible. Otherwise, it causes vertical scroll
- // jitter on OSX trackpads when deltaX is small and deltaY
- // is large (issue #3579)
- if (!dy || (dy && canScrollY))
- e_preventDefault(e);
- display.wheelStartX = null; // Abort measurement, if in progress
- return;
- }
+ if (this.explicitlyCleared) { return }
+ this.explicitlyCleared = true
+ for (var i = 0; i < this.markers.length; ++i)
+ { this$1.markers[i].clear() }
+ signalLater(this, "clear")
+};
- // 'Project' the visible viewport to cover the area that is being
- // scrolled into view (if we know enough to estimate it).
- if (dy && wheelPixelsPerUnit != null) {
- var pixels = dy * wheelPixelsPerUnit;
- var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
- if (pixels < 0) top = Math.max(0, top + pixels - 50);
- else bot = Math.min(cm.doc.height, bot + pixels + 50);
- updateDisplaySimple(cm, {top: top, bottom: bot});
- }
-
- if (wheelSamples < 20) {
- if (display.wheelStartX == null) {
- display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
- display.wheelDX = dx; display.wheelDY = dy;
- setTimeout(function() {
- if (display.wheelStartX == null) return;
- var movedX = scroll.scrollLeft - display.wheelStartX;
- var movedY = scroll.scrollTop - display.wheelStartY;
- var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
- (movedX && display.wheelDX && movedX / display.wheelDX);
- display.wheelStartX = display.wheelStartY = null;
- if (!sample) return;
- wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
- ++wheelSamples;
- }, 200);
- } else {
- display.wheelDX += dx; display.wheelDY += dy;
- }
- }
- }
+SharedTextMarker.prototype.find = function (side, lineObj) {
+ return this.primary.find(side, lineObj)
+};
+eventMixin(SharedTextMarker)
- // KEY EVENTS
+function markTextShared(doc, from, to, options, type) {
+ options = copyObj(options)
+ options.shared = false
+ var markers = [markText(doc, from, to, options, type)], primary = markers[0]
+ var widget = options.widgetNode
+ linkedDocs(doc, function (doc) {
+ if (widget) { options.widgetNode = widget.cloneNode(true) }
+ markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type))
+ for (var i = 0; i < doc.linked.length; ++i)
+ { if (doc.linked[i].isParent) { return } }
+ primary = lst(markers)
+ })
+ return new SharedTextMarker(markers, primary)
+}
- // Run a handler that was bound to a key.
- function doHandleBinding(cm, bound, dropShift) {
- if (typeof bound == "string") {
- bound = commands[bound];
- if (!bound) return false;
- }
- // Ensure previous input has been read, so that the handler sees a
- // consistent view of the document
- cm.display.input.ensurePolled();
- var prevShift = cm.display.shift, done = false;
- try {
- if (cm.isReadOnly()) cm.state.suppressEdits = true;
- if (dropShift) cm.display.shift = false;
- done = bound(cm) != Pass;
- } finally {
- cm.display.shift = prevShift;
- cm.state.suppressEdits = false;
- }
- return done;
- }
+function findSharedMarkers(doc) {
+ return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; })
+}
- function lookupKeyForEditor(cm, name, handle) {
- for (var i = 0; i < cm.state.keyMaps.length; i++) {
- var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
- if (result) return result;
+function copySharedMarkers(doc, markers) {
+ for (var i = 0; i < markers.length; i++) {
+ var marker = markers[i], pos = marker.find()
+ var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to)
+ if (cmp(mFrom, mTo)) {
+ var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type)
+ marker.markers.push(subMark)
+ subMark.parent = marker
}
- return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
- || lookupKey(name, cm.options.keyMap, handle, cm);
}
+}
- var stopSeq = new Delayed;
- function dispatchKey(cm, name, e, handle) {
- var seq = cm.state.keySeq;
- if (seq) {
- if (isModifierKey(name)) return "handled";
- stopSeq.set(50, function() {
- if (cm.state.keySeq == seq) {
- cm.state.keySeq = null;
- cm.display.input.reset();
- }
- });
- name = seq + " " + name;
+function detachSharedMarkers(markers) {
+ var loop = function ( i ) {
+ var marker = markers[i], linked = [marker.primary.doc]
+ linkedDocs(marker.primary.doc, function (d) { return linked.push(d); })
+ for (var j = 0; j < marker.markers.length; j++) {
+ var subMarker = marker.markers[j]
+ if (indexOf(linked, subMarker.doc) == -1) {
+ subMarker.parent = null
+ marker.markers.splice(j--, 1)
+ }
}
- var result = lookupKeyForEditor(cm, name, handle);
-
- if (result == "multi")
- cm.state.keySeq = name;
- if (result == "handled")
- signalLater(cm, "keyHandled", cm, name, e);
+ };
- if (result == "handled" || result == "multi") {
- e_preventDefault(e);
- restartBlink(cm);
+ for (var i = 0; i < markers.length; i++) loop( i );
+}
+
+var nextDocId = 0
+var Doc = function(text, mode, firstLine, lineSep) {
+ if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep) }
+ if (firstLine == null) { firstLine = 0 }
+
+ BranchChunk.call(this, [new LeafChunk([new Line("", null)])])
+ this.first = firstLine
+ this.scrollTop = this.scrollLeft = 0
+ this.cantEdit = false
+ this.cleanGeneration = 1
+ this.frontier = firstLine
+ var start = Pos(firstLine, 0)
+ this.sel = simpleSelection(start)
+ this.history = new History(null)
+ this.id = ++nextDocId
+ this.modeOption = mode
+ this.lineSep = lineSep
+ this.extend = false
+
+ if (typeof text == "string") { text = this.splitLines(text) }
+ updateDoc(this, {from: start, to: start, text: text})
+ setSelection(this, simpleSelection(start), sel_dontScroll)
+}
+
+Doc.prototype = createObj(BranchChunk.prototype, {
+ constructor: Doc,
+ // Iterate over the document. Supports two forms -- with only one
+ // argument, it calls that for each line in the document. With
+ // three, it iterates over the range given by the first two (with
+ // the second being non-inclusive).
+ iter: function(from, to, op) {
+ if (op) { this.iterN(from - this.first, to - from, op) }
+ else { this.iterN(this.first, this.first + this.size, from) }
+ },
+
+ // Non-public interface for adding and removing lines.
+ insert: function(at, lines) {
+ var height = 0
+ for (var i = 0; i < lines.length; ++i) { height += lines[i].height }
+ this.insertInner(at - this.first, lines, height)
+ },
+ remove: function(at, n) { this.removeInner(at - this.first, n) },
+
+ // From here, the methods are part of the public interface. Most
+ // are also available from CodeMirror (editor) instances.
+
+ getValue: function(lineSep) {
+ var lines = getLines(this, this.first, this.first + this.size)
+ if (lineSep === false) { return lines }
+ return lines.join(lineSep || this.lineSeparator())
+ },
+ setValue: docMethodOp(function(code) {
+ var top = Pos(this.first, 0), last = this.first + this.size - 1
+ makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
+ text: this.splitLines(code), origin: "setValue", full: true}, true)
+ setSelection(this, simpleSelection(top))
+ }),
+ replaceRange: function(code, from, to, origin) {
+ from = clipPos(this, from)
+ to = to ? clipPos(this, to) : from
+ replaceRange(this, code, from, to, origin)
+ },
+ getRange: function(from, to, lineSep) {
+ var lines = getBetween(this, clipPos(this, from), clipPos(this, to))
+ if (lineSep === false) { return lines }
+ return lines.join(lineSep || this.lineSeparator())
+ },
+
+ getLine: function(line) {var l = this.getLineHandle(line); return l && l.text},
+
+ getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }},
+ getLineNumber: function(line) {return lineNo(line)},
+
+ getLineHandleVisualStart: function(line) {
+ if (typeof line == "number") { line = getLine(this, line) }
+ return visualLine(line)
+ },
+
+ lineCount: function() {return this.size},
+ firstLine: function() {return this.first},
+ lastLine: function() {return this.first + this.size - 1},
+
+ clipPos: function(pos) {return clipPos(this, pos)},
+
+ getCursor: function(start) {
+ var range = this.sel.primary(), pos
+ if (start == null || start == "head") { pos = range.head }
+ else if (start == "anchor") { pos = range.anchor }
+ else if (start == "end" || start == "to" || start === false) { pos = range.to() }
+ else { pos = range.from() }
+ return pos
+ },
+ listSelections: function() { return this.sel.ranges },
+ somethingSelected: function() {return this.sel.somethingSelected()},
+
+ setCursor: docMethodOp(function(line, ch, options) {
+ setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options)
+ }),
+ setSelection: docMethodOp(function(anchor, head, options) {
+ setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options)
+ }),
+ extendSelection: docMethodOp(function(head, other, options) {
+ extendSelection(this, clipPos(this, head), other && clipPos(this, other), options)
+ }),
+ extendSelections: docMethodOp(function(heads, options) {
+ extendSelections(this, clipPosArray(this, heads), options)
+ }),
+ extendSelectionsBy: docMethodOp(function(f, options) {
+ var heads = map(this.sel.ranges, f)
+ extendSelections(this, clipPosArray(this, heads), options)
+ }),
+ setSelections: docMethodOp(function(ranges, primary, options) {
+ var this$1 = this;
+
+ if (!ranges.length) { return }
+ var out = []
+ for (var i = 0; i < ranges.length; i++)
+ { out[i] = new Range(clipPos(this$1, ranges[i].anchor),
+ clipPos(this$1, ranges[i].head)) }
+ if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex) }
+ setSelection(this, normalizeSelection(out, primary), options)
+ }),
+ addSelection: docMethodOp(function(anchor, head, options) {
+ var ranges = this.sel.ranges.slice(0)
+ ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)))
+ setSelection(this, normalizeSelection(ranges, ranges.length - 1), options)
+ }),
+
+ getSelection: function(lineSep) {
+ var this$1 = this;
+
+ var ranges = this.sel.ranges, lines
+ for (var i = 0; i < ranges.length; i++) {
+ var sel = getBetween(this$1, ranges[i].from(), ranges[i].to())
+ lines = lines ? lines.concat(sel) : sel
}
+ if (lineSep === false) { return lines }
+ else { return lines.join(lineSep || this.lineSeparator()) }
+ },
+ getSelections: function(lineSep) {
+ var this$1 = this;
- if (seq && !result && /\'$/.test(name)) {
- e_preventDefault(e);
- return true;
+ var parts = [], ranges = this.sel.ranges
+ for (var i = 0; i < ranges.length; i++) {
+ var sel = getBetween(this$1, ranges[i].from(), ranges[i].to())
+ if (lineSep !== false) { sel = sel.join(lineSep || this$1.lineSeparator()) }
+ parts[i] = sel
}
- return !!result;
- }
-
- // Handle a key from the keydown event.
- function handleKeyBinding(cm, e) {
- var name = keyName(e, true);
- if (!name) return false;
+ return parts
+ },
+ replaceSelection: function(code, collapse, origin) {
+ var dup = []
+ for (var i = 0; i < this.sel.ranges.length; i++)
+ { dup[i] = code }
+ this.replaceSelections(dup, collapse, origin || "+input")
+ },
+ replaceSelections: docMethodOp(function(code, collapse, origin) {
+ var this$1 = this;
- if (e.shiftKey && !cm.state.keySeq) {
- // First try to resolve full name (including 'Shift-'). Failing
- // that, see if there is a cursor-motion command (starting with
- // 'go') bound to the keyname without 'Shift-'.
- return dispatchKey(cm, "Shift-" + name, e, function(b) {return doHandleBinding(cm, b, true);})
- || dispatchKey(cm, name, e, function(b) {
- if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
- return doHandleBinding(cm, b);
- });
+ var changes = [], sel = this.sel
+ for (var i = 0; i < sel.ranges.length; i++) {
+ var range = sel.ranges[i]
+ changes[i] = {from: range.from(), to: range.to(), text: this$1.splitLines(code[i]), origin: origin}
+ }
+ var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse)
+ for (var i$1 = changes.length - 1; i$1 >= 0; i$1--)
+ { makeChange(this$1, changes[i$1]) }
+ if (newSel) { setSelectionReplaceHistory(this, newSel) }
+ else if (this.cm) { ensureCursorVisible(this.cm) }
+ }),
+ undo: docMethodOp(function() {makeChangeFromHistory(this, "undo")}),
+ redo: docMethodOp(function() {makeChangeFromHistory(this, "redo")}),
+ undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true)}),
+ redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true)}),
+
+ setExtending: function(val) {this.extend = val},
+ getExtending: function() {return this.extend},
+
+ historySize: function() {
+ var hist = this.history, done = 0, undone = 0
+ for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done } }
+ for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone } }
+ return {undo: done, redo: undone}
+ },
+ clearHistory: function() {this.history = new History(this.history.maxGeneration)},
+
+ markClean: function() {
+ this.cleanGeneration = this.changeGeneration(true)
+ },
+ changeGeneration: function(forceSplit) {
+ if (forceSplit)
+ { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null }
+ return this.history.generation
+ },
+ isClean: function (gen) {
+ return this.history.generation == (gen || this.cleanGeneration)
+ },
+
+ getHistory: function() {
+ return {done: copyHistoryArray(this.history.done),
+ undone: copyHistoryArray(this.history.undone)}
+ },
+ setHistory: function(histData) {
+ var hist = this.history = new History(this.history.maxGeneration)
+ hist.done = copyHistoryArray(histData.done.slice(0), null, true)
+ hist.undone = copyHistoryArray(histData.undone.slice(0), null, true)
+ },
+
+ setGutterMarker: docMethodOp(function(line, gutterID, value) {
+ return changeLine(this, line, "gutter", function (line) {
+ var markers = line.gutterMarkers || (line.gutterMarkers = {})
+ markers[gutterID] = value
+ if (!value && isEmpty(markers)) { line.gutterMarkers = null }
+ return true
+ })
+ }),
+
+ clearGutter: docMethodOp(function(gutterID) {
+ var this$1 = this;
+
+ this.iter(function (line) {
+ if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
+ changeLine(this$1, line, "gutter", function () {
+ line.gutterMarkers[gutterID] = null
+ if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null }
+ return true
+ })
+ }
+ })
+ }),
+
+ lineInfo: function(line) {
+ var n
+ if (typeof line == "number") {
+ if (!isLine(this, line)) { return null }
+ n = line
+ line = getLine(this, line)
+ if (!line) { return null }
} else {
- return dispatchKey(cm, name, e, function(b) { return doHandleBinding(cm, b); });
+ n = lineNo(line)
+ if (n == null) { return null }
+ }
+ return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
+ textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
+ widgets: line.widgets}
+ },
+
+ addLineClass: docMethodOp(function(handle, where, cls) {
+ return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
+ var prop = where == "text" ? "textClass"
+ : where == "background" ? "bgClass"
+ : where == "gutter" ? "gutterClass" : "wrapClass"
+ if (!line[prop]) { line[prop] = cls }
+ else if (classTest(cls).test(line[prop])) { return false }
+ else { line[prop] += " " + cls }
+ return true
+ })
+ }),
+ removeLineClass: docMethodOp(function(handle, where, cls) {
+ return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
+ var prop = where == "text" ? "textClass"
+ : where == "background" ? "bgClass"
+ : where == "gutter" ? "gutterClass" : "wrapClass"
+ var cur = line[prop]
+ if (!cur) { return false }
+ else if (cls == null) { line[prop] = null }
+ else {
+ var found = cur.match(classTest(cls))
+ if (!found) { return false }
+ var end = found.index + found[0].length
+ line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null
+ }
+ return true
+ })
+ }),
+
+ addLineWidget: docMethodOp(function(handle, node, options) {
+ return addLineWidget(this, handle, node, options)
+ }),
+ removeLineWidget: function(widget) { widget.clear() },
+
+ markText: function(from, to, options) {
+ return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range")
+ },
+ setBookmark: function(pos, options) {
+ var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
+ insertLeft: options && options.insertLeft,
+ clearWhenEmpty: false, shared: options && options.shared,
+ handleMouseEvents: options && options.handleMouseEvents}
+ pos = clipPos(this, pos)
+ return markText(this, pos, pos, realOpts, "bookmark")
+ },
+ findMarksAt: function(pos) {
+ pos = clipPos(this, pos)
+ var markers = [], spans = getLine(this, pos.line).markedSpans
+ if (spans) { for (var i = 0; i < spans.length; ++i) {
+ var span = spans[i]
+ if ((span.from == null || span.from <= pos.ch) &&
+ (span.to == null || span.to >= pos.ch))
+ { markers.push(span.marker.parent || span.marker) }
+ } }
+ return markers
+ },
+ findMarks: function(from, to, filter) {
+ from = clipPos(this, from); to = clipPos(this, to)
+ var found = [], lineNo = from.line
+ this.iter(from.line, to.line + 1, function (line) {
+ var spans = line.markedSpans
+ if (spans) { for (var i = 0; i < spans.length; i++) {
+ var span = spans[i]
+ if (!(span.to != null && lineNo == from.line && from.ch >= span.to ||
+ span.from == null && lineNo != from.line ||
+ span.from != null && lineNo == to.line && span.from >= to.ch) &&
+ (!filter || filter(span.marker)))
+ { found.push(span.marker.parent || span.marker) }
+ } }
+ ++lineNo
+ })
+ return found
+ },
+ getAllMarks: function() {
+ var markers = []
+ this.iter(function (line) {
+ var sps = line.markedSpans
+ if (sps) { for (var i = 0; i < sps.length; ++i)
+ { if (sps[i].from != null) { markers.push(sps[i].marker) } } }
+ })
+ return markers
+ },
+
+ posFromIndex: function(off) {
+ var ch, lineNo = this.first, sepSize = this.lineSeparator().length
+ this.iter(function (line) {
+ var sz = line.text.length + sepSize
+ if (sz > off) { ch = off; return true }
+ off -= sz
+ ++lineNo
+ })
+ return clipPos(this, Pos(lineNo, ch))
+ },
+ indexFromPos: function (coords) {
+ coords = clipPos(this, coords)
+ var index = coords.ch
+ if (coords.line < this.first || coords.ch < 0) { return 0 }
+ var sepSize = this.lineSeparator().length
+ this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value
+ index += line.text.length + sepSize
+ })
+ return index
+ },
+
+ copy: function(copyHistory) {
+ var doc = new Doc(getLines(this, this.first, this.first + this.size),
+ this.modeOption, this.first, this.lineSep)
+ doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft
+ doc.sel = this.sel
+ doc.extend = false
+ if (copyHistory) {
+ doc.history.undoDepth = this.history.undoDepth
+ doc.setHistory(this.getHistory())
+ }
+ return doc
+ },
+
+ linkedDoc: function(options) {
+ if (!options) { options = {} }
+ var from = this.first, to = this.first + this.size
+ if (options.from != null && options.from > from) { from = options.from }
+ if (options.to != null && options.to < to) { to = options.to }
+ var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep)
+ if (options.sharedHist) { copy.history = this.history
+ ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist})
+ copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]
+ copySharedMarkers(copy, findSharedMarkers(this))
+ return copy
+ },
+ unlinkDoc: function(other) {
+ var this$1 = this;
+
+ if (other instanceof CodeMirror) { other = other.doc }
+ if (this.linked) { for (var i = 0; i < this.linked.length; ++i) {
+ var link = this$1.linked[i]
+ if (link.doc != other) { continue }
+ this$1.linked.splice(i, 1)
+ other.unlinkDoc(this$1)
+ detachSharedMarkers(findSharedMarkers(this$1))
+ break
+ } }
+ // If the histories were shared, split them again
+ if (other.history == this.history) {
+ var splitIds = [other.id]
+ linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true)
+ other.history = new History(null)
+ other.history.done = copyHistoryArray(this.history.done, splitIds)
+ other.history.undone = copyHistoryArray(this.history.undone, splitIds)
+ }
+ },
+ iterLinkedDocs: function(f) {linkedDocs(this, f)},
+
+ getMode: function() {return this.mode},
+ getEditor: function() {return this.cm},
+
+ splitLines: function(str) {
+ if (this.lineSep) { return str.split(this.lineSep) }
+ return splitLinesAuto(str)
+ },
+ lineSeparator: function() { return this.lineSep || "\n" }
+})
+
+// Public alias.
+Doc.prototype.eachLine = Doc.prototype.iter
+
+// Kludge to work around strange IE behavior where it'll sometimes
+// re-fire a series of drag-related events right after the drop (#1551)
+var lastDrop = 0
+
+function onDrop(e) {
+ var cm = this
+ clearDragCursor(cm)
+ if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
+ { return }
+ e_preventDefault(e)
+ if (ie) { lastDrop = +new Date }
+ var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files
+ if (!pos || cm.isReadOnly()) { return }
+ // Might be a file drop, in which case we simply extract the text
+ // and insert it.
+ if (files && files.length && window.FileReader && window.File) {
+ var n = files.length, text = Array(n), read = 0
+ var loadFile = function (file, i) {
+ if (cm.options.allowDropFileTypes &&
+ indexOf(cm.options.allowDropFileTypes, file.type) == -1)
+ { return }
+
+ var reader = new FileReader
+ reader.onload = operation(cm, function () {
+ var content = reader.result
+ if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { content = "" }
+ text[i] = content
+ if (++read == n) {
+ pos = clipPos(cm.doc, pos)
+ var change = {from: pos, to: pos,
+ text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
+ origin: "paste"}
+ makeChange(cm.doc, change)
+ setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)))
+ }
+ })
+ reader.readAsText(file)
+ }
+ for (var i = 0; i < n; ++i) { loadFile(files[i], i) }
+ } else { // Normal drop
+ // Don't do a replace if the drop happened inside of the selected text.
+ if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
+ cm.state.draggingText(e)
+ // Ensure the editor is re-focused
+ setTimeout(function () { return cm.display.input.focus(); }, 20)
+ return
+ }
+ try {
+ var text$1 = e.dataTransfer.getData("Text")
+ if (text$1) {
+ var selected
+ if (cm.state.draggingText && !cm.state.draggingText.copy)
+ { selected = cm.listSelections() }
+ setSelectionNoUndo(cm.doc, simpleSelection(pos, pos))
+ if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1)
+ { replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag") } }
+ cm.replaceSelection(text$1, "around", "paste")
+ cm.display.input.focus()
+ }
}
+ catch(e){}
}
+}
- // Handle a key from the keypress event
- function handleCharBinding(cm, e, ch) {
- return dispatchKey(cm, "'" + ch + "'", e,
- function(b) { return doHandleBinding(cm, b, true); });
- }
+function onDragStart(cm, e) {
+ if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return }
+ if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return }
+
+ e.dataTransfer.setData("Text", cm.getSelection())
+ e.dataTransfer.effectAllowed = "copyMove"
- var lastStoppedKey = null;
- function onKeyDown(e) {
- var cm = this;
- cm.curOp.focus = activeElt();
- if (signalDOMEvent(cm, e)) return;
- // IE does strange things with escape.
- if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false;
- var code = e.keyCode;
- cm.display.shift = code == 16 || e.shiftKey;
- var handled = handleKeyBinding(cm, e);
+ // Use dummy image instead of default browsers image.
+ // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
+ if (e.dataTransfer.setDragImage && !safari) {
+ var img = elt("img", null, null, "position: fixed; left: 0; top: 0;")
+ img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
if (presto) {
- lastStoppedKey = handled ? code : null;
- // Opera has no cut event... we try to at least catch the key combo
- if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
- cm.replaceSelection("", null, "cut");
+ img.width = img.height = 1
+ cm.display.wrapper.appendChild(img)
+ // Force a relayout, or Opera won't use our image for some obscure reason
+ img._top = img.offsetTop
+ }
+ e.dataTransfer.setDragImage(img, 0, 0)
+ if (presto) { img.parentNode.removeChild(img) }
+ }
+}
+
+function onDragOver(cm, e) {
+ var pos = posFromMouse(cm, e)
+ if (!pos) { return }
+ var frag = document.createDocumentFragment()
+ drawSelectionCursor(cm, pos, frag)
+ if (!cm.display.dragCursor) {
+ cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors")
+ cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv)
+ }
+ removeChildrenAndAdd(cm.display.dragCursor, frag)
+}
+
+function clearDragCursor(cm) {
+ if (cm.display.dragCursor) {
+ cm.display.lineSpace.removeChild(cm.display.dragCursor)
+ cm.display.dragCursor = null
+ }
+}
+
+// These must be handled carefully, because naively registering a
+// handler for each editor will cause the editors to never be
+// garbage collected.
+
+function forEachCodeMirror(f) {
+ if (!document.body.getElementsByClassName) { return }
+ var byClass = document.body.getElementsByClassName("CodeMirror")
+ for (var i = 0; i < byClass.length; i++) {
+ var cm = byClass[i].CodeMirror
+ if (cm) { f(cm) }
+ }
+}
+
+var globalsRegistered = false
+function ensureGlobalHandlers() {
+ if (globalsRegistered) { return }
+ registerGlobalHandlers()
+ globalsRegistered = true
+}
+function registerGlobalHandlers() {
+ // When the window resizes, we need to refresh active editors.
+ var resizeTimer
+ on(window, "resize", function () {
+ if (resizeTimer == null) { resizeTimer = setTimeout(function () {
+ resizeTimer = null
+ forEachCodeMirror(onResize)
+ }, 100) }
+ })
+ // When the window loses focus, we want to show the editor as blurred
+ on(window, "blur", function () { return forEachCodeMirror(onBlur); })
+}
+// Called when the window resizes
+function onResize(cm) {
+ var d = cm.display
+ if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
+ { return }
+ // Might be a text scaling operation, clear size caches.
+ d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null
+ d.scrollbarsClipped = false
+ cm.setSize()
+}
+
+var keyNames = {
+ 3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
+ 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
+ 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
+ 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
+ 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete",
+ 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
+ 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
+ 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
+}
+
+// Number keys
+for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i) }
+// Alphabetic keys
+for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1) }
+// Function keys
+for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2 }
+
+var keyMap = {}
+
+keyMap.basic = {
+ "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
+ "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
+ "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
+ "Tab": "defaultTab", "Shift-Tab": "indentAuto",
+ "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
+ "Esc": "singleSelection"
+}
+// Note that the save and find-related commands aren't defined by
+// default. User code or addons can define them. Unknown commands
+// are simply ignored.
+keyMap.pcDefault = {
+ "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
+ "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
+ "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
+ "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
+ "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
+ "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
+ "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
+ fallthrough: "basic"
+}
+// Very basic readline/emacs-style bindings, which are standard on Mac.
+keyMap.emacsy = {
+ "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
+ "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
+ "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
+ "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
+ "Ctrl-O": "openLine"
+}
+keyMap.macDefault = {
+ "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
+ "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
+ "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
+ "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
+ "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
+ "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
+ "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
+ fallthrough: ["basic", "emacsy"]
+}
+keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault
+
+// KEYMAP DISPATCH
+
+function normalizeKeyName(name) {
+ var parts = name.split(/-(?!$)/)
+ name = parts[parts.length - 1]
+ var alt, ctrl, shift, cmd
+ for (var i = 0; i < parts.length - 1; i++) {
+ var mod = parts[i]
+ if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true }
+ else if (/^a(lt)?$/i.test(mod)) { alt = true }
+ else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true }
+ else if (/^s(hift)?$/i.test(mod)) { shift = true }
+ else { throw new Error("Unrecognized modifier name: " + mod) }
+ }
+ if (alt) { name = "Alt-" + name }
+ if (ctrl) { name = "Ctrl-" + name }
+ if (cmd) { name = "Cmd-" + name }
+ if (shift) { name = "Shift-" + name }
+ return name
+}
+
+// This is a kludge to keep keymaps mostly working as raw objects
+// (backwards compatibility) while at the same time support features
+// like normalization and multi-stroke key bindings. It compiles a
+// new normalized keymap, and then updates the old object to reflect
+// this.
+function normalizeKeyMap(keymap) {
+ var copy = {}
+ for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) {
+ var value = keymap[keyname]
+ if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue }
+ if (value == "...") { delete keymap[keyname]; continue }
+
+ var keys = map(keyname.split(" "), normalizeKeyName)
+ for (var i = 0; i < keys.length; i++) {
+ var val = (void 0), name = (void 0)
+ if (i == keys.length - 1) {
+ name = keys.join(" ")
+ val = value
+ } else {
+ name = keys.slice(0, i + 1).join(" ")
+ val = "..."
+ }
+ var prev = copy[name]
+ if (!prev) { copy[name] = val }
+ else if (prev != val) { throw new Error("Inconsistent bindings for " + name) }
}
+ delete keymap[keyname]
+ } }
+ for (var prop in copy) { keymap[prop] = copy[prop] }
+ return keymap
+}
- // Turn mouse into crosshair when Alt is held on Mac.
- if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
- showCrossHair(cm);
- }
-
- function showCrossHair(cm) {
- var lineDiv = cm.display.lineDiv;
- addClass(lineDiv, "CodeMirror-crosshair");
+function lookupKey(key, map, handle, context) {
+ map = getKeyMap(map)
+ var found = map.call ? map.call(key, context) : map[key]
+ if (found === false) { return "nothing" }
+ if (found === "...") { return "multi" }
+ if (found != null && handle(found)) { return "handled" }
- function up(e) {
- if (e.keyCode == 18 || !e.altKey) {
- rmClass(lineDiv, "CodeMirror-crosshair");
- off(document, "keyup", up);
- off(document, "mouseover", up);
- }
+ if (map.fallthrough) {
+ if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")
+ { return lookupKey(key, map.fallthrough, handle, context) }
+ for (var i = 0; i < map.fallthrough.length; i++) {
+ var result = lookupKey(key, map.fallthrough[i], handle, context)
+ if (result) { return result }
}
- on(document, "keyup", up);
- on(document, "mouseover", up);
}
+}
- function onKeyUp(e) {
- if (e.keyCode == 16) this.doc.sel.shift = false;
- signalDOMEvent(this, e);
- }
+// Modifier key presses don't count as 'real' key presses for the
+// purpose of keymap fallthrough.
+function isModifierKey(value) {
+ var name = typeof value == "string" ? value : keyNames[value.keyCode]
+ return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"
+}
- function onKeyPress(e) {
- var cm = this;
- if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return;
- var keyCode = e.keyCode, charCode = e.charCode;
- if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
- if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) return;
- var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
- if (handleCharBinding(cm, e, ch)) return;
- cm.display.input.onKeyPress(e);
- }
+// Look up the name of a key as indicated by an event object.
+function keyName(event, noShift) {
+ if (presto && event.keyCode == 34 && event["char"]) { return false }
+ var base = keyNames[event.keyCode], name = base
+ if (name == null || event.altGraphKey) { return false }
+ if (event.altKey && base != "Alt") { name = "Alt-" + name }
+ if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name }
+ if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") { name = "Cmd-" + name }
+ if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name }
+ return name
+}
- // FOCUS/BLUR EVENTS
+function getKeyMap(val) {
+ return typeof val == "string" ? keyMap[val] : val
+}
- function delayBlurEvent(cm) {
- cm.state.delayingBlurEvent = true;
- setTimeout(function() {
- if (cm.state.delayingBlurEvent) {
- cm.state.delayingBlurEvent = false;
- onBlur(cm);
+// Helper for deleting text near the selection(s), used to implement
+// backspace, delete, and similar functionality.
+function deleteNearSelection(cm, compute) {
+ var ranges = cm.doc.sel.ranges, kill = []
+ // Build up a set of ranges to kill first, merging overlapping
+ // ranges.
+ for (var i = 0; i < ranges.length; i++) {
+ var toKill = compute(ranges[i])
+ while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
+ var replaced = kill.pop()
+ if (cmp(replaced.from, toKill.from) < 0) {
+ toKill.from = replaced.from
+ break
+ }
+ }
+ kill.push(toKill)
+ }
+ // Next, remove those actual ranges.
+ runInOp(cm, function () {
+ for (var i = kill.length - 1; i >= 0; i--)
+ { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete") }
+ ensureCursorVisible(cm)
+ })
+}
+
+// Commands are parameter-less actions that can be performed on an
+// editor, mostly used for keybindings.
+var commands = {
+ selectAll: selectAll,
+ singleSelection: function (cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); },
+ killLine: function (cm) { return deleteNearSelection(cm, function (range) {
+ if (range.empty()) {
+ var len = getLine(cm.doc, range.head.line).text.length
+ if (range.head.ch == len && range.head.line < cm.lastLine())
+ { return {from: range.head, to: Pos(range.head.line + 1, 0)} }
+ else
+ { return {from: range.head, to: Pos(range.head.line, len)} }
+ } else {
+ return {from: range.from(), to: range.to()}
+ }
+ }); },
+ deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({
+ from: Pos(range.from().line, 0),
+ to: clipPos(cm.doc, Pos(range.to().line + 1, 0))
+ }); }); },
+ delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({
+ from: Pos(range.from().line, 0), to: range.from()
+ }); }); },
+ delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) {
+ var top = cm.charCoords(range.head, "div").top + 5
+ var leftPos = cm.coordsChar({left: 0, top: top}, "div")
+ return {from: leftPos, to: range.from()}
+ }); },
+ delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) {
+ var top = cm.charCoords(range.head, "div").top + 5
+ var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
+ return {from: range.from(), to: rightPos }
+ }); },
+ undo: function (cm) { return cm.undo(); },
+ redo: function (cm) { return cm.redo(); },
+ undoSelection: function (cm) { return cm.undoSelection(); },
+ redoSelection: function (cm) { return cm.redoSelection(); },
+ goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); },
+ goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); },
+ goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); },
+ {origin: "+move", bias: 1}
+ ); },
+ goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); },
+ {origin: "+move", bias: 1}
+ ); },
+ goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); },
+ {origin: "+move", bias: -1}
+ ); },
+ goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) {
+ var top = cm.charCoords(range.head, "div").top + 5
+ return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
+ }, sel_move); },
+ goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) {
+ var top = cm.charCoords(range.head, "div").top + 5
+ return cm.coordsChar({left: 0, top: top}, "div")
+ }, sel_move); },
+ goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) {
+ var top = cm.charCoords(range.head, "div").top + 5
+ var pos = cm.coordsChar({left: 0, top: top}, "div")
+ if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head) }
+ return pos
+ }, sel_move); },
+ goLineUp: function (cm) { return cm.moveV(-1, "line"); },
+ goLineDown: function (cm) { return cm.moveV(1, "line"); },
+ goPageUp: function (cm) { return cm.moveV(-1, "page"); },
+ goPageDown: function (cm) { return cm.moveV(1, "page"); },
+ goCharLeft: function (cm) { return cm.moveH(-1, "char"); },
+ goCharRight: function (cm) { return cm.moveH(1, "char"); },
+ goColumnLeft: function (cm) { return cm.moveH(-1, "column"); },
+ goColumnRight: function (cm) { return cm.moveH(1, "column"); },
+ goWordLeft: function (cm) { return cm.moveH(-1, "word"); },
+ goGroupRight: function (cm) { return cm.moveH(1, "group"); },
+ goGroupLeft: function (cm) { return cm.moveH(-1, "group"); },
+ goWordRight: function (cm) { return cm.moveH(1, "word"); },
+ delCharBefore: function (cm) { return cm.deleteH(-1, "char"); },
+ delCharAfter: function (cm) { return cm.deleteH(1, "char"); },
+ delWordBefore: function (cm) { return cm.deleteH(-1, "word"); },
+ delWordAfter: function (cm) { return cm.deleteH(1, "word"); },
+ delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); },
+ delGroupAfter: function (cm) { return cm.deleteH(1, "group"); },
+ indentAuto: function (cm) { return cm.indentSelection("smart"); },
+ indentMore: function (cm) { return cm.indentSelection("add"); },
+ indentLess: function (cm) { return cm.indentSelection("subtract"); },
+ insertTab: function (cm) { return cm.replaceSelection("\t"); },
+ insertSoftTab: function (cm) {
+ var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize
+ for (var i = 0; i < ranges.length; i++) {
+ var pos = ranges[i].from()
+ var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize)
+ spaces.push(spaceStr(tabSize - col % tabSize))
+ }
+ cm.replaceSelections(spaces)
+ },
+ defaultTab: function (cm) {
+ if (cm.somethingSelected()) { cm.indentSelection("add") }
+ else { cm.execCommand("insertTab") }
+ },
+ // Swap the two chars left and right of each selection's head.
+ // Move cursor behind the two swapped characters afterwards.
+ //
+ // Doesn't consider line feeds a character.
+ // Doesn't scan more than one line above to find a character.
+ // Doesn't do anything on an empty line.
+ // Doesn't do anything with non-empty selections.
+ transposeChars: function (cm) { return runInOp(cm, function () {
+ var ranges = cm.listSelections(), newSel = []
+ for (var i = 0; i < ranges.length; i++) {
+ if (!ranges[i].empty()) { continue }
+ var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text
+ if (line) {
+ if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1) }
+ if (cur.ch > 0) {
+ cur = new Pos(cur.line, cur.ch + 1)
+ cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
+ Pos(cur.line, cur.ch - 2), cur, "+transpose")
+ } else if (cur.line > cm.doc.first) {
+ var prev = getLine(cm.doc, cur.line - 1).text
+ if (prev) {
+ cur = new Pos(cur.line, 1)
+ cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
+ prev.charAt(prev.length - 1),
+ Pos(cur.line - 1, prev.length - 1), cur, "+transpose")
+ }
+ }
}
- }, 100);
+ newSel.push(new Range(cur, cur))
+ }
+ cm.setSelections(newSel)
+ }); },
+ newlineAndIndent: function (cm) { return runInOp(cm, function () {
+ var sels = cm.listSelections()
+ for (var i = sels.length - 1; i >= 0; i--)
+ { cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input") }
+ sels = cm.listSelections()
+ for (var i$1 = 0; i$1 < sels.length; i$1++)
+ { cm.indentLine(sels[i$1].from().line, null, true) }
+ ensureCursorVisible(cm)
+ }); },
+ openLine: function (cm) { return cm.replaceSelection("\n", "start"); },
+ toggleOverwrite: function (cm) { return cm.toggleOverwrite(); }
+}
+
+
+function lineStart(cm, lineN) {
+ var line = getLine(cm.doc, lineN)
+ var visual = visualLine(line)
+ if (visual != line) { lineN = lineNo(visual) }
+ return endOfLine(true, cm, visual, lineN, 1)
+}
+function lineEnd(cm, lineN) {
+ var line = getLine(cm.doc, lineN)
+ var visual = visualLineEnd(line)
+ if (visual != line) { lineN = lineNo(visual) }
+ return endOfLine(true, cm, line, lineN, -1)
+}
+function lineStartSmart(cm, pos) {
+ var start = lineStart(cm, pos.line)
+ var line = getLine(cm.doc, start.line)
+ var order = getOrder(line)
+ if (!order || order[0].level == 0) {
+ var firstNonWS = Math.max(0, line.text.search(/\S/))
+ var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch
+ return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
+ }
+ return start
+}
+
+// Run a handler that was bound to a key.
+function doHandleBinding(cm, bound, dropShift) {
+ if (typeof bound == "string") {
+ bound = commands[bound]
+ if (!bound) { return false }
+ }
+ // Ensure previous input has been read, so that the handler sees a
+ // consistent view of the document
+ cm.display.input.ensurePolled()
+ var prevShift = cm.display.shift, done = false
+ try {
+ if (cm.isReadOnly()) { cm.state.suppressEdits = true }
+ if (dropShift) { cm.display.shift = false }
+ done = bound(cm) != Pass
+ } finally {
+ cm.display.shift = prevShift
+ cm.state.suppressEdits = false
}
+ return done
+}
- function onFocus(cm) {
- if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false;
-
- if (cm.options.readOnly == "nocursor") return;
- if (!cm.state.focused) {
- signal(cm, "focus", cm);
- cm.state.focused = true;
- addClass(cm.display.wrapper, "CodeMirror-focused");
- // This test prevents this from firing when a context
- // menu is closed (since the input reset would kill the
- // select-all detection hack)
- if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
- cm.display.input.reset();
- if (webkit) setTimeout(function() { cm.display.input.reset(true); }, 20); // Issue #1730
- }
- cm.display.input.receivedFocus();
- }
- restartBlink(cm);
+function lookupKeyForEditor(cm, name, handle) {
+ for (var i = 0; i < cm.state.keyMaps.length; i++) {
+ var result = lookupKey(name, cm.state.keyMaps[i], handle, cm)
+ if (result) { return result }
}
- function onBlur(cm) {
- if (cm.state.delayingBlurEvent) return;
+ return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
+ || lookupKey(name, cm.options.keyMap, handle, cm)
+}
- if (cm.state.focused) {
- signal(cm, "blur", cm);
- cm.state.focused = false;
- rmClass(cm.display.wrapper, "CodeMirror-focused");
- }
- clearInterval(cm.display.blinker);
- setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150);
+var stopSeq = new Delayed
+function dispatchKey(cm, name, e, handle) {
+ var seq = cm.state.keySeq
+ if (seq) {
+ if (isModifierKey(name)) { return "handled" }
+ stopSeq.set(50, function () {
+ if (cm.state.keySeq == seq) {
+ cm.state.keySeq = null
+ cm.display.input.reset()
+ }
+ })
+ name = seq + " " + name
}
+ var result = lookupKeyForEditor(cm, name, handle)
- // CONTEXT MENU HANDLING
-
- // To make the context menu work, we need to briefly unhide the
- // textarea (making it as unobtrusive as possible) to let the
- // right-click take effect on it.
- function onContextMenu(cm, e) {
- if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return;
- if (signalDOMEvent(cm, e, "contextmenu")) return;
- cm.display.input.onContextMenu(e);
- }
+ if (result == "multi")
+ { cm.state.keySeq = name }
+ if (result == "handled")
+ { signalLater(cm, "keyHandled", cm, name, e) }
- function contextMenuInGutter(cm, e) {
- if (!hasHandler(cm, "gutterContextMenu")) return false;
- return gutterEvent(cm, e, "gutterContextMenu", false);
+ if (result == "handled" || result == "multi") {
+ e_preventDefault(e)
+ restartBlink(cm)
}
- // UPDATING
-
- // Compute the position of the end of a change (its 'to' property
- // refers to the pre-change end).
- var changeEnd = CodeMirror.changeEnd = function(change) {
- if (!change.text) return change.to;
- return Pos(change.from.line + change.text.length - 1,
- lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0));
- };
-
- // Adjust a position to refer to the post-change position of the
- // same text, or the end of the change if the change covers it.
- function adjustForChange(pos, change) {
- if (cmp(pos, change.from) < 0) return pos;
- if (cmp(pos, change.to) <= 0) return changeEnd(change);
-
- var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
- if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch;
- return Pos(line, ch);
+ if (seq && !result && /\'$/.test(name)) {
+ e_preventDefault(e)
+ return true
}
+ return !!result
+}
- function computeSelAfterChange(doc, change) {
- var out = [];
- for (var i = 0; i < doc.sel.ranges.length; i++) {
- var range = doc.sel.ranges[i];
- out.push(new Range(adjustForChange(range.anchor, change),
- adjustForChange(range.head, change)));
- }
- return normalizeSelection(out, doc.sel.primIndex);
- }
+// Handle a key from the keydown event.
+function handleKeyBinding(cm, e) {
+ var name = keyName(e, true)
+ if (!name) { return false }
- function offsetPos(pos, old, nw) {
- if (pos.line == old.line)
- return Pos(nw.line, pos.ch - old.ch + nw.ch);
+ if (e.shiftKey && !cm.state.keySeq) {
+ // First try to resolve full name (including 'Shift-'). Failing
+ // that, see if there is a cursor-motion command (starting with
+ // 'go') bound to the keyname without 'Shift-'.
+ return dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); })
+ || dispatchKey(cm, name, e, function (b) {
+ if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
+ { return doHandleBinding(cm, b) }
+ })
+ } else {
+ return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); })
+ }
+}
+
+// Handle a key from the keypress event
+function handleCharBinding(cm, e, ch) {
+ return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); })
+}
+
+var lastStoppedKey = null
+function onKeyDown(e) {
+ var cm = this
+ cm.curOp.focus = activeElt()
+ if (signalDOMEvent(cm, e)) { return }
+ // IE does strange things with escape.
+ if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false }
+ var code = e.keyCode
+ cm.display.shift = code == 16 || e.shiftKey
+ var handled = handleKeyBinding(cm, e)
+ if (presto) {
+ lastStoppedKey = handled ? code : null
+ // Opera has no cut event... we try to at least catch the key combo
+ if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
+ { cm.replaceSelection("", null, "cut") }
+ }
+
+ // Turn mouse into crosshair when Alt is held on Mac.
+ if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
+ { showCrossHair(cm) }
+}
+
+function showCrossHair(cm) {
+ var lineDiv = cm.display.lineDiv
+ addClass(lineDiv, "CodeMirror-crosshair")
+
+ function up(e) {
+ if (e.keyCode == 18 || !e.altKey) {
+ rmClass(lineDiv, "CodeMirror-crosshair")
+ off(document, "keyup", up)
+ off(document, "mouseover", up)
+ }
+ }
+ on(document, "keyup", up)
+ on(document, "mouseover", up)
+}
+
+function onKeyUp(e) {
+ if (e.keyCode == 16) { this.doc.sel.shift = false }
+ signalDOMEvent(this, e)
+}
+
+function onKeyPress(e) {
+ var cm = this
+ if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }
+ var keyCode = e.keyCode, charCode = e.charCode
+ if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}
+ if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return }
+ var ch = String.fromCharCode(charCode == null ? keyCode : charCode)
+ // Some browsers fire keypress events for backspace
+ if (ch == "\x08") { return }
+ if (handleCharBinding(cm, e, ch)) { return }
+ cm.display.input.onKeyPress(e)
+}
+
+// A mouse down can be a single click, double click, triple click,
+// start of selection drag, start of text drag, new cursor
+// (ctrl-click), rectangle drag (alt-drag), or xwin
+// middle-click-paste. Or it might be a click on something we should
+// not interfere with, such as a scrollbar or widget.
+function onMouseDown(e) {
+ var cm = this, display = cm.display
+ if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }
+ display.input.ensurePolled()
+ display.shift = e.shiftKey
+
+ if (eventInWidget(display, e)) {
+ if (!webkit) {
+ // Briefly turn off draggability, to allow widgets to do
+ // normal dragging things.
+ display.scroller.draggable = false
+ setTimeout(function () { return display.scroller.draggable = true; }, 100)
+ }
+ return
+ }
+ if (clickInGutter(cm, e)) { return }
+ var start = posFromMouse(cm, e)
+ window.focus()
+
+ switch (e_button(e)) {
+ case 1:
+ // #3261: make sure, that we're not starting a second selection
+ if (cm.state.selectingText)
+ { cm.state.selectingText(e) }
+ else if (start)
+ { leftButtonDown(cm, e, start) }
+ else if (e_target(e) == display.scroller)
+ { e_preventDefault(e) }
+ break
+ case 2:
+ if (webkit) { cm.state.lastMiddleDown = +new Date }
+ if (start) { extendSelection(cm.doc, start) }
+ setTimeout(function () { return display.input.focus(); }, 20)
+ e_preventDefault(e)
+ break
+ case 3:
+ if (captureRightClick) { onContextMenu(cm, e) }
+ else { delayBlurEvent(cm) }
+ break
+ }
+}
+
+var lastClick;
+var lastDoubleClick;
+function leftButtonDown(cm, e, start) {
+ if (ie) { setTimeout(bind(ensureFocus, cm), 0) }
+ else { cm.curOp.focus = activeElt() }
+
+ var now = +new Date, type
+ if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
+ type = "triple"
+ } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
+ type = "double"
+ lastDoubleClick = {time: now, pos: start}
+ } else {
+ type = "single"
+ lastClick = {time: now, pos: start}
+ }
+
+ var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained
+ if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
+ type == "single" && (contained = sel.contains(start)) > -1 &&
+ (cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
+ (cmp(contained.to(), start) > 0 || start.xRel < 0))
+ { leftButtonStartDrag(cm, e, start, modifier) }
+ else
+ { leftButtonSelect(cm, e, start, type, modifier) }
+}
+
+// Start a text drag. When it ends, see if any dragging actually
+// happen, and treat as a click if it didn't.
+function leftButtonStartDrag(cm, e, start, modifier) {
+ var display = cm.display, startTime = +new Date
+ var dragEnd = operation(cm, function (e2) {
+ if (webkit) { display.scroller.draggable = false }
+ cm.state.draggingText = false
+ off(document, "mouseup", dragEnd)
+ off(display.scroller, "drop", dragEnd)
+ if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
+ e_preventDefault(e2)
+ if (!modifier && +new Date - 200 < startTime)
+ { extendSelection(cm.doc, start) }
+ // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
+ if (webkit || ie && ie_version == 9)
+ { setTimeout(function () {document.body.focus(); display.input.focus()}, 20) }
+ else
+ { display.input.focus() }
+ }
+ })
+ // Let the drag handler handle this.
+ if (webkit) { display.scroller.draggable = true }
+ cm.state.draggingText = dragEnd
+ dragEnd.copy = mac ? e.altKey : e.ctrlKey
+ // IE's approach to draggable
+ if (display.scroller.dragDrop) { display.scroller.dragDrop() }
+ on(document, "mouseup", dragEnd)
+ on(display.scroller, "drop", dragEnd)
+}
+
+// Normal selection, as opposed to text dragging.
+function leftButtonSelect(cm, e, start, type, addNew) {
+ var display = cm.display, doc = cm.doc
+ e_preventDefault(e)
+
+ var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges
+ if (addNew && !e.shiftKey) {
+ ourIndex = doc.sel.contains(start)
+ if (ourIndex > -1)
+ { ourRange = ranges[ourIndex] }
else
- return Pos(nw.line + (pos.line - old.line), pos.ch);
- }
-
- // Used by replaceSelections to allow moving the selection to the
- // start or around the replaced test. Hint may be "start" or "around".
- function computeReplacedSel(doc, changes, hint) {
- var out = [];
- var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
- for (var i = 0; i < changes.length; i++) {
- var change = changes[i];
- var from = offsetPos(change.from, oldPrev, newPrev);
- var to = offsetPos(changeEnd(change), oldPrev, newPrev);
- oldPrev = change.to;
- newPrev = to;
- if (hint == "around") {
- var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
- out[i] = new Range(inv ? to : from, inv ? from : to);
- } else {
- out[i] = new Range(from, from);
+ { ourRange = new Range(start, start) }
+ } else {
+ ourRange = doc.sel.primary()
+ ourIndex = doc.sel.primIndex
+ }
+
+ if (chromeOS ? e.shiftKey && e.metaKey : e.altKey) {
+ type = "rect"
+ if (!addNew) { ourRange = new Range(start, start) }
+ start = posFromMouse(cm, e, true, true)
+ ourIndex = -1
+ } else if (type == "double") {
+ var word = cm.findWordAt(start)
+ if (cm.display.shift || doc.extend)
+ { ourRange = extendRange(doc, ourRange, word.anchor, word.head) }
+ else
+ { ourRange = word }
+ } else if (type == "triple") {
+ var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)))
+ if (cm.display.shift || doc.extend)
+ { ourRange = extendRange(doc, ourRange, line.anchor, line.head) }
+ else
+ { ourRange = line }
+ } else {
+ ourRange = extendRange(doc, ourRange, start)
+ }
+
+ if (!addNew) {
+ ourIndex = 0
+ setSelection(doc, new Selection([ourRange], 0), sel_mouse)
+ startSel = doc.sel
+ } else if (ourIndex == -1) {
+ ourIndex = ranges.length
+ setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
+ {scroll: false, origin: "*mouse"})
+ } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
+ setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
+ {scroll: false, origin: "*mouse"})
+ startSel = doc.sel
+ } else {
+ replaceOneSelection(doc, ourIndex, ourRange, sel_mouse)
+ }
+
+ var lastPos = start
+ function extendTo(pos) {
+ if (cmp(lastPos, pos) == 0) { return }
+ lastPos = pos
+
+ if (type == "rect") {
+ var ranges = [], tabSize = cm.options.tabSize
+ var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize)
+ var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize)
+ var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol)
+ for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
+ line <= end; line++) {
+ var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize)
+ if (left == right)
+ { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))) }
+ else if (text.length > leftPos)
+ { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))) }
+ }
+ if (!ranges.length) { ranges.push(new Range(start, start)) }
+ setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
+ {origin: "*mouse", scroll: false})
+ cm.scrollIntoView(pos)
+ } else {
+ var oldRange = ourRange
+ var anchor = oldRange.anchor, head = pos
+ if (type != "single") {
+ var range
+ if (type == "double")
+ { range = cm.findWordAt(pos) }
+ else
+ { range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))) }
+ if (cmp(range.anchor, anchor) > 0) {
+ head = range.head
+ anchor = minPos(oldRange.from(), range.anchor)
+ } else {
+ head = range.anchor
+ anchor = maxPos(oldRange.to(), range.head)
+ }
}
+ var ranges$1 = startSel.ranges.slice(0)
+ ranges$1[ourIndex] = new Range(clipPos(doc, anchor), head)
+ setSelection(doc, normalizeSelection(ranges$1, ourIndex), sel_mouse)
}
- return new Selection(out, doc.sel.primIndex);
- }
-
- // Allow "beforeChange" event handlers to influence a change
- function filterChange(doc, change, update) {
- var obj = {
- canceled: false,
- from: change.from,
- to: change.to,
- text: change.text,
- origin: change.origin,
- cancel: function() { this.canceled = true; }
- };
- if (update) obj.update = function(from, to, text, origin) {
- if (from) this.from = clipPos(doc, from);
- if (to) this.to = clipPos(doc, to);
- if (text) this.text = text;
- if (origin !== undefined) this.origin = origin;
- };
- signal(doc, "beforeChange", doc, obj);
- if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj);
-
- if (obj.canceled) return null;
- return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin};
}
- // Apply a change to a document, and add it to the document's
- // history, and propagating it to all linked documents.
- function makeChange(doc, change, ignoreReadOnly) {
- if (doc.cm) {
- if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly);
- if (doc.cm.state.suppressEdits) return;
- }
-
- if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
- change = filterChange(doc, change, true);
- if (!change) return;
- }
+ var editorSize = display.wrapper.getBoundingClientRect()
+ // Used to ensure timeout re-tries don't fire when another extend
+ // happened in the meantime (clearTimeout isn't reliable -- at
+ // least on Chrome, the timeouts still happen even when cleared,
+ // if the clear happens after their scheduled firing time).
+ var counter = 0
- // Possibly split or suppress the update based on the presence
- // of read-only spans in its range.
- var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
- if (split) {
- for (var i = split.length - 1; i >= 0; --i)
- makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text});
+ function extend(e) {
+ var curCount = ++counter
+ var cur = posFromMouse(cm, e, true, type == "rect")
+ if (!cur) { return }
+ if (cmp(cur, lastPos) != 0) {
+ cm.curOp.focus = activeElt()
+ extendTo(cur)
+ var visible = visibleLines(display, doc)
+ if (cur.line >= visible.to || cur.line < visible.from)
+ { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e) }}), 150) }
} else {
- makeChangeInner(doc, change);
+ var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0
+ if (outside) { setTimeout(operation(cm, function () {
+ if (counter != curCount) { return }
+ display.scroller.scrollTop += outside
+ extend(e)
+ }), 50) }
}
}
- function makeChangeInner(doc, change) {
- if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return;
- var selAfter = computeSelAfterChange(doc, change);
- addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
-
- makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
- var rebased = [];
-
- linkedDocs(doc, function(doc, sharedHist) {
- if (!sharedHist && indexOf(rebased, doc.history) == -1) {
- rebaseHist(doc.history, change);
- rebased.push(doc.history);
- }
- makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
- });
+ function done(e) {
+ cm.state.selectingText = false
+ counter = Infinity
+ e_preventDefault(e)
+ display.input.focus()
+ off(document, "mousemove", move)
+ off(document, "mouseup", up)
+ doc.history.lastSelOrigin = null
}
- // Revert a change stored in a document's history.
- function makeChangeFromHistory(doc, type, allowSelectionOnly) {
- if (doc.cm && doc.cm.state.suppressEdits) return;
-
- var hist = doc.history, event, selAfter = doc.sel;
- var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
-
- // Verify that there is a useable event (so that ctrl-z won't
- // needlessly clear selection events)
- for (var i = 0; i < source.length; i++) {
- event = source[i];
- if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
- break;
- }
- if (i == source.length) return;
- hist.lastOrigin = hist.lastSelOrigin = null;
-
- for (;;) {
- event = source.pop();
- if (event.ranges) {
- pushSelectionToHistory(event, dest);
- if (allowSelectionOnly && !event.equals(doc.sel)) {
- setSelection(doc, event, {clearRedo: false});
- return;
- }
- selAfter = event;
- }
- else break;
- }
-
- // Build up a reverse change object to add to the opposite history
- // stack (redo when undoing, and vice versa).
- var antiChanges = [];
- pushSelectionToHistory(selAfter, dest);
- dest.push({changes: antiChanges, generation: hist.generation});
- hist.generation = event.generation || ++hist.maxGeneration;
+ var move = operation(cm, function (e) {
+ if (!e_button(e)) { done(e) }
+ else { extend(e) }
+ })
+ var up = operation(cm, done)
+ cm.state.selectingText = up
+ on(document, "mousemove", move)
+ on(document, "mouseup", up)
+}
- var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
- for (var i = event.changes.length - 1; i >= 0; --i) {
- var change = event.changes[i];
- change.origin = type;
- if (filter && !filterChange(doc, change, false)) {
- source.length = 0;
- return;
- }
+// Determines whether an event happened in the gutter, and fires the
+// handlers for the corresponding event.
+function gutterEvent(cm, e, type, prevent) {
+ var mX, mY
+ try { mX = e.clientX; mY = e.clientY }
+ catch(e) { return false }
+ if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }
+ if (prevent) { e_preventDefault(e) }
- antiChanges.push(historyChangeFromChange(doc, change));
+ var display = cm.display
+ var lineBox = display.lineDiv.getBoundingClientRect()
- var after = i ? computeSelAfterChange(doc, change) : lst(source);
- makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
- if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)});
- var rebased = [];
+ if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) }
+ mY -= lineBox.top - display.viewOffset
- // Propagate to the linked documents
- linkedDocs(doc, function(doc, sharedHist) {
- if (!sharedHist && indexOf(rebased, doc.history) == -1) {
- rebaseHist(doc.history, change);
- rebased.push(doc.history);
- }
- makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
- });
+ for (var i = 0; i < cm.options.gutters.length; ++i) {
+ var g = display.gutters.childNodes[i]
+ if (g && g.getBoundingClientRect().right >= mX) {
+ var line = lineAtHeight(cm.doc, mY)
+ var gutter = cm.options.gutters[i]
+ signal(cm, type, cm, line, gutter, e)
+ return e_defaultPrevented(e)
}
}
+}
- // Sub-views need their line numbers shifted when text is added
- // above or below them in the parent document.
- function shiftDoc(doc, distance) {
- if (distance == 0) return;
- doc.first += distance;
- doc.sel = new Selection(map(doc.sel.ranges, function(range) {
- return new Range(Pos(range.anchor.line + distance, range.anchor.ch),
- Pos(range.head.line + distance, range.head.ch));
- }), doc.sel.primIndex);
- if (doc.cm) {
- regChange(doc.cm, doc.first, doc.first - distance, distance);
- for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
- regLineChange(doc.cm, l, "gutter");
- }
- }
+function clickInGutter(cm, e) {
+ return gutterEvent(cm, e, "gutterClick", true)
+}
- // More lower-level change function, handling only a single document
- // (not linked ones).
- function makeChangeSingleDoc(doc, change, selAfter, spans) {
- if (doc.cm && !doc.cm.curOp)
- return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans);
+// CONTEXT MENU HANDLING
- if (change.to.line < doc.first) {
- shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
- return;
- }
- if (change.from.line > doc.lastLine()) return;
+// To make the context menu work, we need to briefly unhide the
+// textarea (making it as unobtrusive as possible) to let the
+// right-click take effect on it.
+function onContextMenu(cm, e) {
+ if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return }
+ if (signalDOMEvent(cm, e, "contextmenu")) { return }
+ cm.display.input.onContextMenu(e)
+}
- // Clip the change to the size of this doc
- if (change.from.line < doc.first) {
- var shift = change.text.length - 1 - (doc.first - change.from.line);
- shiftDoc(doc, shift);
- change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
- text: [lst(change.text)], origin: change.origin};
- }
- var last = doc.lastLine();
- if (change.to.line > last) {
- change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
- text: [change.text[0]], origin: change.origin};
- }
+function contextMenuInGutter(cm, e) {
+ if (!hasHandler(cm, "gutterContextMenu")) { return false }
+ return gutterEvent(cm, e, "gutterContextMenu", false)
+}
- change.removed = getBetween(doc, change.from, change.to);
+function themeChanged(cm) {
+ cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
+ cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-")
+ clearCaches(cm)
+}
- if (!selAfter) selAfter = computeSelAfterChange(doc, change);
- if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans);
- else updateDoc(doc, change, spans);
- setSelectionNoUndo(doc, selAfter, sel_dontScroll);
- }
+var Init = {toString: function(){return "CodeMirror.Init"}}
- // Handle the interaction of a change to a document with the editor
- // that this document is part of.
- function makeChangeSingleDocInEditor(cm, change, spans) {
- var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
+var defaults = {}
+var optionHandlers = {}
- var recomputeMaxLength = false, checkWidthStart = from.line;
- if (!cm.options.lineWrapping) {
- checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
- doc.iter(checkWidthStart, to.line + 1, function(line) {
- if (line == display.maxLine) {
- recomputeMaxLength = true;
- return true;
- }
- });
- }
+function defineOptions(CodeMirror) {
+ var optionHandlers = CodeMirror.optionHandlers
- if (doc.sel.contains(change.from, change.to) > -1)
- signalCursorActivity(cm);
+ function option(name, deflt, handle, notOnInit) {
+ CodeMirror.defaults[name] = deflt
+ if (handle) { optionHandlers[name] =
+ notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old) }} : handle }
+ }
- updateDoc(doc, change, spans, estimateHeight(cm));
+ CodeMirror.defineOption = option
- if (!cm.options.lineWrapping) {
- doc.iter(checkWidthStart, from.line + change.text.length, function(line) {
- var len = lineLength(line);
- if (len > display.maxLineLength) {
- display.maxLine = line;
- display.maxLineLength = len;
- display.maxLineChanged = true;
- recomputeMaxLength = false;
- }
- });
- if (recomputeMaxLength) cm.curOp.updateMaxLine = true;
+ // Passed to option handlers when there is no old value.
+ CodeMirror.Init = Init
+
+ // These two are, on init, called from the constructor because they
+ // have to be initialized before the editor can start at all.
+ option("value", "", function (cm, val) { return cm.setValue(val); }, true)
+ option("mode", null, function (cm, val) {
+ cm.doc.modeOption = val
+ loadMode(cm)
+ }, true)
+
+ option("indentUnit", 2, loadMode, true)
+ option("indentWithTabs", false)
+ option("smartIndent", true)
+ option("tabSize", 4, function (cm) {
+ resetModeState(cm)
+ clearCaches(cm)
+ regChange(cm)
+ }, true)
+ option("lineSeparator", null, function (cm, val) {
+ cm.doc.lineSep = val
+ if (!val) { return }
+ var newBreaks = [], lineNo = cm.doc.first
+ cm.doc.iter(function (line) {
+ for (var pos = 0;;) {
+ var found = line.text.indexOf(val, pos)
+ if (found == -1) { break }
+ pos = found + val.length
+ newBreaks.push(Pos(lineNo, found))
+ }
+ lineNo++
+ })
+ for (var i = newBreaks.length - 1; i >= 0; i--)
+ { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)) }
+ })
+ option("specialChars", /[\u0000-\u001f\u007f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g, function (cm, val, old) {
+ cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g")
+ if (old != Init) { cm.refresh() }
+ })
+ option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true)
+ option("electricChars", true)
+ option("inputStyle", mobile ? "contenteditable" : "textarea", function () {
+ throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME
+ }, true)
+ option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true)
+ option("rtlMoveVisually", !windows)
+ option("wholeLineUpdateBefore", true)
+
+ option("theme", "default", function (cm) {
+ themeChanged(cm)
+ guttersChanged(cm)
+ }, true)
+ option("keyMap", "default", function (cm, val, old) {
+ var next = getKeyMap(val)
+ var prev = old != Init && getKeyMap(old)
+ if (prev && prev.detach) { prev.detach(cm, next) }
+ if (next.attach) { next.attach(cm, prev || null) }
+ })
+ option("extraKeys", null)
+
+ option("lineWrapping", false, wrappingChanged, true)
+ option("gutters", [], function (cm) {
+ setGuttersForLineNumbers(cm.options)
+ guttersChanged(cm)
+ }, true)
+ option("fixedGutter", true, function (cm, val) {
+ cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"
+ cm.refresh()
+ }, true)
+ option("coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true)
+ option("scrollbarStyle", "native", function (cm) {
+ initScrollbars(cm)
+ updateScrollbars(cm)
+ cm.display.scrollbars.setScrollTop(cm.doc.scrollTop)
+ cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft)
+ }, true)
+ option("lineNumbers", false, function (cm) {
+ setGuttersForLineNumbers(cm.options)
+ guttersChanged(cm)
+ }, true)
+ option("firstLineNumber", 1, guttersChanged, true)
+ option("lineNumberFormatter", function (integer) { return integer; }, guttersChanged, true)
+ option("showCursorWhenSelecting", false, updateSelection, true)
+
+ option("resetSelectionOnContextMenu", true)
+ option("lineWiseCopyCut", true)
+
+ option("readOnly", false, function (cm, val) {
+ if (val == "nocursor") {
+ onBlur(cm)
+ cm.display.input.blur()
+ cm.display.disabled = true
+ } else {
+ cm.display.disabled = false
}
+ cm.display.input.readOnlyChanged(val)
+ })
+ option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset() }}, true)
+ option("dragDrop", true, dragDropChanged)
+ option("allowDropFileTypes", null)
+
+ option("cursorBlinkRate", 530)
+ option("cursorScrollMargin", 0)
+ option("cursorHeight", 1, updateSelection, true)
+ option("singleCursorHeightPerLine", true, updateSelection, true)
+ option("workTime", 100)
+ option("workDelay", 100)
+ option("flattenSpans", true, resetModeState, true)
+ option("addModeClass", false, resetModeState, true)
+ option("pollInterval", 100)
+ option("undoDepth", 200, function (cm, val) { return cm.doc.history.undoDepth = val; })
+ option("historyEventDelay", 1250)
+ option("viewportMargin", 10, function (cm) { return cm.refresh(); }, true)
+ option("maxHighlightLength", 10000, resetModeState, true)
+ option("moveInputWithCursor", true, function (cm, val) {
+ if (!val) { cm.display.input.resetPosition() }
+ })
+
+ option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; })
+ option("autofocus", null)
+}
+
+function guttersChanged(cm) {
+ updateGutters(cm)
+ regChange(cm)
+ alignHorizontally(cm)
+}
+
+function dragDropChanged(cm, value, old) {
+ var wasOn = old && old != Init
+ if (!value != !wasOn) {
+ var funcs = cm.display.dragFunctions
+ var toggle = value ? on : off
+ toggle(cm.display.scroller, "dragstart", funcs.start)
+ toggle(cm.display.scroller, "dragenter", funcs.enter)
+ toggle(cm.display.scroller, "dragover", funcs.over)
+ toggle(cm.display.scroller, "dragleave", funcs.leave)
+ toggle(cm.display.scroller, "drop", funcs.drop)
+ }
+}
+
+function wrappingChanged(cm) {
+ if (cm.options.lineWrapping) {
+ addClass(cm.display.wrapper, "CodeMirror-wrap")
+ cm.display.sizer.style.minWidth = ""
+ cm.display.sizerWidth = null
+ } else {
+ rmClass(cm.display.wrapper, "CodeMirror-wrap")
+ findMaxLine(cm)
+ }
+ estimateLineHeights(cm)
+ regChange(cm)
+ clearCaches(cm)
+ setTimeout(function () { return updateScrollbars(cm); }, 100)
+}
+
+// A CodeMirror instance represents an editor. This is the object
+// that user code is usually dealing with.
+
+function CodeMirror(place, options) {
+ var this$1 = this;
+
+ if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) }
+
+ this.options = options = options ? copyObj(options) : {}
+ // Determine effective options based on given values and defaults.
+ copyObj(defaults, options, false)
+ setGuttersForLineNumbers(options)
+
+ var doc = options.value
+ if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator) }
+ this.doc = doc
+
+ var input = new CodeMirror.inputStyles[options.inputStyle](this)
+ var display = this.display = new Display(place, doc, input)
+ display.wrapper.CodeMirror = this
+ updateGutters(this)
+ themeChanged(this)
+ if (options.lineWrapping)
+ { this.display.wrapper.className += " CodeMirror-wrap" }
+ initScrollbars(this)
+
+ this.state = {
+ keyMaps: [], // stores maps added by addKeyMap
+ overlays: [], // highlighting overlays, as added by addOverlay
+ modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
+ overwrite: false,
+ delayingBlurEvent: false,
+ focused: false,
+ suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
+ pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
+ selectingText: false,
+ draggingText: false,
+ highlight: new Delayed(), // stores highlight worker timeout
+ keySeq: null, // Unfinished key sequence
+ specialChars: null
+ }
+
+ if (options.autofocus && !mobile) { display.input.focus() }
+
+ // Override magic textarea content restore that IE sometimes does
+ // on our hidden textarea on reload
+ if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20) }
+
+ registerEventHandlers(this)
+ ensureGlobalHandlers()
+
+ startOperation(this)
+ this.curOp.forceUpdate = true
+ attachDoc(this, doc)
+
+ if ((options.autofocus && !mobile) || this.hasFocus())
+ { setTimeout(bind(onFocus, this), 20) }
+ else
+ { onBlur(this) }
+
+ for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt))
+ { optionHandlers[opt](this$1, options[opt], Init) } }
+ maybeUpdateLineNumberWidth(this)
+ if (options.finishInit) { options.finishInit(this) }
+ for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this$1) }
+ endOperation(this)
+ // Suppress optimizelegibility in Webkit, since it breaks text
+ // measuring on line wrapping boundaries.
+ if (webkit && options.lineWrapping &&
+ getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
+ { display.lineDiv.style.textRendering = "auto" }
+}
+
+// The default configuration options.
+CodeMirror.defaults = defaults
+// Functions to run when options are changed.
+CodeMirror.optionHandlers = optionHandlers
+
+// Attach the necessary event handlers when initializing the editor
+function registerEventHandlers(cm) {
+ var d = cm.display
+ on(d.scroller, "mousedown", operation(cm, onMouseDown))
+ // Older IE's will not fire a second mousedown for a double click
+ if (ie && ie_version < 11)
+ { on(d.scroller, "dblclick", operation(cm, function (e) {
+ if (signalDOMEvent(cm, e)) { return }
+ var pos = posFromMouse(cm, e)
+ if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return }
+ e_preventDefault(e)
+ var word = cm.findWordAt(pos)
+ extendSelection(cm.doc, word.anchor, word.head)
+ })) }
+ else
+ { on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }) }
+ // Some browsers fire contextmenu *after* opening the menu, at
+ // which point we can't mess with it anymore. Context menu is
+ // handled in onMouseDown for these browsers.
+ if (!captureRightClick) { on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); }) }
+
+ // Used to suppress mouse event handling when a touch happens
+ var touchFinished, prevTouch = {end: 0}
+ function finishTouch() {
+ if (d.activeTouch) {
+ touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000)
+ prevTouch = d.activeTouch
+ prevTouch.end = +new Date
+ }
+ }
+ function isMouseLikeTouchEvent(e) {
+ if (e.touches.length != 1) { return false }
+ var touch = e.touches[0]
+ return touch.radiusX <= 1 && touch.radiusY <= 1
+ }
+ function farAway(touch, other) {
+ if (other.left == null) { return true }
+ var dx = other.left - touch.left, dy = other.top - touch.top
+ return dx * dx + dy * dy > 20 * 20
+ }
+ on(d.scroller, "touchstart", function (e) {
+ if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e)) {
+ d.input.ensurePolled()
+ clearTimeout(touchFinished)
+ var now = +new Date
+ d.activeTouch = {start: now, moved: false,
+ prev: now - prevTouch.end <= 300 ? prevTouch : null}
+ if (e.touches.length == 1) {
+ d.activeTouch.left = e.touches[0].pageX
+ d.activeTouch.top = e.touches[0].pageY
+ }
+ }
+ })
+ on(d.scroller, "touchmove", function () {
+ if (d.activeTouch) { d.activeTouch.moved = true }
+ })
+ on(d.scroller, "touchend", function (e) {
+ var touch = d.activeTouch
+ if (touch && !eventInWidget(d, e) && touch.left != null &&
+ !touch.moved && new Date - touch.start < 300) {
+ var pos = cm.coordsChar(d.activeTouch, "page"), range
+ if (!touch.prev || farAway(touch, touch.prev)) // Single tap
+ { range = new Range(pos, pos) }
+ else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
+ { range = cm.findWordAt(pos) }
+ else // Triple tap
+ { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) }
+ cm.setSelection(range.anchor, range.head)
+ cm.focus()
+ e_preventDefault(e)
+ }
+ finishTouch()
+ })
+ on(d.scroller, "touchcancel", finishTouch)
+
+ // Sync scrolling between fake scrollbars and real scrollable
+ // area, ensure viewport is updated when scrolling.
+ on(d.scroller, "scroll", function () {
+ if (d.scroller.clientHeight) {
+ setScrollTop(cm, d.scroller.scrollTop)
+ setScrollLeft(cm, d.scroller.scrollLeft, true)
+ signal(cm, "scroll", cm)
+ }
+ })
+
+ // Listen to wheel events in order to try and update the viewport on time.
+ on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); })
+ on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); })
+
+ // Prevent wrapper from ever scrolling
+ on(d.wrapper, "scroll", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; })
+
+ d.dragFunctions = {
+ enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e) }},
+ over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e) }},
+ start: function (e) { return onDragStart(cm, e); },
+ drop: operation(cm, onDrop),
+ leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm) }}
+ }
+
+ var inp = d.input.getField()
+ on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); })
+ on(inp, "keydown", operation(cm, onKeyDown))
+ on(inp, "keypress", operation(cm, onKeyPress))
+ on(inp, "focus", function (e) { return onFocus(cm, e); })
+ on(inp, "blur", function (e) { return onBlur(cm, e); })
+}
+
+var initHooks = []
+CodeMirror.defineInitHook = function (f) { return initHooks.push(f); }
+
+// Indent the given line. The how parameter can be "smart",
+// "add"/null, "subtract", or "prev". When aggressive is false
+// (typically set to true for forced single-line indents), empty
+// lines are not indented, and places where the mode returns Pass
+// are left alone.
+function indentLine(cm, n, how, aggressive) {
+ var doc = cm.doc, state
+ if (how == null) { how = "add" }
+ if (how == "smart") {
+ // Fall back to "prev" when the mode doesn't have an indentation
+ // method.
+ if (!doc.mode.indent) { how = "prev" }
+ else { state = getStateBefore(cm, n) }
+ }
+
+ var tabSize = cm.options.tabSize
+ var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize)
+ if (line.stateAfter) { line.stateAfter = null }
+ var curSpaceString = line.text.match(/^\s*/)[0], indentation
+ if (!aggressive && !/\S/.test(line.text)) {
+ indentation = 0
+ how = "not"
+ } else if (how == "smart") {
+ indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text)
+ if (indentation == Pass || indentation > 150) {
+ if (!aggressive) { return }
+ how = "prev"
+ }
+ }
+ if (how == "prev") {
+ if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize) }
+ else { indentation = 0 }
+ } else if (how == "add") {
+ indentation = curSpace + cm.options.indentUnit
+ } else if (how == "subtract") {
+ indentation = curSpace - cm.options.indentUnit
+ } else if (typeof how == "number") {
+ indentation = curSpace + how
+ }
+ indentation = Math.max(0, indentation)
+
+ var indentString = "", pos = 0
+ if (cm.options.indentWithTabs)
+ { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t"} }
+ if (pos < indentation) { indentString += spaceStr(indentation - pos) }
+
+ if (indentString != curSpaceString) {
+ replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input")
+ line.stateAfter = null
+ return true
+ } else {
+ // Ensure that, if the cursor was in the whitespace at the start
+ // of the line, it is moved to the end of that space.
+ for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) {
+ var range = doc.sel.ranges[i$1]
+ if (range.head.line == n && range.head.ch < curSpaceString.length) {
+ var pos$1 = Pos(n, curSpaceString.length)
+ replaceOneSelection(doc, i$1, new Range(pos$1, pos$1))
+ break
+ }
+ }
+ }
+}
+
+// This will be set to a {lineWise: bool, text: [string]} object, so
+// that, when pasting, we know what kind of selections the copied
+// text was made out of.
+var lastCopied = null
- // Adjust frontier, schedule worker
- doc.frontier = Math.min(doc.frontier, from.line);
- startWorker(cm, 400);
+function setLastCopied(newLastCopied) {
+ lastCopied = newLastCopied
+}
- var lendiff = change.text.length - (to.line - from.line) - 1;
- // Remember that these lines changed, for updating the display
- if (change.full)
- regChange(cm);
- else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
- regLineChange(cm, from.line, "text");
- else
- regChange(cm, from.line, to.line + 1, lendiff);
-
- var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
- if (changeHandler || changesHandler) {
- var obj = {
- from: from, to: to,
- text: change.text,
- removed: change.removed,
- origin: change.origin
- };
- if (changeHandler) signalLater(cm, "change", cm, obj);
- if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj);
- }
- cm.display.selForContextMenu = null;
- }
-
- function replaceRange(doc, code, from, to, origin) {
- if (!to) to = from;
- if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; }
- if (typeof code == "string") code = doc.splitLines(code);
- makeChange(doc, {from: from, to: to, text: code, origin: origin});
- }
-
- // SCROLLING THINGS INTO VIEW
-
- // If an editor sits on the top or bottom of the window, partially
- // scrolled out of view, this ensures that the cursor is visible.
- function maybeScrollWindow(cm, coords) {
- if (signalDOMEvent(cm, "scrollCursorIntoView")) return;
-
- var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
- if (coords.top + box.top < 0) doScroll = true;
- else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false;
- if (doScroll != null && !phantom) {
- var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " +
- (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " +
- (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " +
- coords.left + "px; width: 2px;");
- cm.display.lineSpace.appendChild(scrollNode);
- scrollNode.scrollIntoView(doScroll);
- cm.display.lineSpace.removeChild(scrollNode);
- }
- }
-
- // Scroll a given position into view (immediately), verifying that
- // it actually became visible (as line heights are accurately
- // measured, the position of something may 'drift' during drawing).
- function scrollPosIntoView(cm, pos, end, margin) {
- if (margin == null) margin = 0;
- for (var limit = 0; limit < 5; limit++) {
- var changed = false, coords = cursorCoords(cm, pos);
- var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
- var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
- Math.min(coords.top, endCoords.top) - margin,
- Math.max(coords.left, endCoords.left),
- Math.max(coords.bottom, endCoords.bottom) + margin);
- var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
- if (scrollPos.scrollTop != null) {
- setScrollTop(cm, scrollPos.scrollTop);
- if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true;
- }
- if (scrollPos.scrollLeft != null) {
- setScrollLeft(cm, scrollPos.scrollLeft);
- if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true;
- }
- if (!changed) break;
- }
- return coords;
- }
-
- // Scroll a given set of coordinates into view (immediately).
- function scrollIntoView(cm, x1, y1, x2, y2) {
- var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2);
- if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop);
- if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft);
- }
-
- // Calculate a new scroll position needed to scroll the given
- // rectangle into view. Returns an object with scrollTop and
- // scrollLeft properties. When these are undefined, the
- // vertical/horizontal position does not need to be adjusted.
- function calculateScrollPos(cm, x1, y1, x2, y2) {
- var display = cm.display, snapMargin = textHeight(cm.display);
- if (y1 < 0) y1 = 0;
- var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
- var screen = displayHeight(cm), result = {};
- if (y2 - y1 > screen) y2 = y1 + screen;
- var docBottom = cm.doc.height + paddingVert(display);
- var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin;
- if (y1 < screentop) {
- result.scrollTop = atTop ? 0 : y1;
- } else if (y2 > screentop + screen) {
- var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen);
- if (newTop != screentop) result.scrollTop = newTop;
- }
-
- var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
- var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
- var tooWide = x2 - x1 > screenw;
- if (tooWide) x2 = x1 + screenw;
- if (x1 < 10)
- result.scrollLeft = 0;
- else if (x1 < screenleft)
- result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10));
- else if (x2 > screenw + screenleft - 3)
- result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw;
- return result;
- }
+function applyTextInput(cm, inserted, deleted, sel, origin) {
+ var doc = cm.doc
+ cm.display.shift = false
+ if (!sel) { sel = doc.sel }
- // Store a relative adjustment to the scroll position in the current
- // operation (to be applied when the operation finishes).
- function addToScrollPos(cm, left, top) {
- if (left != null || top != null) resolveScrollToPos(cm);
- if (left != null)
- cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left;
- if (top != null)
- cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
- }
-
- // Make sure that at the end of the operation the current cursor is
- // shown.
- function ensureCursorVisible(cm) {
- resolveScrollToPos(cm);
- var cur = cm.getCursor(), from = cur, to = cur;
- if (!cm.options.lineWrapping) {
- from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur;
- to = Pos(cur.line, cur.ch + 1);
- }
- cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true};
- }
-
- // When an operation has its scrollToPos property set, and another
- // scroll action is applied before the end of the operation, this
- // 'simulates' scrolling that position into view in a cheap way, so
- // that the effect of intermediate scroll commands is not ignored.
- function resolveScrollToPos(cm) {
- var range = cm.curOp.scrollToPos;
- if (range) {
- cm.curOp.scrollToPos = null;
- var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to);
- var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),
- Math.min(from.top, to.top) - range.margin,
- Math.max(from.right, to.right),
- Math.max(from.bottom, to.bottom) + range.margin);
- cm.scrollTo(sPos.scrollLeft, sPos.scrollTop);
- }
- }
-
- // API UTILITIES
-
- // Indent the given line. The how parameter can be "smart",
- // "add"/null, "subtract", or "prev". When aggressive is false
- // (typically set to true for forced single-line indents), empty
- // lines are not indented, and places where the mode returns Pass
- // are left alone.
- function indentLine(cm, n, how, aggressive) {
- var doc = cm.doc, state;
- if (how == null) how = "add";
- if (how == "smart") {
- // Fall back to "prev" when the mode doesn't have an indentation
- // method.
- if (!doc.mode.indent) how = "prev";
- else state = getStateBefore(cm, n);
- }
-
- var tabSize = cm.options.tabSize;
- var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
- if (line.stateAfter) line.stateAfter = null;
- var curSpaceString = line.text.match(/^\s*/)[0], indentation;
- if (!aggressive && !/\S/.test(line.text)) {
- indentation = 0;
- how = "not";
- } else if (how == "smart") {
- indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
- if (indentation == Pass || indentation > 150) {
- if (!aggressive) return;
- how = "prev";
- }
- }
- if (how == "prev") {
- if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize);
- else indentation = 0;
- } else if (how == "add") {
- indentation = curSpace + cm.options.indentUnit;
- } else if (how == "subtract") {
- indentation = curSpace - cm.options.indentUnit;
- } else if (typeof how == "number") {
- indentation = curSpace + how;
- }
- indentation = Math.max(0, indentation);
-
- var indentString = "", pos = 0;
- if (cm.options.indentWithTabs)
- for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
- if (pos < indentation) indentString += spaceStr(indentation - pos);
-
- if (indentString != curSpaceString) {
- replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
- line.stateAfter = null;
- return true;
- } else {
- // Ensure that, if the cursor was in the whitespace at the start
- // of the line, it is moved to the end of that space.
- for (var i = 0; i < doc.sel.ranges.length; i++) {
- var range = doc.sel.ranges[i];
- if (range.head.line == n && range.head.ch < curSpaceString.length) {
- var pos = Pos(n, curSpaceString.length);
- replaceOneSelection(doc, i, new Range(pos, pos));
- break;
- }
- }
+ var paste = cm.state.pasteIncoming || origin == "paste"
+ var textLines = splitLinesAuto(inserted), multiPaste = null
+ // When pasing N lines into N selections, insert one line per selection
+ if (paste && sel.ranges.length > 1) {
+ if (lastCopied && lastCopied.text.join("\n") == inserted) {
+ if (sel.ranges.length % lastCopied.text.length == 0) {
+ multiPaste = []
+ for (var i = 0; i < lastCopied.text.length; i++)
+ { multiPaste.push(doc.splitLines(lastCopied.text[i])) }
+ }
+ } else if (textLines.length == sel.ranges.length) {
+ multiPaste = map(textLines, function (l) { return [l]; })
+ }
+ }
+
+ var updateInput
+ // Normal behavior is to insert the new text into every selection
+ for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) {
+ var range = sel.ranges[i$1]
+ var from = range.from(), to = range.to()
+ if (range.empty()) {
+ if (deleted && deleted > 0) // Handle deletion
+ { from = Pos(from.line, from.ch - deleted) }
+ else if (cm.state.overwrite && !paste) // Handle overwrite
+ { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)) }
+ else if (lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
+ { from = to = Pos(from.line, 0) }
}
+ updateInput = cm.curOp.updateInput
+ var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,
+ origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")}
+ makeChange(cm.doc, changeEvent)
+ signalLater(cm, "inputRead", cm, changeEvent)
}
+ if (inserted && !paste)
+ { triggerElectric(cm, inserted) }
- // Utility for applying a change to a line by handle or number,
- // returning the number and optionally registering the line as
- // changed.
- function changeLine(doc, handle, changeType, op) {
- var no = handle, line = handle;
- if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle));
- else no = lineNo(handle);
- if (no == null) return null;
- if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType);
- return line;
- }
+ ensureCursorVisible(cm)
+ cm.curOp.updateInput = updateInput
+ cm.curOp.typing = true
+ cm.state.pasteIncoming = cm.state.cutIncoming = false
+}
- // Helper for deleting text near the selection(s), used to implement
- // backspace, delete, and similar functionality.
- function deleteNearSelection(cm, compute) {
- var ranges = cm.doc.sel.ranges, kill = [];
- // Build up a set of ranges to kill first, merging overlapping
- // ranges.
- for (var i = 0; i < ranges.length; i++) {
- var toKill = compute(ranges[i]);
- while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
- var replaced = kill.pop();
- if (cmp(replaced.from, toKill.from) < 0) {
- toKill.from = replaced.from;
- break;
- }
- }
- kill.push(toKill);
- }
- // Next, remove those actual ranges.
- runInOp(cm, function() {
- for (var i = kill.length - 1; i >= 0; i--)
- replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete");
- ensureCursorVisible(cm);
- });
+function handlePaste(e, cm) {
+ var pasted = e.clipboardData && e.clipboardData.getData("Text")
+ if (pasted) {
+ e.preventDefault()
+ if (!cm.isReadOnly() && !cm.options.disableInput)
+ { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }) }
+ return true
}
+}
- // Used for horizontal relative motion. Dir is -1 or 1 (left or
- // right), unit can be "char", "column" (like char, but doesn't
- // cross line boundaries), "word" (across next word), or "group" (to
- // the start of next group of word or non-word-non-whitespace
- // chars). The visually param controls whether, in right-to-left
- // text, direction 1 means to move towards the next index in the
- // string, or towards the character to the right of the current
- // position. The resulting position will have a hitSide=true
- // property if it reached the end of the document.
- function findPosH(doc, pos, dir, unit, visually) {
- var line = pos.line, ch = pos.ch, origDir = dir;
- var lineObj = getLine(doc, line);
- function findNextLine() {
- var l = line + dir;
- if (l < doc.first || l >= doc.first + doc.size) return false
- line = l;
- return lineObj = getLine(doc, l);
- }
- function moveOnce(boundToLine) {
- var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true);
- if (next == null) {
- if (!boundToLine && findNextLine()) {
- if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj);
- else ch = dir < 0 ? lineObj.text.length : 0;
- } else return false
- } else ch = next;
- return true;
- }
+function triggerElectric(cm, inserted) {
+ // When an 'electric' character is inserted, immediately trigger a reindent
+ if (!cm.options.electricChars || !cm.options.smartIndent) { return }
+ var sel = cm.doc.sel
- if (unit == "char") {
- moveOnce()
- } else if (unit == "column") {
- moveOnce(true)
- } else if (unit == "word" || unit == "group") {
- var sawType = null, group = unit == "group";
- var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
- for (var first = true;; first = false) {
- if (dir < 0 && !moveOnce(!first)) break;
- var cur = lineObj.text.charAt(ch) || "\n";
- var type = isWordChar(cur, helper) ? "w"
- : group && cur == "\n" ? "n"
- : !group || /\s/.test(cur) ? null
- : "p";
- if (group && !first && !type) type = "s";
- if (sawType && sawType != type) {
- if (dir < 0) {dir = 1; moveOnce();}
- break;
- }
-
- if (type) sawType = type;
- if (dir > 0 && !moveOnce(!first)) break;
- }
+ for (var i = sel.ranges.length - 1; i >= 0; i--) {
+ var range = sel.ranges[i]
+ if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) { continue }
+ var mode = cm.getModeAt(range.head)
+ var indented = false
+ if (mode.electricChars) {
+ for (var j = 0; j < mode.electricChars.length; j++)
+ { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
+ indented = indentLine(cm, range.head.line, "smart")
+ break
+ } }
+ } else if (mode.electricInput) {
+ if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
+ { indented = indentLine(cm, range.head.line, "smart") }
}
- var result = skipAtomic(doc, Pos(line, ch), pos, origDir, true);
- if (!cmp(pos, result)) result.hitSide = true;
- return result;
+ if (indented) { signalLater(cm, "electricInput", cm, range.head.line) }
}
+}
- // For relative vertical movement. Dir may be -1 or 1. Unit can be
- // "page" or "line". The resulting position will have a hitSide=true
- // property if it reached the end of the document.
- function findPosV(cm, pos, dir, unit) {
- var doc = cm.doc, x = pos.left, y;
- if (unit == "page") {
- var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
- y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display));
- } else if (unit == "line") {
- y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
- }
- for (;;) {
- var target = coordsChar(cm, x, y);
- if (!target.outside) break;
- if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; }
- y += dir * 5;
- }
- return target;
+function copyableRanges(cm) {
+ var text = [], ranges = []
+ for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
+ var line = cm.doc.sel.ranges[i].head.line
+ var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}
+ ranges.push(lineRange)
+ text.push(cm.getRange(lineRange.anchor, lineRange.head))
}
+ return {text: text, ranges: ranges}
+}
+
+function disableBrowserMagic(field, spellcheck) {
+ field.setAttribute("autocorrect", "off")
+ field.setAttribute("autocapitalize", "off")
+ field.setAttribute("spellcheck", !!spellcheck)
+}
+
+function hiddenTextarea() {
+ var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none")
+ var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;")
+ // The textarea is kept positioned near the cursor to prevent the
+ // fact that it'll be scrolled into view on input from scrolling
+ // our fake cursor out of view. On webkit, when wrap=off, paste is
+ // very slow. So make the area wide instead.
+ if (webkit) { te.style.width = "1000px" }
+ else { te.setAttribute("wrap", "off") }
+ // If border: 0; -- iOS fails to open keyboard (issue #1287)
+ if (ios) { te.style.border = "1px solid black" }
+ disableBrowserMagic(te)
+ return div
+}
- // EDITOR METHODS
-
- // The publicly visible API. Note that methodOp(f) means
- // 'wrap f in an operation, performed on its `this` parameter'.
+// The publicly visible API. Note that methodOp(f) means
+// 'wrap f in an operation, performed on its `this` parameter'.
- // This is not the complete set of editor methods. Most of the
- // methods defined on the Doc type are also injected into
- // CodeMirror.prototype, for backwards compatibility and
- // convenience.
+// This is not the complete set of editor methods. Most of the
+// methods defined on the Doc type are also injected into
+// CodeMirror.prototype, for backwards compatibility and
+// convenience.
+
+function addEditorMethods(CodeMirror) {
+ var optionHandlers = CodeMirror.optionHandlers
+
+ var helpers = CodeMirror.helpers = {}
CodeMirror.prototype = {
constructor: CodeMirror,
- focus: function(){window.focus(); this.display.input.focus();},
+ focus: function(){window.focus(); this.display.input.focus()},
setOption: function(option, value) {
- var options = this.options, old = options[option];
- if (options[option] == value && option != "mode") return;
- options[option] = value;
+ var options = this.options, old = options[option]
+ if (options[option] == value && option != "mode") { return }
+ options[option] = value
if (optionHandlers.hasOwnProperty(option))
- operation(this, optionHandlers[option])(this, value, old);
+ { operation(this, optionHandlers[option])(this, value, old) }
+ signal(this, "optionChange", this, option)
},
- getOption: function(option) {return this.options[option];},
- getDoc: function() {return this.doc;},
+ getOption: function(option) {return this.options[option]},
+ getDoc: function() {return this.doc},
addKeyMap: function(map, bottom) {
- this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map));
+ this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map))
},
removeKeyMap: function(map) {
- var maps = this.state.keyMaps;
+ var maps = this.state.keyMaps
for (var i = 0; i < maps.length; ++i)
- if (maps[i] == map || maps[i].name == map) {
- maps.splice(i, 1);
- return true;
- }
+ { if (maps[i] == map || maps[i].name == map) {
+ maps.splice(i, 1)
+ return true
+ } }
},
addOverlay: methodOp(function(spec, options) {
- var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
- if (mode.startState) throw new Error("Overlays may not be stateful.");
- this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque});
- this.state.modeGen++;
- regChange(this);
+ var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec)
+ if (mode.startState) { throw new Error("Overlays may not be stateful.") }
+ insertSorted(this.state.overlays,
+ {mode: mode, modeSpec: spec, opaque: options && options.opaque,
+ priority: (options && options.priority) || 0},
+ function (overlay) { return overlay.priority; })
+ this.state.modeGen++
+ regChange(this)
}),
removeOverlay: methodOp(function(spec) {
- var overlays = this.state.overlays;
+ var this$1 = this;
+
+ var overlays = this.state.overlays
for (var i = 0; i < overlays.length; ++i) {
- var cur = overlays[i].modeSpec;
+ var cur = overlays[i].modeSpec
if (cur == spec || typeof spec == "string" && cur.name == spec) {
- overlays.splice(i, 1);
- this.state.modeGen++;
- regChange(this);
- return;
+ overlays.splice(i, 1)
+ this$1.state.modeGen++
+ regChange(this$1)
+ return
}
}
}),
indentLine: methodOp(function(n, dir, aggressive) {
if (typeof dir != "string" && typeof dir != "number") {
- if (dir == null) dir = this.options.smartIndent ? "smart" : "prev";
- else dir = dir ? "add" : "subtract";
+ if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev" }
+ else { dir = dir ? "add" : "subtract" }
}
- if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive);
+ if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive) }
}),
indentSelection: methodOp(function(how) {
- var ranges = this.doc.sel.ranges, end = -1;
+ var this$1 = this;
+
+ var ranges = this.doc.sel.ranges, end = -1
for (var i = 0; i < ranges.length; i++) {
- var range = ranges[i];
+ var range = ranges[i]
if (!range.empty()) {
- var from = range.from(), to = range.to();
- var start = Math.max(end, from.line);
- end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
+ var from = range.from(), to = range.to()
+ var start = Math.max(end, from.line)
+ end = Math.min(this$1.lastLine(), to.line - (to.ch ? 0 : 1)) + 1
for (var j = start; j < end; ++j)
- indentLine(this, j, how);
- var newRanges = this.doc.sel.ranges;
+ { indentLine(this$1, j, how) }
+ var newRanges = this$1.doc.sel.ranges
if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
- replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll);
+ { replaceOneSelection(this$1.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll) }
} else if (range.head.line > end) {
- indentLine(this, range.head.line, how, true);
- end = range.head.line;
- if (i == this.doc.sel.primIndex) ensureCursorVisible(this);
+ indentLine(this$1, range.head.line, how, true)
+ end = range.head.line
+ if (i == this$1.doc.sel.primIndex) { ensureCursorVisible(this$1) }
}
}
}),
@@ -4994,178 +7815,144 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof requ
// Fetch the parser token for a given character. Useful for hacks
// that want to inspect the mode state (say, for completion).
getTokenAt: function(pos, precise) {
- return takeToken(this, pos, precise);
+ return takeToken(this, pos, precise)
},
getLineTokens: function(line, precise) {
- return takeToken(this, Pos(line), precise, true);
+ return takeToken(this, Pos(line), precise, true)
},
getTokenTypeAt: function(pos) {
- pos = clipPos(this.doc, pos);
- var styles = getLineStyles(this, getLine(this.doc, pos.line));
- var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
- var type;
- if (ch == 0) type = styles[2];
- else for (;;) {
- var mid = (before + after) >> 1;
- if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid;
- else if (styles[mid * 2 + 1] < ch) before = mid + 1;
- else { type = styles[mid * 2 + 2]; break; }
- }
- var cut = type ? type.indexOf("cm-overlay ") : -1;
- return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1);
+ pos = clipPos(this.doc, pos)
+ var styles = getLineStyles(this, getLine(this.doc, pos.line))
+ var before = 0, after = (styles.length - 1) / 2, ch = pos.ch
+ var type
+ if (ch == 0) { type = styles[2] }
+ else { for (;;) {
+ var mid = (before + after) >> 1
+ if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid }
+ else if (styles[mid * 2 + 1] < ch) { before = mid + 1 }
+ else { type = styles[mid * 2 + 2]; break }
+ } }
+ var cut = type ? type.indexOf("overlay ") : -1
+ return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1)
},
getModeAt: function(pos) {
- var mode = this.doc.mode;
- if (!mode.innerMode) return mode;
- return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode;
+ var mode = this.doc.mode
+ if (!mode.innerMode) { return mode }
+ return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode
},
getHelper: function(pos, type) {
- return this.getHelpers(pos, type)[0];
+ return this.getHelpers(pos, type)[0]
},
getHelpers: function(pos, type) {
- var found = [];
- if (!helpers.hasOwnProperty(type)) return found;
- var help = helpers[type], mode = this.getModeAt(pos);
+ var this$1 = this;
+
+ var found = []
+ if (!helpers.hasOwnProperty(type)) { return found }
+ var help = helpers[type], mode = this.getModeAt(pos)
if (typeof mode[type] == "string") {
- if (help[mode[type]]) found.push(help[mode[type]]);
+ if (help[mode[type]]) { found.push(help[mode[type]]) }
} else if (mode[type]) {
for (var i = 0; i < mode[type].length; i++) {
- var val = help[mode[type][i]];
- if (val) found.push(val);
+ var val = help[mode[type][i]]
+ if (val) { found.push(val) }
}
} else if (mode.helperType && help[mode.helperType]) {
- found.push(help[mode.helperType]);
+ found.push(help[mode.helperType])
} else if (help[mode.name]) {
- found.push(help[mode.name]);
+ found.push(help[mode.name])
}
- for (var i = 0; i < help._global.length; i++) {
- var cur = help._global[i];
- if (cur.pred(mode, this) && indexOf(found, cur.val) == -1)
- found.push(cur.val);
+ for (var i$1 = 0; i$1 < help._global.length; i$1++) {
+ var cur = help._global[i$1]
+ if (cur.pred(mode, this$1) && indexOf(found, cur.val) == -1)
+ { found.push(cur.val) }
}
- return found;
+ return found
},
getStateAfter: function(line, precise) {
- var doc = this.doc;
- line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
- return getStateBefore(this, line + 1, precise);
+ var doc = this.doc
+ line = clipLine(doc, line == null ? doc.first + doc.size - 1: line)
+ return getStateBefore(this, line + 1, precise)
},
cursorCoords: function(start, mode) {
- var pos, range = this.doc.sel.primary();
- if (start == null) pos = range.head;
- else if (typeof start == "object") pos = clipPos(this.doc, start);
- else pos = start ? range.from() : range.to();
- return cursorCoords(this, pos, mode || "page");
+ var pos, range = this.doc.sel.primary()
+ if (start == null) { pos = range.head }
+ else if (typeof start == "object") { pos = clipPos(this.doc, start) }
+ else { pos = start ? range.from() : range.to() }
+ return cursorCoords(this, pos, mode || "page")
},
charCoords: function(pos, mode) {
- return charCoords(this, clipPos(this.doc, pos), mode || "page");
+ return charCoords(this, clipPos(this.doc, pos), mode || "page")
},
coordsChar: function(coords, mode) {
- coords = fromCoordSystem(this, coords, mode || "page");
- return coordsChar(this, coords.left, coords.top);
+ coords = fromCoordSystem(this, coords, mode || "page")
+ return coordsChar(this, coords.left, coords.top)
},
lineAtHeight: function(height, mode) {
- height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
- return lineAtHeight(this.doc, height + this.display.viewOffset);
+ height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top
+ return lineAtHeight(this.doc, height + this.display.viewOffset)
},
- heightAtLine: function(line, mode) {
- var end = false, lineObj;
+ heightAtLine: function(line, mode, includeWidgets) {
+ var end = false, lineObj
if (typeof line == "number") {
- var last = this.doc.first + this.doc.size - 1;
- if (line < this.doc.first) line = this.doc.first;
- else if (line > last) { line = last; end = true; }
- lineObj = getLine(this.doc, line);
+ var last = this.doc.first + this.doc.size - 1
+ if (line < this.doc.first) { line = this.doc.first }
+ else if (line > last) { line = last; end = true }
+ lineObj = getLine(this.doc, line)
} else {
- lineObj = line;
+ lineObj = line
}
- return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top +
- (end ? this.doc.height - heightAtLine(lineObj) : 0);
+ return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top +
+ (end ? this.doc.height - heightAtLine(lineObj) : 0)
},
- defaultTextHeight: function() { return textHeight(this.display); },
- defaultCharWidth: function() { return charWidth(this.display); },
+ defaultTextHeight: function() { return textHeight(this.display) },
+ defaultCharWidth: function() { return charWidth(this.display) },
- setGutterMarker: methodOp(function(line, gutterID, value) {
- return changeLine(this.doc, line, "gutter", function(line) {
- var markers = line.gutterMarkers || (line.gutterMarkers = {});
- markers[gutterID] = value;
- if (!value && isEmpty(markers)) line.gutterMarkers = null;
- return true;
- });
- }),
-
- clearGutter: methodOp(function(gutterID) {
- var cm = this, doc = cm.doc, i = doc.first;
- doc.iter(function(line) {
- if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
- line.gutterMarkers[gutterID] = null;
- regLineChange(cm, i, "gutter");
- if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null;
- }
- ++i;
- });
- }),
-
- lineInfo: function(line) {
- if (typeof line == "number") {
- if (!isLine(this.doc, line)) return null;
- var n = line;
- line = getLine(this.doc, line);
- if (!line) return null;
- } else {
- var n = lineNo(line);
- if (n == null) return null;
- }
- return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
- textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
- widgets: line.widgets};
- },
-
- getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};},
+ getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},
addWidget: function(pos, node, scroll, vert, horiz) {
- var display = this.display;
- pos = cursorCoords(this, clipPos(this.doc, pos));
- var top = pos.bottom, left = pos.left;
- node.style.position = "absolute";
- node.setAttribute("cm-ignore-events", "true");
- this.display.input.setUneditable(node);
- display.sizer.appendChild(node);
+ var display = this.display
+ pos = cursorCoords(this, clipPos(this.doc, pos))
+ var top = pos.bottom, left = pos.left
+ node.style.position = "absolute"
+ node.setAttribute("cm-ignore-events", "true")
+ this.display.input.setUneditable(node)
+ display.sizer.appendChild(node)
if (vert == "over") {
- top = pos.top;
+ top = pos.top
} else if (vert == "above" || vert == "near") {
var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
- hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
+ hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth)
// Default to positioning above (if specified and possible); otherwise default to positioning below
if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
- top = pos.top - node.offsetHeight;
+ { top = pos.top - node.offsetHeight }
else if (pos.bottom + node.offsetHeight <= vspace)
- top = pos.bottom;
+ { top = pos.bottom }
if (left + node.offsetWidth > hspace)
- left = hspace - node.offsetWidth;
+ { left = hspace - node.offsetWidth }
}
- node.style.top = top + "px";
- node.style.left = node.style.right = "";
+ node.style.top = top + "px"
+ node.style.left = node.style.right = ""
if (horiz == "right") {
- left = display.sizer.clientWidth - node.offsetWidth;
- node.style.right = "0px";
+ left = display.sizer.clientWidth - node.offsetWidth
+ node.style.right = "0px"
} else {
- if (horiz == "left") left = 0;
- else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2;
- node.style.left = left + "px";
+ if (horiz == "left") { left = 0 }
+ else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2 }
+ node.style.left = left + "px"
}
if (scroll)
- scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight);
+ { scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight) }
},
triggerOnKeyDown: methodOp(onKeyDown),
@@ -5174,3768 +7961,2492 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof requ
execCommand: function(cmd) {
if (commands.hasOwnProperty(cmd))
- return commands[cmd].call(null, this);
+ { return commands[cmd].call(null, this) }
},
- triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),
+ triggerElectric: methodOp(function(text) { triggerElectric(this, text) }),
findPosH: function(from, amount, unit, visually) {
- var dir = 1;
- if (amount < 0) { dir = -1; amount = -amount; }
- for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
- cur = findPosH(this.doc, cur, dir, unit, visually);
- if (cur.hitSide) break;
+ var this$1 = this;
+
+ var dir = 1
+ if (amount < 0) { dir = -1; amount = -amount }
+ var cur = clipPos(this.doc, from)
+ for (var i = 0; i < amount; ++i) {
+ cur = findPosH(this$1.doc, cur, dir, unit, visually)
+ if (cur.hitSide) { break }
}
- return cur;
+ return cur
},
moveH: methodOp(function(dir, unit) {
- var cm = this;
- cm.extendSelectionsBy(function(range) {
- if (cm.display.shift || cm.doc.extend || range.empty())
- return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually);
+ var this$1 = this;
+
+ this.extendSelectionsBy(function (range) {
+ if (this$1.display.shift || this$1.doc.extend || range.empty())
+ { return findPosH(this$1.doc, range.head, dir, unit, this$1.options.rtlMoveVisually) }
else
- return dir < 0 ? range.from() : range.to();
- }, sel_move);
+ { return dir < 0 ? range.from() : range.to() }
+ }, sel_move)
}),
deleteH: methodOp(function(dir, unit) {
- var sel = this.doc.sel, doc = this.doc;
+ var sel = this.doc.sel, doc = this.doc
if (sel.somethingSelected())
- doc.replaceSelection("", null, "+delete");
+ { doc.replaceSelection("", null, "+delete") }
else
- deleteNearSelection(this, function(range) {
- var other = findPosH(doc, range.head, dir, unit, false);
- return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other};
- });
+ { deleteNearSelection(this, function (range) {
+ var other = findPosH(doc, range.head, dir, unit, false)
+ return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other}
+ }) }
}),
findPosV: function(from, amount, unit, goalColumn) {
- var dir = 1, x = goalColumn;
- if (amount < 0) { dir = -1; amount = -amount; }
- for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) {
- var coords = cursorCoords(this, cur, "div");
- if (x == null) x = coords.left;
- else coords.left = x;
- cur = findPosV(this, coords, dir, unit);
- if (cur.hitSide) break;
- }
- return cur;
+ var this$1 = this;
+
+ var dir = 1, x = goalColumn
+ if (amount < 0) { dir = -1; amount = -amount }
+ var cur = clipPos(this.doc, from)
+ for (var i = 0; i < amount; ++i) {
+ var coords = cursorCoords(this$1, cur, "div")
+ if (x == null) { x = coords.left }
+ else { coords.left = x }
+ cur = findPosV(this$1, coords, dir, unit)
+ if (cur.hitSide) { break }
+ }
+ return cur
},
moveV: methodOp(function(dir, unit) {
- var cm = this, doc = this.doc, goals = [];
- var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected();
- doc.extendSelectionsBy(function(range) {
+ var this$1 = this;
+
+ var doc = this.doc, goals = []
+ var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected()
+ doc.extendSelectionsBy(function (range) {
if (collapse)
- return dir < 0 ? range.from() : range.to();
- var headPos = cursorCoords(cm, range.head, "div");
- if (range.goalColumn != null) headPos.left = range.goalColumn;
- goals.push(headPos.left);
- var pos = findPosV(cm, headPos, dir, unit);
+ { return dir < 0 ? range.from() : range.to() }
+ var headPos = cursorCoords(this$1, range.head, "div")
+ if (range.goalColumn != null) { headPos.left = range.goalColumn }
+ goals.push(headPos.left)
+ var pos = findPosV(this$1, headPos, dir, unit)
if (unit == "page" && range == doc.sel.primary())
- addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top);
- return pos;
- }, sel_move);
- if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++)
- doc.sel.ranges[i].goalColumn = goals[i];
+ { addToScrollPos(this$1, null, charCoords(this$1, pos, "div").top - headPos.top) }
+ return pos
+ }, sel_move)
+ if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++)
+ { doc.sel.ranges[i].goalColumn = goals[i] } }
}),
// Find the word at the given position (as returned by coordsChar).
findWordAt: function(pos) {
- var doc = this.doc, line = getLine(doc, pos.line).text;
- var start = pos.ch, end = pos.ch;
+ var doc = this.doc, line = getLine(doc, pos.line).text
+ var start = pos.ch, end = pos.ch
if (line) {
- var helper = this.getHelper(pos, "wordChars");
- if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end;
- var startChar = line.charAt(start);
+ var helper = this.getHelper(pos, "wordChars")
+ if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end }
+ var startChar = line.charAt(start)
var check = isWordChar(startChar, helper)
- ? function(ch) { return isWordChar(ch, helper); }
- : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);}
- : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);};
- while (start > 0 && check(line.charAt(start - 1))) --start;
- while (end < line.length && check(line.charAt(end))) ++end;
+ ? function (ch) { return isWordChar(ch, helper); }
+ : /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); }
+ : function (ch) { return (!/\s/.test(ch) && !isWordChar(ch)); }
+ while (start > 0 && check(line.charAt(start - 1))) { --start }
+ while (end < line.length && check(line.charAt(end))) { ++end }
}
- return new Range(Pos(pos.line, start), Pos(pos.line, end));
+ return new Range(Pos(pos.line, start), Pos(pos.line, end))
},
toggleOverwrite: function(value) {
- if (value != null && value == this.state.overwrite) return;
+ if (value != null && value == this.state.overwrite) { return }
if (this.state.overwrite = !this.state.overwrite)
- addClass(this.display.cursorDiv, "CodeMirror-overwrite");
+ { addClass(this.display.cursorDiv, "CodeMirror-overwrite") }
else
- rmClass(this.display.cursorDiv, "CodeMirror-overwrite");
+ { rmClass(this.display.cursorDiv, "CodeMirror-overwrite") }
- signal(this, "overwriteToggle", this, this.state.overwrite);
+ signal(this, "overwriteToggle", this, this.state.overwrite)
},
- hasFocus: function() { return this.display.input.getField() == activeElt(); },
- isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit); },
+ hasFocus: function() { return this.display.input.getField() == activeElt() },
+ isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
scrollTo: methodOp(function(x, y) {
- if (x != null || y != null) resolveScrollToPos(this);
- if (x != null) this.curOp.scrollLeft = x;
- if (y != null) this.curOp.scrollTop = y;
+ if (x != null || y != null) { resolveScrollToPos(this) }
+ if (x != null) { this.curOp.scrollLeft = x }
+ if (y != null) { this.curOp.scrollTop = y }
}),
getScrollInfo: function() {
- var scroller = this.display.scroller;
+ var scroller = this.display.scroller
return {left: scroller.scrollLeft, top: scroller.scrollTop,
height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
- clientHeight: displayHeight(this), clientWidth: displayWidth(this)};
+ clientHeight: displayHeight(this), clientWidth: displayWidth(this)}
},
scrollIntoView: methodOp(function(range, margin) {
if (range == null) {
- range = {from: this.doc.sel.primary().head, to: null};
- if (margin == null) margin = this.options.cursorScrollMargin;
+ range = {from: this.doc.sel.primary().head, to: null}
+ if (margin == null) { margin = this.options.cursorScrollMargin }
} else if (typeof range == "number") {
- range = {from: Pos(range, 0), to: null};
+ range = {from: Pos(range, 0), to: null}
} else if (range.from == null) {
- range = {from: range, to: null};
+ range = {from: range, to: null}
}
- if (!range.to) range.to = range.from;
- range.margin = margin || 0;
+ if (!range.to) { range.to = range.from }
+ range.margin = margin || 0
if (range.from.line != null) {
- resolveScrollToPos(this);
- this.curOp.scrollToPos = range;
+ resolveScrollToPos(this)
+ this.curOp.scrollToPos = range
} else {
var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left),
Math.min(range.from.top, range.to.top) - range.margin,
Math.max(range.from.right, range.to.right),
- Math.max(range.from.bottom, range.to.bottom) + range.margin);
- this.scrollTo(sPos.scrollLeft, sPos.scrollTop);
+ Math.max(range.from.bottom, range.to.bottom) + range.margin)
+ this.scrollTo(sPos.scrollLeft, sPos.scrollTop)
}
}),
setSize: methodOp(function(width, height) {
- var cm = this;
- function interpret(val) {
- return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val;
- }
- if (width != null) cm.display.wrapper.style.width = interpret(width);
- if (height != null) cm.display.wrapper.style.height = interpret(height);
- if (cm.options.lineWrapping) clearLineMeasurementCache(this);
- var lineNo = cm.display.viewFrom;
- cm.doc.iter(lineNo, cm.display.viewTo, function(line) {
- if (line.widgets) for (var i = 0; i < line.widgets.length; i++)
- if (line.widgets[i].noHScroll) { regLineChange(cm, lineNo, "widget"); break; }
- ++lineNo;
- });
- cm.curOp.forceUpdate = true;
- signal(cm, "refresh", this);
+ var this$1 = this;
+
+ var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; }
+ if (width != null) { this.display.wrapper.style.width = interpret(width) }
+ if (height != null) { this.display.wrapper.style.height = interpret(height) }
+ if (this.options.lineWrapping) { clearLineMeasurementCache(this) }
+ var lineNo = this.display.viewFrom
+ this.doc.iter(lineNo, this.display.viewTo, function (line) {
+ if (line.widgets) { for (var i = 0; i < line.widgets.length; i++)
+ { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo, "widget"); break } } }
+ ++lineNo
+ })
+ this.curOp.forceUpdate = true
+ signal(this, "refresh", this)
}),
- operation: function(f){return runInOp(this, f);},
+ operation: function(f){return runInOp(this, f)},
refresh: methodOp(function() {
- var oldHeight = this.display.cachedTextHeight;
- regChange(this);
- this.curOp.forceUpdate = true;
- clearCaches(this);
- this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop);
- updateGutterSpace(this);
+ var oldHeight = this.display.cachedTextHeight
+ regChange(this)
+ this.curOp.forceUpdate = true
+ clearCaches(this)
+ this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop)
+ updateGutterSpace(this)
if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
- estimateLineHeights(this);
- signal(this, "refresh", this);
+ { estimateLineHeights(this) }
+ signal(this, "refresh", this)
}),
swapDoc: methodOp(function(doc) {
- var old = this.doc;
- old.cm = null;
- attachDoc(this, doc);
- clearCaches(this);
- this.display.input.reset();
- this.scrollTo(doc.scrollLeft, doc.scrollTop);
- this.curOp.forceScroll = true;
- signalLater(this, "swapDoc", this, old);
- return old;
+ var old = this.doc
+ old.cm = null
+ attachDoc(this, doc)
+ clearCaches(this)
+ this.display.input.reset()
+ this.scrollTo(doc.scrollLeft, doc.scrollTop)
+ this.curOp.forceScroll = true
+ signalLater(this, "swapDoc", this, old)
+ return old
}),
- getInputField: function(){return this.display.input.getField();},
- getWrapperElement: function(){return this.display.wrapper;},
- getScrollerElement: function(){return this.display.scroller;},
- getGutterElement: function(){return this.display.gutters;}
- };
- eventMixin(CodeMirror);
+ getInputField: function(){return this.display.input.getField()},
+ getWrapperElement: function(){return this.display.wrapper},
+ getScrollerElement: function(){return this.display.scroller},
+ getGutterElement: function(){return this.display.gutters}
+ }
+ eventMixin(CodeMirror)
- // OPTION DEFAULTS
+ CodeMirror.registerHelper = function(type, name, value) {
+ if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []} }
+ helpers[type][name] = value
+ }
+ CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
+ CodeMirror.registerHelper(type, name, value)
+ helpers[type]._global.push({pred: predicate, val: value})
+ }
+}
+
+// Used for horizontal relative motion. Dir is -1 or 1 (left or
+// right), unit can be "char", "column" (like char, but doesn't
+// cross line boundaries), "word" (across next word), or "group" (to
+// the start of next group of word or non-word-non-whitespace
+// chars). The visually param controls whether, in right-to-left
+// text, direction 1 means to move towards the next index in the
+// string, or towards the character to the right of the current
+// position. The resulting position will have a hitSide=true
+// property if it reached the end of the document.
+function findPosH(doc, pos, dir, unit, visually) {
+ var oldPos = pos
+ var origDir = dir
+ var lineObj = getLine(doc, pos.line)
+ function findNextLine() {
+ var l = pos.line + dir
+ if (l < doc.first || l >= doc.first + doc.size) { return false }
+ pos = new Pos(l, pos.ch, pos.sticky)
+ return lineObj = getLine(doc, l)
+ }
+ function moveOnce(boundToLine) {
+ var next
+ if (visually) {
+ next = moveVisually(doc.cm, lineObj, pos, dir)
+ } else {
+ next = moveLogically(lineObj, pos, dir)
+ }
+ if (next == null) {
+ if (!boundToLine && findNextLine())
+ { pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir) }
+ else
+ { return false }
+ } else {
+ pos = next
+ }
+ return true
+ }
- // The default configuration options.
- var defaults = CodeMirror.defaults = {};
- // Functions to run when options are changed.
- var optionHandlers = CodeMirror.optionHandlers = {};
+ if (unit == "char") {
+ moveOnce()
+ } else if (unit == "column") {
+ moveOnce(true)
+ } else if (unit == "word" || unit == "group") {
+ var sawType = null, group = unit == "group"
+ var helper = doc.cm && doc.cm.getHelper(pos, "wordChars")
+ for (var first = true;; first = false) {
+ if (dir < 0 && !moveOnce(!first)) { break }
+ var cur = lineObj.text.charAt(pos.ch) || "\n"
+ var type = isWordChar(cur, helper) ? "w"
+ : group && cur == "\n" ? "n"
+ : !group || /\s/.test(cur) ? null
+ : "p"
+ if (group && !first && !type) { type = "s" }
+ if (sawType && sawType != type) {
+ if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after"}
+ break
+ }
+
+ if (type) { sawType = type }
+ if (dir > 0 && !moveOnce(!first)) { break }
+ }
+ }
+ var result = skipAtomic(doc, pos, oldPos, origDir, true)
+ if (equalCursorPos(oldPos, result)) { result.hitSide = true }
+ return result
+}
+
+// For relative vertical movement. Dir may be -1 or 1. Unit can be
+// "page" or "line". The resulting position will have a hitSide=true
+// property if it reached the end of the document.
+function findPosV(cm, pos, dir, unit) {
+ var doc = cm.doc, x = pos.left, y
+ if (unit == "page") {
+ var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight)
+ var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3)
+ y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount
+
+ } else if (unit == "line") {
+ y = dir > 0 ? pos.bottom + 3 : pos.top - 3
+ }
+ var target
+ for (;;) {
+ target = coordsChar(cm, x, y)
+ if (!target.outside) { break }
+ if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break }
+ y += dir * 5
+ }
+ return target
+}
+
+// CONTENTEDITABLE INPUT STYLE
+
+var ContentEditableInput = function(cm) {
+ this.cm = cm
+ this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null
+ this.polling = new Delayed()
+ this.composing = null
+ this.gracePeriod = false
+ this.readDOMTimeout = null
+};
- function option(name, deflt, handle, notOnInit) {
- CodeMirror.defaults[name] = deflt;
- if (handle) optionHandlers[name] =
- notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle;
- }
+ContentEditableInput.prototype.init = function (display) {
+ var this$1 = this;
+
+ var input = this, cm = input.cm
+ var div = input.div = display.lineDiv
+ disableBrowserMagic(div, cm.options.spellcheck)
+
+ on(div, "paste", function (e) {
+ if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
+ // IE doesn't fire input events, so we schedule a read for the pasted content in this way
+ if (ie_version <= 11) { setTimeout(operation(cm, function () {
+ if (!input.pollContent()) { regChange(cm) }
+ }), 20) }
+ })
+
+ on(div, "compositionstart", function (e) {
+ this$1.composing = {data: e.data, done: false}
+ })
+ on(div, "compositionupdate", function (e) {
+ if (!this$1.composing) { this$1.composing = {data: e.data, done: false} }
+ })
+ on(div, "compositionend", function (e) {
+ if (this$1.composing) {
+ if (e.data != this$1.composing.data) { this$1.readFromDOMSoon() }
+ this$1.composing.done = true
+ }
+ })
+
+ on(div, "touchstart", function () { return input.forceCompositionEnd(); })
+
+ on(div, "input", function () {
+ if (!this$1.composing) { this$1.readFromDOMSoon() }
+ })
+
+ function onCopyCut(e) {
+ if (signalDOMEvent(cm, e)) { return }
+ if (cm.somethingSelected()) {
+ setLastCopied({lineWise: false, text: cm.getSelections()})
+ if (e.type == "cut") { cm.replaceSelection("", null, "cut") }
+ } else if (!cm.options.lineWiseCopyCut) {
+ return
+ } else {
+ var ranges = copyableRanges(cm)
+ setLastCopied({lineWise: true, text: ranges.text})
+ if (e.type == "cut") {
+ cm.operation(function () {
+ cm.setSelections(ranges.ranges, 0, sel_dontScroll)
+ cm.replaceSelection("", null, "cut")
+ })
+ }
+ }
+ if (e.clipboardData) {
+ e.clipboardData.clearData()
+ var content = lastCopied.text.join("\n")
+ // iOS exposes the clipboard API, but seems to discard content inserted into it
+ e.clipboardData.setData("Text", content)
+ if (e.clipboardData.getData("Text") == content) {
+ e.preventDefault()
+ return
+ }
+ }
+ // Old-fashioned briefly-focus-a-textarea hack
+ var kludge = hiddenTextarea(), te = kludge.firstChild
+ cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild)
+ te.value = lastCopied.text.join("\n")
+ var hadFocus = document.activeElement
+ selectInput(te)
+ setTimeout(function () {
+ cm.display.lineSpace.removeChild(kludge)
+ hadFocus.focus()
+ if (hadFocus == div) { input.showPrimarySelection() }
+ }, 50)
+ }
+ on(div, "copy", onCopyCut)
+ on(div, "cut", onCopyCut)
+};
- // Passed to option handlers when there is no old value.
- var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}};
+ContentEditableInput.prototype.prepareSelection = function () {
+ var result = prepareSelection(this.cm, false)
+ result.focus = this.cm.state.focused
+ return result
+};
- // These two are, on init, called from the constructor because they
- // have to be initialized before the editor can start at all.
- option("value", "", function(cm, val) {
- cm.setValue(val);
- }, true);
- option("mode", null, function(cm, val) {
- cm.doc.modeOption = val;
- loadMode(cm);
- }, true);
-
- option("indentUnit", 2, loadMode, true);
- option("indentWithTabs", false);
- option("smartIndent", true);
- option("tabSize", 4, function(cm) {
- resetModeState(cm);
- clearCaches(cm);
- regChange(cm);
- }, true);
- option("lineSeparator", null, function(cm, val) {
- cm.doc.lineSep = val;
- if (!val) return;
- var newBreaks = [], lineNo = cm.doc.first;
- cm.doc.iter(function(line) {
- for (var pos = 0;;) {
- var found = line.text.indexOf(val, pos);
- if (found == -1) break;
- pos = found + val.length;
- newBreaks.push(Pos(lineNo, found));
+ContentEditableInput.prototype.showSelection = function (info, takeFocus) {
+ if (!info || !this.cm.display.view.length) { return }
+ if (info.focus || takeFocus) { this.showPrimarySelection() }
+ this.showMultipleSelections(info)
+};
+
+ContentEditableInput.prototype.showPrimarySelection = function () {
+ var sel = window.getSelection(), prim = this.cm.doc.sel.primary()
+ var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset)
+ var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset)
+ if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
+ cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
+ cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
+ { return }
+
+ var start = posToDOM(this.cm, prim.from())
+ var end = posToDOM(this.cm, prim.to())
+ if (!start && !end) { return }
+
+ var view = this.cm.display.view
+ var old = sel.rangeCount && sel.getRangeAt(0)
+ if (!start) {
+ start = {node: view[0].measure.map[2], offset: 0}
+ } else if (!end) { // FIXME dangerously hacky
+ var measure = view[view.length - 1].measure
+ var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map
+ end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}
+ }
+
+ var rng
+ try { rng = range(start.node, start.offset, end.offset, end.node) }
+ catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
+ if (rng) {
+ if (!gecko && this.cm.state.focused) {
+ sel.collapse(start.node, start.offset)
+ if (!rng.collapsed) {
+ sel.removeAllRanges()
+ sel.addRange(rng)
}
- lineNo++;
- });
- for (var i = newBreaks.length - 1; i >= 0; i--)
- replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length))
- });
- option("specialChars", /[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) {
- cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
- if (old != CodeMirror.Init) cm.refresh();
- });
- option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true);
- option("electricChars", true);
- option("inputStyle", mobile ? "contenteditable" : "textarea", function() {
- throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME
- }, true);
- option("rtlMoveVisually", !windows);
- option("wholeLineUpdateBefore", true);
-
- option("theme", "default", function(cm) {
- themeChanged(cm);
- guttersChanged(cm);
- }, true);
- option("keyMap", "default", function(cm, val, old) {
- var next = getKeyMap(val);
- var prev = old != CodeMirror.Init && getKeyMap(old);
- if (prev && prev.detach) prev.detach(cm, next);
- if (next.attach) next.attach(cm, prev || null);
- });
- option("extraKeys", null);
-
- option("lineWrapping", false, wrappingChanged, true);
- option("gutters", [], function(cm) {
- setGuttersForLineNumbers(cm.options);
- guttersChanged(cm);
- }, true);
- option("fixedGutter", true, function(cm, val) {
- cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
- cm.refresh();
- }, true);
- option("coverGutterNextToScrollbar", false, function(cm) {updateScrollbars(cm);}, true);
- option("scrollbarStyle", "native", function(cm) {
- initScrollbars(cm);
- updateScrollbars(cm);
- cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
- cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
- }, true);
- option("lineNumbers", false, function(cm) {
- setGuttersForLineNumbers(cm.options);
- guttersChanged(cm);
- }, true);
- option("firstLineNumber", 1, guttersChanged, true);
- option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true);
- option("showCursorWhenSelecting", false, updateSelection, true);
-
- option("resetSelectionOnContextMenu", true);
- option("lineWiseCopyCut", true);
-
- option("readOnly", false, function(cm, val) {
- if (val == "nocursor") {
- onBlur(cm);
- cm.display.input.blur();
- cm.display.disabled = true;
} else {
- cm.display.disabled = false;
+ sel.removeAllRanges()
+ sel.addRange(rng)
}
- cm.display.input.readOnlyChanged(val)
- });
- option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true);
- option("dragDrop", true, dragDropChanged);
- option("allowDropFileTypes", null);
-
- option("cursorBlinkRate", 530);
- option("cursorScrollMargin", 0);
- option("cursorHeight", 1, updateSelection, true);
- option("singleCursorHeightPerLine", true, updateSelection, true);
- option("workTime", 100);
- option("workDelay", 100);
- option("flattenSpans", true, resetModeState, true);
- option("addModeClass", false, resetModeState, true);
- option("pollInterval", 100);
- option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;});
- option("historyEventDelay", 1250);
- option("viewportMargin", 10, function(cm){cm.refresh();}, true);
- option("maxHighlightLength", 10000, resetModeState, true);
- option("moveInputWithCursor", true, function(cm, val) {
- if (!val) cm.display.input.resetPosition();
- });
-
- option("tabindex", null, function(cm, val) {
- cm.display.input.getField().tabIndex = val || "";
- });
- option("autofocus", null);
+ if (old && sel.anchorNode == null) { sel.addRange(old) }
+ else if (gecko) { this.startGracePeriod() }
+ }
+ this.rememberSelection()
+};
- // MODE DEFINITION AND QUERYING
+ContentEditableInput.prototype.startGracePeriod = function () {
+ var this$1 = this;
- // Known modes, by name and by MIME
- var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
+ clearTimeout(this.gracePeriod)
+ this.gracePeriod = setTimeout(function () {
+ this$1.gracePeriod = false
+ if (this$1.selectionChanged())
+ { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }) }
+ }, 20)
+};
- // Extra arguments are stored as the mode's dependencies, which is
- // used by (legacy) mechanisms like loadmode.js to automatically
- // load a mode. (Preferred mechanism is the require/define calls.)
- CodeMirror.defineMode = function(name, mode) {
- if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
- if (arguments.length > 2)
- mode.dependencies = Array.prototype.slice.call(arguments, 2);
- modes[name] = mode;
- };
+ContentEditableInput.prototype.showMultipleSelections = function (info) {
+ removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors)
+ removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection)
+};
- CodeMirror.defineMIME = function(mime, spec) {
- mimeModes[mime] = spec;
- };
+ContentEditableInput.prototype.rememberSelection = function () {
+ var sel = window.getSelection()
+ this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset
+ this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset
+};
- // Given a MIME type, a {name, ...options} config object, or a name
- // string, return a mode config object.
- CodeMirror.resolveMode = function(spec) {
- if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
- spec = mimeModes[spec];
- } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
- var found = mimeModes[spec.name];
- if (typeof found == "string") found = {name: found};
- spec = createObj(found, spec);
- spec.name = found.name;
- } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
- return CodeMirror.resolveMode("application/xml");
- }
- if (typeof spec == "string") return {name: spec};
- else return spec || {name: "null"};
- };
+ContentEditableInput.prototype.selectionInEditor = function () {
+ var sel = window.getSelection()
+ if (!sel.rangeCount) { return false }
+ var node = sel.getRangeAt(0).commonAncestorContainer
+ return contains(this.div, node)
+};
- // Given a mode spec (anything that resolveMode accepts), find and
- // initialize an actual mode object.
- CodeMirror.getMode = function(options, spec) {
- var spec = CodeMirror.resolveMode(spec);
- var mfactory = modes[spec.name];
- if (!mfactory) return CodeMirror.getMode(options, "text/plain");
- var modeObj = mfactory(options, spec);
- if (modeExtensions.hasOwnProperty(spec.name)) {
- var exts = modeExtensions[spec.name];
- for (var prop in exts) {
- if (!exts.hasOwnProperty(prop)) continue;
- if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
- modeObj[prop] = exts[prop];
- }
- }
- modeObj.name = spec.name;
- if (spec.helperType) modeObj.helperType = spec.helperType;
- if (spec.modeProps) for (var prop in spec.modeProps)
- modeObj[prop] = spec.modeProps[prop];
-
- return modeObj;
- };
+ContentEditableInput.prototype.focus = function () {
+ if (this.cm.options.readOnly != "nocursor") {
+ if (!this.selectionInEditor())
+ { this.showSelection(this.prepareSelection(), true) }
+ this.div.focus()
+ }
+};
+ContentEditableInput.prototype.blur = function () { this.div.blur() };
+ContentEditableInput.prototype.getField = function () { return this.div };
- // Minimal default mode.
- CodeMirror.defineMode("null", function() {
- return {token: function(stream) {stream.skipToEnd();}};
- });
- CodeMirror.defineMIME("text/plain", "null");
-
- // This can be used to attach properties to mode objects from
- // outside the actual mode definition.
- var modeExtensions = CodeMirror.modeExtensions = {};
- CodeMirror.extendMode = function(mode, properties) {
- var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
- copyObj(properties, exts);
- };
+ContentEditableInput.prototype.supportsTouch = function () { return true };
- // EXTENSIONS
+ContentEditableInput.prototype.receivedFocus = function () {
+ var input = this
+ if (this.selectionInEditor())
+ { this.pollSelection() }
+ else
+ { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }) }
- CodeMirror.defineExtension = function(name, func) {
- CodeMirror.prototype[name] = func;
- };
- CodeMirror.defineDocExtension = function(name, func) {
- Doc.prototype[name] = func;
- };
- CodeMirror.defineOption = option;
+ function poll() {
+ if (input.cm.state.focused) {
+ input.pollSelection()
+ input.polling.set(input.cm.options.pollInterval, poll)
+ }
+ }
+ this.polling.set(this.cm.options.pollInterval, poll)
+};
- var initHooks = [];
- CodeMirror.defineInitHook = function(f) {initHooks.push(f);};
+ContentEditableInput.prototype.selectionChanged = function () {
+ var sel = window.getSelection()
+ return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
+ sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset
+};
- var helpers = CodeMirror.helpers = {};
- CodeMirror.registerHelper = function(type, name, value) {
- if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []};
- helpers[type][name] = value;
- };
- CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
- CodeMirror.registerHelper(type, name, value);
- helpers[type]._global.push({pred: predicate, val: value});
- };
+ContentEditableInput.prototype.pollSelection = function () {
+ if (!this.composing && this.readDOMTimeout == null && !this.gracePeriod && this.selectionChanged()) {
+ var sel = window.getSelection(), cm = this.cm
+ this.rememberSelection()
+ var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset)
+ var head = domToPos(cm, sel.focusNode, sel.focusOffset)
+ if (anchor && head) { runInOp(cm, function () {
+ setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll)
+ if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true }
+ }) }
+ }
+};
- // MODE STATE HANDLING
+ContentEditableInput.prototype.pollContent = function () {
+ if (this.readDOMTimeout != null) {
+ clearTimeout(this.readDOMTimeout)
+ this.readDOMTimeout = null
+ }
- // Utility functions for working with state. Exported because nested
- // modes need to do this for their inner modes.
+ var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary()
+ var from = sel.from(), to = sel.to()
+ if (from.ch == 0 && from.line > cm.firstLine())
+ { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length) }
+ if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine())
+ { to = Pos(to.line + 1, 0) }
+ if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }
- var copyState = CodeMirror.copyState = function(mode, state) {
- if (state === true) return state;
- if (mode.copyState) return mode.copyState(state);
- var nstate = {};
- for (var n in state) {
- var val = state[n];
- if (val instanceof Array) val = val.concat([]);
- nstate[n] = val;
- }
- return nstate;
- };
+ var fromIndex, fromLine, fromNode
+ if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
+ fromLine = lineNo(display.view[0].line)
+ fromNode = display.view[0].node
+ } else {
+ fromLine = lineNo(display.view[fromIndex].line)
+ fromNode = display.view[fromIndex - 1].node.nextSibling
+ }
+ var toIndex = findViewIndex(cm, to.line)
+ var toLine, toNode
+ if (toIndex == display.view.length - 1) {
+ toLine = display.viewTo - 1
+ toNode = display.lineDiv.lastChild
+ } else {
+ toLine = lineNo(display.view[toIndex + 1].line) - 1
+ toNode = display.view[toIndex + 1].node.previousSibling
+ }
+
+ if (!fromNode) { return false }
+ var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine))
+ var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length))
+ while (newText.length > 1 && oldText.length > 1) {
+ if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine-- }
+ else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++ }
+ else { break }
+ }
+
+ var cutFront = 0, cutEnd = 0
+ var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length)
+ while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
+ { ++cutFront }
+ var newBot = lst(newText), oldBot = lst(oldText)
+ var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
+ oldBot.length - (oldText.length == 1 ? cutFront : 0))
+ while (cutEnd < maxCutEnd &&
+ newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
+ { ++cutEnd }
+
+ newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "")
+ newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "")
+
+ var chFrom = Pos(fromLine, cutFront)
+ var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0)
+ if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
+ replaceRange(cm.doc, newText, chFrom, chTo, "+input")
+ return true
+ }
+};
- var startState = CodeMirror.startState = function(mode, a1, a2) {
- return mode.startState ? mode.startState(a1, a2) : true;
- };
+ContentEditableInput.prototype.ensurePolled = function () {
+ this.forceCompositionEnd()
+};
+ContentEditableInput.prototype.reset = function () {
+ this.forceCompositionEnd()
+};
+ContentEditableInput.prototype.forceCompositionEnd = function () {
+ if (!this.composing) { return }
+ clearTimeout(this.readDOMTimeout)
+ this.composing = null
+ if (!this.pollContent()) { regChange(this.cm) }
+ this.div.blur()
+ this.div.focus()
+};
+ContentEditableInput.prototype.readFromDOMSoon = function () {
+ var this$1 = this;
+
+ if (this.readDOMTimeout != null) { return }
+ this.readDOMTimeout = setTimeout(function () {
+ this$1.readDOMTimeout = null
+ if (this$1.composing) {
+ if (this$1.composing.done) { this$1.composing = null }
+ else { return }
+ }
+ if (this$1.cm.isReadOnly() || !this$1.pollContent())
+ { runInOp(this$1.cm, function () { return regChange(this$1.cm); }) }
+ }, 80)
+};
- // Given a mode and a state (for that mode), find the inner mode and
- // state at the position that the state refers to.
- CodeMirror.innerMode = function(mode, state) {
- while (mode.innerMode) {
- var info = mode.innerMode(state);
- if (!info || info.mode == mode) break;
- state = info.state;
- mode = info.mode;
- }
- return info || {mode: mode, state: state};
- };
+ContentEditableInput.prototype.setUneditable = function (node) {
+ node.contentEditable = "false"
+};
- // STANDARD COMMANDS
+ContentEditableInput.prototype.onKeyPress = function (e) {
+ if (e.charCode == 0) { return }
+ e.preventDefault()
+ if (!this.cm.isReadOnly())
+ { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0) }
+};
- // Commands are parameter-less actions that can be performed on an
- // editor, mostly used for keybindings.
- var commands = CodeMirror.commands = {
- selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);},
- singleSelection: function(cm) {
- cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll);
- },
- killLine: function(cm) {
- deleteNearSelection(cm, function(range) {
- if (range.empty()) {
- var len = getLine(cm.doc, range.head.line).text.length;
- if (range.head.ch == len && range.head.line < cm.lastLine())
- return {from: range.head, to: Pos(range.head.line + 1, 0)};
- else
- return {from: range.head, to: Pos(range.head.line, len)};
- } else {
- return {from: range.from(), to: range.to()};
- }
- });
- },
- deleteLine: function(cm) {
- deleteNearSelection(cm, function(range) {
- return {from: Pos(range.from().line, 0),
- to: clipPos(cm.doc, Pos(range.to().line + 1, 0))};
- });
- },
- delLineLeft: function(cm) {
- deleteNearSelection(cm, function(range) {
- return {from: Pos(range.from().line, 0), to: range.from()};
- });
- },
- delWrappedLineLeft: function(cm) {
- deleteNearSelection(cm, function(range) {
- var top = cm.charCoords(range.head, "div").top + 5;
- var leftPos = cm.coordsChar({left: 0, top: top}, "div");
- return {from: leftPos, to: range.from()};
- });
- },
- delWrappedLineRight: function(cm) {
- deleteNearSelection(cm, function(range) {
- var top = cm.charCoords(range.head, "div").top + 5;
- var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
- return {from: range.from(), to: rightPos };
- });
- },
- undo: function(cm) {cm.undo();},
- redo: function(cm) {cm.redo();},
- undoSelection: function(cm) {cm.undoSelection();},
- redoSelection: function(cm) {cm.redoSelection();},
- goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));},
- goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));},
- goLineStart: function(cm) {
- cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); },
- {origin: "+move", bias: 1});
- },
- goLineStartSmart: function(cm) {
- cm.extendSelectionsBy(function(range) {
- return lineStartSmart(cm, range.head);
- }, {origin: "+move", bias: 1});
- },
- goLineEnd: function(cm) {
- cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); },
- {origin: "+move", bias: -1});
- },
- goLineRight: function(cm) {
- cm.extendSelectionsBy(function(range) {
- var top = cm.charCoords(range.head, "div").top + 5;
- return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
- }, sel_move);
- },
- goLineLeft: function(cm) {
- cm.extendSelectionsBy(function(range) {
- var top = cm.charCoords(range.head, "div").top + 5;
- return cm.coordsChar({left: 0, top: top}, "div");
- }, sel_move);
- },
- goLineLeftSmart: function(cm) {
- cm.extendSelectionsBy(function(range) {
- var top = cm.charCoords(range.head, "div").top + 5;
- var pos = cm.coordsChar({left: 0, top: top}, "div");
- if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head);
- return pos;
- }, sel_move);
- },
- goLineUp: function(cm) {cm.moveV(-1, "line");},
- goLineDown: function(cm) {cm.moveV(1, "line");},
- goPageUp: function(cm) {cm.moveV(-1, "page");},
- goPageDown: function(cm) {cm.moveV(1, "page");},
- goCharLeft: function(cm) {cm.moveH(-1, "char");},
- goCharRight: function(cm) {cm.moveH(1, "char");},
- goColumnLeft: function(cm) {cm.moveH(-1, "column");},
- goColumnRight: function(cm) {cm.moveH(1, "column");},
- goWordLeft: function(cm) {cm.moveH(-1, "word");},
- goGroupRight: function(cm) {cm.moveH(1, "group");},
- goGroupLeft: function(cm) {cm.moveH(-1, "group");},
- goWordRight: function(cm) {cm.moveH(1, "word");},
- delCharBefore: function(cm) {cm.deleteH(-1, "char");},
- delCharAfter: function(cm) {cm.deleteH(1, "char");},
- delWordBefore: function(cm) {cm.deleteH(-1, "word");},
- delWordAfter: function(cm) {cm.deleteH(1, "word");},
- delGroupBefore: function(cm) {cm.deleteH(-1, "group");},
- delGroupAfter: function(cm) {cm.deleteH(1, "group");},
- indentAuto: function(cm) {cm.indentSelection("smart");},
- indentMore: function(cm) {cm.indentSelection("add");},
- indentLess: function(cm) {cm.indentSelection("subtract");},
- insertTab: function(cm) {cm.replaceSelection("\t");},
- insertSoftTab: function(cm) {
- var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
- for (var i = 0; i < ranges.length; i++) {
- var pos = ranges[i].from();
- var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
- spaces.push(spaceStr(tabSize - col % tabSize));
- }
- cm.replaceSelections(spaces);
- },
- defaultTab: function(cm) {
- if (cm.somethingSelected()) cm.indentSelection("add");
- else cm.execCommand("insertTab");
- },
- transposeChars: function(cm) {
- runInOp(cm, function() {
- var ranges = cm.listSelections(), newSel = [];
- for (var i = 0; i < ranges.length; i++) {
- var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
- if (line) {
- if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1);
- if (cur.ch > 0) {
- cur = new Pos(cur.line, cur.ch + 1);
- cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
- Pos(cur.line, cur.ch - 2), cur, "+transpose");
- } else if (cur.line > cm.doc.first) {
- var prev = getLine(cm.doc, cur.line - 1).text;
- if (prev)
- cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
- prev.charAt(prev.length - 1),
- Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose");
- }
- }
- newSel.push(new Range(cur, cur));
- }
- cm.setSelections(newSel);
- });
- },
- newlineAndIndent: function(cm) {
- runInOp(cm, function() {
- var len = cm.listSelections().length;
- for (var i = 0; i < len; i++) {
- var range = cm.listSelections()[i];
- cm.replaceRange(cm.doc.lineSeparator(), range.anchor, range.head, "+input");
- cm.indentLine(range.from().line + 1, null, true);
- }
- ensureCursorVisible(cm);
- });
- },
- openLine: function(cm) {cm.replaceSelection("\n", "start")},
- toggleOverwrite: function(cm) {cm.toggleOverwrite();}
- };
+ContentEditableInput.prototype.readOnlyChanged = function (val) {
+ this.div.contentEditable = String(val != "nocursor")
+};
+ContentEditableInput.prototype.onContextMenu = function () {};
+ContentEditableInput.prototype.resetPosition = function () {};
+
+ContentEditableInput.prototype.needsContentAttribute = true
+
+function posToDOM(cm, pos) {
+ var view = findViewForLine(cm, pos.line)
+ if (!view || view.hidden) { return null }
+ var line = getLine(cm.doc, pos.line)
+ var info = mapFromLineView(view, line, pos.line)
+
+ var order = getOrder(line), side = "left"
+ if (order) {
+ var partPos = getBidiPartAt(order, pos.ch)
+ side = partPos % 2 ? "right" : "left"
+ }
+ var result = nodeAndOffsetInLineMap(info.map, pos.ch, side)
+ result.offset = result.collapse == "right" ? result.end : result.start
+ return result
+}
+
+function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }
+
+function domTextBetween(cm, from, to, fromLine, toLine) {
+ var text = "", closing = false, lineSep = cm.doc.lineSeparator()
+ function recognizeMarker(id) { return function (marker) { return marker.id == id; } }
+ function walk(node) {
+ if (node.nodeType == 1) {
+ var cmText = node.getAttribute("cm-text")
+ if (cmText != null) {
+ if (cmText == "") { text += node.textContent.replace(/\u200b/g, "") }
+ else { text += cmText }
+ return
+ }
+ var markerID = node.getAttribute("cm-marker"), range
+ if (markerID) {
+ var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID))
+ if (found.length && (range = found[0].find()))
+ { text += getBetween(cm.doc, range.from, range.to).join(lineSep) }
+ return
+ }
+ if (node.getAttribute("contenteditable") == "false") { return }
+ for (var i = 0; i < node.childNodes.length; i++)
+ { walk(node.childNodes[i]) }
+ if (/^(pre|div|p)$/i.test(node.nodeName))
+ { closing = true }
+ } else if (node.nodeType == 3) {
+ var val = node.nodeValue
+ if (!val) { return }
+ if (closing) {
+ text += lineSep
+ closing = false
+ }
+ text += val
+ }
+ }
+ for (;;) {
+ walk(from)
+ if (from == to) { break }
+ from = from.nextSibling
+ }
+ return text
+}
+
+function domToPos(cm, node, offset) {
+ var lineNode
+ if (node == cm.display.lineDiv) {
+ lineNode = cm.display.lineDiv.childNodes[offset]
+ if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) }
+ node = null; offset = 0
+ } else {
+ for (lineNode = node;; lineNode = lineNode.parentNode) {
+ if (!lineNode || lineNode == cm.display.lineDiv) { return null }
+ if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break }
+ }
+ }
+ for (var i = 0; i < cm.display.view.length; i++) {
+ var lineView = cm.display.view[i]
+ if (lineView.node == lineNode)
+ { return locateNodeInLineView(lineView, node, offset) }
+ }
+}
- // STANDARD KEYMAPS
+function locateNodeInLineView(lineView, node, offset) {
+ var wrapper = lineView.text.firstChild, bad = false
+ if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) }
+ if (node == wrapper) {
+ bad = true
+ node = wrapper.childNodes[offset]
+ offset = 0
+ if (!node) {
+ var line = lineView.rest ? lst(lineView.rest) : lineView.line
+ return badPos(Pos(lineNo(line), line.text.length), bad)
+ }
+ }
- var keyMap = CodeMirror.keyMap = {};
+ var textNode = node.nodeType == 3 ? node : null, topNode = node
+ if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
+ textNode = node.firstChild
+ if (offset) { offset = textNode.nodeValue.length }
+ }
+ while (topNode.parentNode != wrapper) { topNode = topNode.parentNode }
+ var measure = lineView.measure, maps = measure.maps
- keyMap.basic = {
- "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
- "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
- "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
- "Tab": "defaultTab", "Shift-Tab": "indentAuto",
- "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
- "Esc": "singleSelection"
- };
- // Note that the save and find-related commands aren't defined by
- // default. User code or addons can define them. Unknown commands
- // are simply ignored.
- keyMap.pcDefault = {
- "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
- "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
- "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
- "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
- "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
- "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
- "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
- fallthrough: "basic"
- };
- // Very basic readline/emacs-style bindings, which are standard on Mac.
- keyMap.emacsy = {
- "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
- "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
- "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
- "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
- "Ctrl-O": "openLine"
- };
- keyMap.macDefault = {
- "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
- "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
- "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
- "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
- "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
- "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
- "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
- fallthrough: ["basic", "emacsy"]
- };
- keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
-
- // KEYMAP DISPATCH
-
- function normalizeKeyName(name) {
- var parts = name.split(/-(?!$)/), name = parts[parts.length - 1];
- var alt, ctrl, shift, cmd;
- for (var i = 0; i < parts.length - 1; i++) {
- var mod = parts[i];
- if (/^(cmd|meta|m)$/i.test(mod)) cmd = true;
- else if (/^a(lt)?$/i.test(mod)) alt = true;
- else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
- else if (/^s(hift)$/i.test(mod)) shift = true;
- else throw new Error("Unrecognized modifier name: " + mod);
- }
- if (alt) name = "Alt-" + name;
- if (ctrl) name = "Ctrl-" + name;
- if (cmd) name = "Cmd-" + name;
- if (shift) name = "Shift-" + name;
- return name;
- }
-
- // This is a kludge to keep keymaps mostly working as raw objects
- // (backwards compatibility) while at the same time support features
- // like normalization and multi-stroke key bindings. It compiles a
- // new normalized keymap, and then updates the old object to reflect
- // this.
- CodeMirror.normalizeKeyMap = function(keymap) {
- var copy = {};
- for (var keyname in keymap) if (keymap.hasOwnProperty(keyname)) {
- var value = keymap[keyname];
- if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue;
- if (value == "...") { delete keymap[keyname]; continue; }
-
- var keys = map(keyname.split(" "), normalizeKeyName);
- for (var i = 0; i < keys.length; i++) {
- var val, name;
- if (i == keys.length - 1) {
- name = keys.join(" ");
- val = value;
- } else {
- name = keys.slice(0, i + 1).join(" ");
- val = "...";
+ function find(textNode, topNode, offset) {
+ for (var i = -1; i < (maps ? maps.length : 0); i++) {
+ var map = i < 0 ? measure.map : maps[i]
+ for (var j = 0; j < map.length; j += 3) {
+ var curNode = map[j + 2]
+ if (curNode == textNode || curNode == topNode) {
+ var line = lineNo(i < 0 ? lineView.line : lineView.rest[i])
+ var ch = map[j] + offset
+ if (offset < 0 || curNode != textNode) { ch = map[j + (offset ? 1 : 0)] }
+ return Pos(line, ch)
}
- var prev = copy[name];
- if (!prev) copy[name] = val;
- else if (prev != val) throw new Error("Inconsistent bindings for " + name);
}
- delete keymap[keyname];
}
- for (var prop in copy) keymap[prop] = copy[prop];
- return keymap;
- };
+ }
+ var found = find(textNode, topNode, offset)
+ if (found) { return badPos(found, bad) }
- var lookupKey = CodeMirror.lookupKey = function(key, map, handle, context) {
- map = getKeyMap(map);
- var found = map.call ? map.call(key, context) : map[key];
- if (found === false) return "nothing";
- if (found === "...") return "multi";
- if (found != null && handle(found)) return "handled";
+ // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
+ for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
+ found = find(after, after.firstChild, 0)
+ if (found)
+ { return badPos(Pos(found.line, found.ch - dist), bad) }
+ else
+ { dist += after.textContent.length }
+ }
+ for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {
+ found = find(before, before.firstChild, -1)
+ if (found)
+ { return badPos(Pos(found.line, found.ch + dist$1), bad) }
+ else
+ { dist$1 += before.textContent.length }
+ }
+}
- if (map.fallthrough) {
- if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")
- return lookupKey(key, map.fallthrough, handle, context);
- for (var i = 0; i < map.fallthrough.length; i++) {
- var result = lookupKey(key, map.fallthrough[i], handle, context);
- if (result) return result;
- }
- }
- };
+// TEXTAREA INPUT STYLE
- // Modifier key presses don't count as 'real' key presses for the
- // purpose of keymap fallthrough.
- var isModifierKey = CodeMirror.isModifierKey = function(value) {
- var name = typeof value == "string" ? value : keyNames[value.keyCode];
- return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
- };
+var TextareaInput = function(cm) {
+ this.cm = cm
+ // See input.poll and input.reset
+ this.prevInput = ""
- // Look up the name of a key as indicated by an event object.
- var keyName = CodeMirror.keyName = function(event, noShift) {
- if (presto && event.keyCode == 34 && event["char"]) return false;
- var base = keyNames[event.keyCode], name = base;
- if (name == null || event.altGraphKey) return false;
- if (event.altKey && base != "Alt") name = "Alt-" + name;
- if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name;
- if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") name = "Cmd-" + name;
- if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name;
- return name;
- };
+ // Flag that indicates whether we expect input to appear real soon
+ // now (after some event like 'keypress' or 'input') and are
+ // polling intensively.
+ this.pollingFast = false
+ // Self-resetting timeout for the poller
+ this.polling = new Delayed()
+ // Tracks when input.reset has punted to just putting a short
+ // string into the textarea instead of the full selection.
+ this.inaccurateSelection = false
+ // Used to work around IE issue with selection being forgotten when focus moves away from textarea
+ this.hasSelection = false
+ this.composing = null
+};
- function getKeyMap(val) {
- return typeof val == "string" ? keyMap[val] : val;
- }
-
- // FROMTEXTAREA
-
- CodeMirror.fromTextArea = function(textarea, options) {
- options = options ? copyObj(options) : {};
- options.value = textarea.value;
- if (!options.tabindex && textarea.tabIndex)
- options.tabindex = textarea.tabIndex;
- if (!options.placeholder && textarea.placeholder)
- options.placeholder = textarea.placeholder;
- // Set autofocus to true if this textarea is focused, or if it has
- // autofocus and no other element is focused.
- if (options.autofocus == null) {
- var hasFocus = activeElt();
- options.autofocus = hasFocus == textarea ||
- textarea.getAttribute("autofocus") != null && hasFocus == document.body;
- }
-
- function save() {textarea.value = cm.getValue();}
- if (textarea.form) {
- on(textarea.form, "submit", save);
- // Deplorable hack to make the submit method do the right thing.
- if (!options.leaveSubmitMethodAlone) {
- var form = textarea.form, realSubmit = form.submit;
- try {
- var wrappedSubmit = form.submit = function() {
- save();
- form.submit = realSubmit;
- form.submit();
- form.submit = wrappedSubmit;
- };
- } catch(e) {}
- }
- }
+TextareaInput.prototype.init = function (display) {
+ var this$1 = this;
+
+ var input = this, cm = this.cm
+
+ // Wraps and hides input textarea
+ var div = this.wrapper = hiddenTextarea()
+ // The semihidden textarea that is focused when the editor is
+ // focused, and receives input.
+ var te = this.textarea = div.firstChild
+ display.wrapper.insertBefore(div, display.wrapper.firstChild)
+
+ // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
+ if (ios) { te.style.width = "0px" }
+
+ on(te, "input", function () {
+ if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null }
+ input.poll()
+ })
+
+ on(te, "paste", function (e) {
+ if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
+
+ cm.state.pasteIncoming = true
+ input.fastPoll()
+ })
+
+ function prepareCopyCut(e) {
+ if (signalDOMEvent(cm, e)) { return }
+ if (cm.somethingSelected()) {
+ setLastCopied({lineWise: false, text: cm.getSelections()})
+ if (input.inaccurateSelection) {
+ input.prevInput = ""
+ input.inaccurateSelection = false
+ te.value = lastCopied.text.join("\n")
+ selectInput(te)
+ }
+ } else if (!cm.options.lineWiseCopyCut) {
+ return
+ } else {
+ var ranges = copyableRanges(cm)
+ setLastCopied({lineWise: true, text: ranges.text})
+ if (e.type == "cut") {
+ cm.setSelections(ranges.ranges, null, sel_dontScroll)
+ } else {
+ input.prevInput = ""
+ te.value = ranges.text.join("\n")
+ selectInput(te)
+ }
+ }
+ if (e.type == "cut") { cm.state.cutIncoming = true }
+ }
+ on(te, "cut", prepareCopyCut)
+ on(te, "copy", prepareCopyCut)
+
+ on(display.scroller, "paste", function (e) {
+ if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }
+ cm.state.pasteIncoming = true
+ input.focus()
+ })
+
+ // Prevent normal selection in the editor (we handle our own)
+ on(display.lineSpace, "selectstart", function (e) {
+ if (!eventInWidget(display, e)) { e_preventDefault(e) }
+ })
+
+ on(te, "compositionstart", function () {
+ var start = cm.getCursor("from")
+ if (input.composing) { input.composing.range.clear() }
+ input.composing = {
+ start: start,
+ range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
+ }
+ })
+ on(te, "compositionend", function () {
+ if (input.composing) {
+ input.poll()
+ input.composing.range.clear()
+ input.composing = null
+ }
+ })
+};
- options.finishInit = function(cm) {
- cm.save = save;
- cm.getTextArea = function() { return textarea; };
- cm.toTextArea = function() {
- cm.toTextArea = isNaN; // Prevent this from being ran twice
- save();
- textarea.parentNode.removeChild(cm.getWrapperElement());
- textarea.style.display = "";
- if (textarea.form) {
- off(textarea.form, "submit", save);
- if (typeof textarea.form.submit == "function")
- textarea.form.submit = realSubmit;
- }
- };
- };
+TextareaInput.prototype.prepareSelection = function () {
+ // Redraw the selection and/or cursor
+ var cm = this.cm, display = cm.display, doc = cm.doc
+ var result = prepareSelection(cm)
- textarea.style.display = "none";
- var cm = CodeMirror(function(node) {
- textarea.parentNode.insertBefore(node, textarea.nextSibling);
- }, options);
- return cm;
- };
+ // Move the hidden textarea near the cursor to prevent scrolling artifacts
+ if (cm.options.moveInputWithCursor) {
+ var headPos = cursorCoords(cm, doc.sel.primary().head, "div")
+ var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect()
+ result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
+ headPos.top + lineOff.top - wrapOff.top))
+ result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
+ headPos.left + lineOff.left - wrapOff.left))
+ }
- // STRING STREAM
+ return result
+};
- // Fed to the mode parsers, provides helper functions to make
- // parsers more succinct.
+TextareaInput.prototype.showSelection = function (drawn) {
+ var cm = this.cm, display = cm.display
+ removeChildrenAndAdd(display.cursorDiv, drawn.cursors)
+ removeChildrenAndAdd(display.selectionDiv, drawn.selection)
+ if (drawn.teTop != null) {
+ this.wrapper.style.top = drawn.teTop + "px"
+ this.wrapper.style.left = drawn.teLeft + "px"
+ }
+};
- var StringStream = CodeMirror.StringStream = function(string, tabSize) {
- this.pos = this.start = 0;
- this.string = string;
- this.tabSize = tabSize || 8;
- this.lastColumnPos = this.lastColumnValue = 0;
- this.lineStart = 0;
- };
+// Reset the input to correspond to the selection (or to be empty,
+// when not typing and nothing is selected)
+TextareaInput.prototype.reset = function (typing) {
+ if (this.contextMenuPending) { return }
+ var minimal, selected, cm = this.cm, doc = cm.doc
+ if (cm.somethingSelected()) {
+ this.prevInput = ""
+ var range = doc.sel.primary()
+ minimal = hasCopyEvent &&
+ (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000)
+ var content = minimal ? "-" : selected || cm.getSelection()
+ this.textarea.value = content
+ if (cm.state.focused) { selectInput(this.textarea) }
+ if (ie && ie_version >= 9) { this.hasSelection = content }
+ } else if (!typing) {
+ this.prevInput = this.textarea.value = ""
+ if (ie && ie_version >= 9) { this.hasSelection = null }
+ }
+ this.inaccurateSelection = minimal
+};
- StringStream.prototype = {
- eol: function() {return this.pos >= this.string.length;},
- sol: function() {return this.pos == this.lineStart;},
- peek: function() {return this.string.charAt(this.pos) || undefined;},
- next: function() {
- if (this.pos < this.string.length)
- return this.string.charAt(this.pos++);
- },
- eat: function(match) {
- var ch = this.string.charAt(this.pos);
- if (typeof match == "string") var ok = ch == match;
- else var ok = ch && (match.test ? match.test(ch) : match(ch));
- if (ok) {++this.pos; return ch;}
- },
- eatWhile: function(match) {
- var start = this.pos;
- while (this.eat(match)){}
- return this.pos > start;
- },
- eatSpace: function() {
- var start = this.pos;
- while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos;
- return this.pos > start;
- },
- skipToEnd: function() {this.pos = this.string.length;},
- skipTo: function(ch) {
- var found = this.string.indexOf(ch, this.pos);
- if (found > -1) {this.pos = found; return true;}
- },
- backUp: function(n) {this.pos -= n;},
- column: function() {
- if (this.lastColumnPos < this.start) {
- this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
- this.lastColumnPos = this.start;
- }
- return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
- },
- indentation: function() {
- return countColumn(this.string, null, this.tabSize) -
- (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
- },
- match: function(pattern, consume, caseInsensitive) {
- if (typeof pattern == "string") {
- var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
- var substr = this.string.substr(this.pos, pattern.length);
- if (cased(substr) == cased(pattern)) {
- if (consume !== false) this.pos += pattern.length;
- return true;
- }
- } else {
- var match = this.string.slice(this.pos).match(pattern);
- if (match && match.index > 0) return null;
- if (match && consume !== false) this.pos += match[0].length;
- return match;
- }
- },
- current: function(){return this.string.slice(this.start, this.pos);},
- hideFirstChars: function(n, inner) {
- this.lineStart += n;
- try { return inner(); }
- finally { this.lineStart -= n; }
- }
- };
+TextareaInput.prototype.getField = function () { return this.textarea };
- // TEXTMARKERS
-
- // Created with markText and setBookmark methods. A TextMarker is a
- // handle that can be used to clear or find a marked position in the
- // document. Line objects hold arrays (markedSpans) containing
- // {from, to, marker} object pointing to such marker objects, and
- // indicating that such a marker is present on that line. Multiple
- // lines may point to the same marker when it spans across lines.
- // The spans will have null for their from/to properties when the
- // marker continues beyond the start/end of the line. Markers have
- // links back to the lines they currently touch.
-
- var nextMarkerId = 0;
-
- var TextMarker = CodeMirror.TextMarker = function(doc, type) {
- this.lines = [];
- this.type = type;
- this.doc = doc;
- this.id = ++nextMarkerId;
- };
- eventMixin(TextMarker);
-
- // Clear the marker.
- TextMarker.prototype.clear = function() {
- if (this.explicitlyCleared) return;
- var cm = this.doc.cm, withOp = cm && !cm.curOp;
- if (withOp) startOperation(cm);
- if (hasHandler(this, "clear")) {
- var found = this.find();
- if (found) signalLater(this, "clear", found.from, found.to);
- }
- var min = null, max = null;
- for (var i = 0; i < this.lines.length; ++i) {
- var line = this.lines[i];
- var span = getMarkedSpanFor(line.markedSpans, this);
- if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text");
- else if (cm) {
- if (span.to != null) max = lineNo(line);
- if (span.from != null) min = lineNo(line);
- }
- line.markedSpans = removeMarkedSpan(line.markedSpans, span);
- if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm)
- updateLineHeight(line, textHeight(cm.display));
- }
- if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) {
- var visual = visualLine(this.lines[i]), len = lineLength(visual);
- if (len > cm.display.maxLineLength) {
- cm.display.maxLine = visual;
- cm.display.maxLineLength = len;
- cm.display.maxLineChanged = true;
- }
- }
-
- if (min != null && cm && this.collapsed) regChange(cm, min, max + 1);
- this.lines.length = 0;
- this.explicitlyCleared = true;
- if (this.atomic && this.doc.cantEdit) {
- this.doc.cantEdit = false;
- if (cm) reCheckSelection(cm.doc);
- }
- if (cm) signalLater(cm, "markerCleared", cm, this);
- if (withOp) endOperation(cm);
- if (this.parent) this.parent.clear();
- };
+TextareaInput.prototype.supportsTouch = function () { return false };
- // Find the position of the marker in the document. Returns a {from,
- // to} object by default. Side can be passed to get a specific side
- // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
- // Pos objects returned contain a line object, rather than a line
- // number (used to prevent looking up the same line twice).
- TextMarker.prototype.find = function(side, lineObj) {
- if (side == null && this.type == "bookmark") side = 1;
- var from, to;
- for (var i = 0; i < this.lines.length; ++i) {
- var line = this.lines[i];
- var span = getMarkedSpanFor(line.markedSpans, this);
- if (span.from != null) {
- from = Pos(lineObj ? line : lineNo(line), span.from);
- if (side == -1) return from;
- }
- if (span.to != null) {
- to = Pos(lineObj ? line : lineNo(line), span.to);
- if (side == 1) return to;
- }
- }
- return from && {from: from, to: to};
- };
+TextareaInput.prototype.focus = function () {
+ if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
+ try { this.textarea.focus() }
+ catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
+ }
+};
- // Signals that the marker's widget changed, and surrounding layout
- // should be recomputed.
- TextMarker.prototype.changed = function() {
- var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
- if (!pos || !cm) return;
- runInOp(cm, function() {
- var line = pos.line, lineN = lineNo(pos.line);
- var view = findViewForLine(cm, lineN);
- if (view) {
- clearLineMeasurementCacheFor(view);
- cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
- }
- cm.curOp.updateMaxLine = true;
- if (!lineIsHidden(widget.doc, line) && widget.height != null) {
- var oldHeight = widget.height;
- widget.height = null;
- var dHeight = widgetHeight(widget) - oldHeight;
- if (dHeight)
- updateLineHeight(line, line.height + dHeight);
- }
- });
- };
+TextareaInput.prototype.blur = function () { this.textarea.blur() };
- TextMarker.prototype.attachLine = function(line) {
- if (!this.lines.length && this.doc.cm) {
- var op = this.doc.cm.curOp;
- if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
- (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this);
- }
- this.lines.push(line);
- };
- TextMarker.prototype.detachLine = function(line) {
- this.lines.splice(indexOf(this.lines, line), 1);
- if (!this.lines.length && this.doc.cm) {
- var op = this.doc.cm.curOp;
- (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
- }
- };
+TextareaInput.prototype.resetPosition = function () {
+ this.wrapper.style.top = this.wrapper.style.left = 0
+};
- // Collapsed markers have unique ids, in order to be able to order
- // them, which is needed for uniquely determining an outer marker
- // when they overlap (they may nest, but not partially overlap).
- var nextMarkerId = 0;
-
- // Create a marker, wire it up to the right lines, and
- function markText(doc, from, to, options, type) {
- // Shared markers (across linked documents) are handled separately
- // (markTextShared will call out to this again, once per
- // document).
- if (options && options.shared) return markTextShared(doc, from, to, options, type);
- // Ensure we are in an operation.
- if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type);
-
- var marker = new TextMarker(doc, type), diff = cmp(from, to);
- if (options) copyObj(options, marker, false);
- // Don't connect empty markers unless clearWhenEmpty is false
- if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
- return marker;
- if (marker.replacedWith) {
- // Showing up as a widget implies collapsed (widget replaces text)
- marker.collapsed = true;
- marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget");
- if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true");
- if (options.insertLeft) marker.widgetNode.insertLeft = true;
- }
- if (marker.collapsed) {
- if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
- from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
- throw new Error("Inserting collapsed marker partially overlapping an existing one");
- sawCollapsedSpans = true;
- }
-
- if (marker.addToHistory)
- addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN);
-
- var curLine = from.line, cm = doc.cm, updateMaxLine;
- doc.iter(curLine, to.line + 1, function(line) {
- if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
- updateMaxLine = true;
- if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0);
- addMarkedSpan(line, new MarkedSpan(marker,
- curLine == from.line ? from.ch : null,
- curLine == to.line ? to.ch : null));
- ++curLine;
- });
- // lineIsHidden depends on the presence of the spans, so needs a second pass
- if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) {
- if (lineIsHidden(doc, line)) updateLineHeight(line, 0);
- });
+TextareaInput.prototype.receivedFocus = function () { this.slowPoll() };
- if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); });
+// Poll for input changes, using the normal rate of polling. This
+// runs as long as the editor is focused.
+TextareaInput.prototype.slowPoll = function () {
+ var this$1 = this;
- if (marker.readOnly) {
- sawReadOnlySpans = true;
- if (doc.history.done.length || doc.history.undone.length)
- doc.clearHistory();
- }
- if (marker.collapsed) {
- marker.id = ++nextMarkerId;
- marker.atomic = true;
- }
- if (cm) {
- // Sync editor state
- if (updateMaxLine) cm.curOp.updateMaxLine = true;
- if (marker.collapsed)
- regChange(cm, from.line, to.line + 1);
- else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
- for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text");
- if (marker.atomic) reCheckSelection(cm.doc);
- signalLater(cm, "markerAdded", cm, marker);
- }
- return marker;
- }
+ if (this.pollingFast) { return }
+ this.polling.set(this.cm.options.pollInterval, function () {
+ this$1.poll()
+ if (this$1.cm.state.focused) { this$1.slowPoll() }
+ })
+};
- // SHARED TEXTMARKERS
+// When an event has just come in that is likely to add or change
+// something in the input textarea, we poll faster, to ensure that
+// the change appears on the screen quickly.
+TextareaInput.prototype.fastPoll = function () {
+ var missed = false, input = this
+ input.pollingFast = true
+ function p() {
+ var changed = input.poll()
+ if (!changed && !missed) {missed = true; input.polling.set(60, p)}
+ else {input.pollingFast = false; input.slowPoll()}
+ }
+ input.polling.set(20, p)
+};
- // A shared marker spans multiple linked documents. It is
- // implemented as a meta-marker-object controlling multiple normal
- // markers.
- var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) {
- this.markers = markers;
- this.primary = primary;
- for (var i = 0; i < markers.length; ++i)
- markers[i].parent = this;
- };
- eventMixin(SharedTextMarker);
-
- SharedTextMarker.prototype.clear = function() {
- if (this.explicitlyCleared) return;
- this.explicitlyCleared = true;
- for (var i = 0; i < this.markers.length; ++i)
- this.markers[i].clear();
- signalLater(this, "clear");
- };
- SharedTextMarker.prototype.find = function(side, lineObj) {
- return this.primary.find(side, lineObj);
- };
+// Read input from the textarea, and update the document to match.
+// When something is selected, it is present in the textarea, and
+// selected (unless it is huge, in which case a placeholder is
+// used). When nothing is selected, the cursor sits after previously
+// seen text (can be empty), which is stored in prevInput (we must
+// not reset the textarea when typing, because that breaks IME).
+TextareaInput.prototype.poll = function () {
+ var this$1 = this;
+
+ var cm = this.cm, input = this.textarea, prevInput = this.prevInput
+ // Since this is called a *lot*, try to bail out as cheaply as
+ // possible when it is clear that nothing happened. hasSelection
+ // will be the case when there is a lot of text in the textarea,
+ // in which case reading its value would be expensive.
+ if (this.contextMenuPending || !cm.state.focused ||
+ (hasSelection(input) && !prevInput && !this.composing) ||
+ cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
+ { return false }
+
+ var text = input.value
+ // If nothing changed, bail.
+ if (text == prevInput && !cm.somethingSelected()) { return false }
+ // Work around nonsensical selection resetting in IE9/10, and
+ // inexplicable appearance of private area unicode characters on
+ // some key combos in Mac (#2689).
+ if (ie && ie_version >= 9 && this.hasSelection === text ||
+ mac && /[\uf700-\uf7ff]/.test(text)) {
+ cm.display.input.reset()
+ return false
+ }
+
+ if (cm.doc.sel == cm.display.selForContextMenu) {
+ var first = text.charCodeAt(0)
+ if (first == 0x200b && !prevInput) { prevInput = "\u200b" }
+ if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") }
+ }
+ // Find the part of the input that is actually new
+ var same = 0, l = Math.min(prevInput.length, text.length)
+ while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same }
+
+ runInOp(cm, function () {
+ applyTextInput(cm, text.slice(same), prevInput.length - same,
+ null, this$1.composing ? "*compose" : null)
+
+ // Don't leave long text in the textarea, since it makes further polling slow
+ if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = "" }
+ else { this$1.prevInput = text }
+
+ if (this$1.composing) {
+ this$1.composing.range.clear()
+ this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"),
+ {className: "CodeMirror-composing"})
+ }
+ })
+ return true
+};
- function markTextShared(doc, from, to, options, type) {
- options = copyObj(options);
- options.shared = false;
- var markers = [markText(doc, from, to, options, type)], primary = markers[0];
- var widget = options.widgetNode;
- linkedDocs(doc, function(doc) {
- if (widget) options.widgetNode = widget.cloneNode(true);
- markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
- for (var i = 0; i < doc.linked.length; ++i)
- if (doc.linked[i].isParent) return;
- primary = lst(markers);
- });
- return new SharedTextMarker(markers, primary);
- }
+TextareaInput.prototype.ensurePolled = function () {
+ if (this.pollingFast && this.poll()) { this.pollingFast = false }
+};
- function findSharedMarkers(doc) {
- return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())),
- function(m) { return m.parent; });
- }
+TextareaInput.prototype.onKeyPress = function () {
+ if (ie && ie_version >= 9) { this.hasSelection = null }
+ this.fastPoll()
+};
- function copySharedMarkers(doc, markers) {
- for (var i = 0; i < markers.length; i++) {
- var marker = markers[i], pos = marker.find();
- var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
- if (cmp(mFrom, mTo)) {
- var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
- marker.markers.push(subMark);
- subMark.parent = marker;
+TextareaInput.prototype.onContextMenu = function (e) {
+ var input = this, cm = input.cm, display = cm.display, te = input.textarea
+ var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop
+ if (!pos || presto) { return } // Opera is difficult.
+
+ // Reset the current text selection only if the click is done outside of the selection
+ // and 'resetSelectionOnContextMenu' option is true.
+ var reset = cm.options.resetSelectionOnContextMenu
+ if (reset && cm.doc.sel.contains(pos) == -1)
+ { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll) }
+
+ var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText
+ input.wrapper.style.cssText = "position: absolute"
+ var wrapperBox = input.wrapper.getBoundingClientRect()
+ te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"
+ var oldScrollY
+ if (webkit) { oldScrollY = window.scrollY } // Work around Chrome issue (#2712)
+ display.input.focus()
+ if (webkit) { window.scrollTo(null, oldScrollY) }
+ display.input.reset()
+ // Adds "Select all" to context menu in FF
+ if (!cm.somethingSelected()) { te.value = input.prevInput = " " }
+ input.contextMenuPending = true
+ display.selForContextMenu = cm.doc.sel
+ clearTimeout(display.detectingSelectAll)
+
+ // Select-all will be greyed out if there's nothing to select, so
+ // this adds a zero-width space so that we can later check whether
+ // it got selected.
+ function prepareSelectAllHack() {
+ if (te.selectionStart != null) {
+ var selected = cm.somethingSelected()
+ var extval = "\u200b" + (selected ? te.value : "")
+ te.value = "\u21da" // Used to catch context-menu undo
+ te.value = extval
+ input.prevInput = selected ? "" : "\u200b"
+ te.selectionStart = 1; te.selectionEnd = extval.length
+ // Re-set this, in case some other handler touched the
+ // selection in the meantime.
+ display.selForContextMenu = cm.doc.sel
+ }
+ }
+ function rehide() {
+ input.contextMenuPending = false
+ input.wrapper.style.cssText = oldWrapperCSS
+ te.style.cssText = oldCSS
+ if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos) }
+
+ // Try to detect the user choosing select-all
+ if (te.selectionStart != null) {
+ if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack() }
+ var i = 0, poll = function () {
+ if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
+ te.selectionEnd > 0 && input.prevInput == "\u200b") {
+ operation(cm, selectAll)(cm)
+ } else if (i++ < 10) {
+ display.detectingSelectAll = setTimeout(poll, 500)
+ } else {
+ display.selForContextMenu = null
+ display.input.reset()
+ }
}
+ display.detectingSelectAll = setTimeout(poll, 200)
}
}
- function detachSharedMarkers(markers) {
- for (var i = 0; i < markers.length; i++) {
- var marker = markers[i], linked = [marker.primary.doc];;
- linkedDocs(marker.primary.doc, function(d) { linked.push(d); });
- for (var j = 0; j < marker.markers.length; j++) {
- var subMarker = marker.markers[j];
- if (indexOf(linked, subMarker.doc) == -1) {
- subMarker.parent = null;
- marker.markers.splice(j--, 1);
- }
- }
+ if (ie && ie_version >= 9) { prepareSelectAllHack() }
+ if (captureRightClick) {
+ e_stop(e)
+ var mouseup = function () {
+ off(window, "mouseup", mouseup)
+ setTimeout(rehide, 20)
}
+ on(window, "mouseup", mouseup)
+ } else {
+ setTimeout(rehide, 50)
}
+};
- // TEXTMARKER SPANS
+TextareaInput.prototype.readOnlyChanged = function (val) {
+ if (!val) { this.reset() }
+};
- function MarkedSpan(marker, from, to) {
- this.marker = marker;
- this.from = from; this.to = to;
- }
+TextareaInput.prototype.setUneditable = function () {};
+
+TextareaInput.prototype.needsContentAttribute = false
+
+function fromTextArea(textarea, options) {
+ options = options ? copyObj(options) : {}
+ options.value = textarea.value
+ if (!options.tabindex && textarea.tabIndex)
+ { options.tabindex = textarea.tabIndex }
+ if (!options.placeholder && textarea.placeholder)
+ { options.placeholder = textarea.placeholder }
+ // Set autofocus to true if this textarea is focused, or if it has
+ // autofocus and no other element is focused.
+ if (options.autofocus == null) {
+ var hasFocus = activeElt()
+ options.autofocus = hasFocus == textarea ||
+ textarea.getAttribute("autofocus") != null && hasFocus == document.body
+ }
+
+ function save() {textarea.value = cm.getValue()}
+
+ var realSubmit
+ if (textarea.form) {
+ on(textarea.form, "submit", save)
+ // Deplorable hack to make the submit method do the right thing.
+ if (!options.leaveSubmitMethodAlone) {
+ var form = textarea.form
+ realSubmit = form.submit
+ try {
+ var wrappedSubmit = form.submit = function () {
+ save()
+ form.submit = realSubmit
+ form.submit()
+ form.submit = wrappedSubmit
+ }
+ } catch(e) {}
+ }
+ }
+
+ options.finishInit = function (cm) {
+ cm.save = save
+ cm.getTextArea = function () { return textarea; }
+ cm.toTextArea = function () {
+ cm.toTextArea = isNaN // Prevent this from being ran twice
+ save()
+ textarea.parentNode.removeChild(cm.getWrapperElement())
+ textarea.style.display = ""
+ if (textarea.form) {
+ off(textarea.form, "submit", save)
+ if (typeof textarea.form.submit == "function")
+ { textarea.form.submit = realSubmit }
+ }
+ }
+ }
- // Search an array of spans for a span matching the given marker.
- function getMarkedSpanFor(spans, marker) {
- if (spans) for (var i = 0; i < spans.length; ++i) {
- var span = spans[i];
- if (span.marker == marker) return span;
- }
- }
- // Remove a span from an array, returning undefined if no spans are
- // left (we don't store arrays for lines without spans).
- function removeMarkedSpan(spans, span) {
- for (var r, i = 0; i < spans.length; ++i)
- if (spans[i] != span) (r || (r = [])).push(spans[i]);
- return r;
- }
- // Add a span to a line.
- function addMarkedSpan(line, span) {
- line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
- span.marker.attachLine(line);
- }
+ textarea.style.display = "none"
+ var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },
+ options)
+ return cm
+}
- // Used for the algorithm that adjusts markers for a change in the
- // document. These functions cut an array of spans at a given
- // character position, returning an array of remaining chunks (or
- // undefined if nothing remains).
- function markedSpansBefore(old, startCh, isInsert) {
- if (old) for (var i = 0, nw; i < old.length; ++i) {
- var span = old[i], marker = span.marker;
- var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
- if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
- var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);
- (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
- }
- }
- return nw;
- }
- function markedSpansAfter(old, endCh, isInsert) {
- if (old) for (var i = 0, nw; i < old.length; ++i) {
- var span = old[i], marker = span.marker;
- var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
- if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
- var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);
- (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
- span.to == null ? null : span.to - endCh));
- }
- }
- return nw;
- }
+function addLegacyProps(CodeMirror) {
+ CodeMirror.off = off
+ CodeMirror.on = on
+ CodeMirror.wheelEventPixels = wheelEventPixels
+ CodeMirror.Doc = Doc
+ CodeMirror.splitLines = splitLinesAuto
+ CodeMirror.countColumn = countColumn
+ CodeMirror.findColumn = findColumn
+ CodeMirror.isWordChar = isWordCharBasic
+ CodeMirror.Pass = Pass
+ CodeMirror.signal = signal
+ CodeMirror.Line = Line
+ CodeMirror.changeEnd = changeEnd
+ CodeMirror.scrollbarModel = scrollbarModel
+ CodeMirror.Pos = Pos
+ CodeMirror.cmpPos = cmp
+ CodeMirror.modes = modes
+ CodeMirror.mimeModes = mimeModes
+ CodeMirror.resolveMode = resolveMode
+ CodeMirror.getMode = getMode
+ CodeMirror.modeExtensions = modeExtensions
+ CodeMirror.extendMode = extendMode
+ CodeMirror.copyState = copyState
+ CodeMirror.startState = startState
+ CodeMirror.innerMode = innerMode
+ CodeMirror.commands = commands
+ CodeMirror.keyMap = keyMap
+ CodeMirror.keyName = keyName
+ CodeMirror.isModifierKey = isModifierKey
+ CodeMirror.lookupKey = lookupKey
+ CodeMirror.normalizeKeyMap = normalizeKeyMap
+ CodeMirror.StringStream = StringStream
+ CodeMirror.SharedTextMarker = SharedTextMarker
+ CodeMirror.TextMarker = TextMarker
+ CodeMirror.LineWidget = LineWidget
+ CodeMirror.e_preventDefault = e_preventDefault
+ CodeMirror.e_stopPropagation = e_stopPropagation
+ CodeMirror.e_stop = e_stop
+ CodeMirror.addClass = addClass
+ CodeMirror.contains = contains
+ CodeMirror.rmClass = rmClass
+ CodeMirror.keyNames = keyNames
+}
- // Given a change object, compute the new set of marker spans that
- // cover the line in which the change took place. Removes spans
- // entirely within the change, reconnects spans belonging to the
- // same marker that appear on both sides of the change, and cuts off
- // spans partially within the change. Returns an array of span
- // arrays with one element for each line in (after) the change.
- function stretchSpansOverChange(doc, change) {
- if (change.full) return null;
- var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
- var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
- if (!oldFirst && !oldLast) return null;
+// EDITOR CONSTRUCTOR
- var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
- // Get the spans that 'stick out' on both sides
- var first = markedSpansBefore(oldFirst, startCh, isInsert);
- var last = markedSpansAfter(oldLast, endCh, isInsert);
+defineOptions(CodeMirror)
- // Next, merge those two ends
- var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
- if (first) {
- // Fix up .to properties of first
- for (var i = 0; i < first.length; ++i) {
- var span = first[i];
- if (span.to == null) {
- var found = getMarkedSpanFor(last, span.marker);
- if (!found) span.to = startCh;
- else if (sameLine) span.to = found.to == null ? null : found.to + offset;
- }
- }
- }
- if (last) {
- // Fix up .from in last (or move them into first in case of sameLine)
- for (var i = 0; i < last.length; ++i) {
- var span = last[i];
- if (span.to != null) span.to += offset;
- if (span.from == null) {
- var found = getMarkedSpanFor(first, span.marker);
- if (!found) {
- span.from = offset;
- if (sameLine) (first || (first = [])).push(span);
- }
- } else {
- span.from += offset;
- if (sameLine) (first || (first = [])).push(span);
- }
- }
- }
- // Make sure we didn't create any zero-length spans
- if (first) first = clearEmptySpans(first);
- if (last && last != first) last = clearEmptySpans(last);
+addEditorMethods(CodeMirror)
- var newMarkers = [first];
- if (!sameLine) {
- // Fill gap with whole-line-spans
- var gap = change.text.length - 2, gapMarkers;
- if (gap > 0 && first)
- for (var i = 0; i < first.length; ++i)
- if (first[i].to == null)
- (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null));
- for (var i = 0; i < gap; ++i)
- newMarkers.push(gapMarkers);
- newMarkers.push(last);
- }
- return newMarkers;
- }
+// Set up methods on CodeMirror's prototype to redirect to the editor's document.
+var dontDelegate = "iter insert remove copy getEditor constructor".split(" ")
+for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
+ { CodeMirror.prototype[prop] = (function(method) {
+ return function() {return method.apply(this.doc, arguments)}
+ })(Doc.prototype[prop]) } }
- // Remove spans that are empty and don't have a clearWhenEmpty
- // option of false.
- function clearEmptySpans(spans) {
- for (var i = 0; i < spans.length; ++i) {
- var span = spans[i];
- if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
- spans.splice(i--, 1);
- }
- if (!spans.length) return null;
- return spans;
- }
+eventMixin(Doc)
- // Used for un/re-doing changes from the history. Combines the
- // result of computing the existing spans with the set of spans that
- // existed in the history (so that deleting around a span and then
- // undoing brings back the span).
- function mergeOldSpans(doc, change) {
- var old = getOldSpans(doc, change);
- var stretched = stretchSpansOverChange(doc, change);
- if (!old) return stretched;
- if (!stretched) return old;
+// INPUT HANDLING
- for (var i = 0; i < old.length; ++i) {
- var oldCur = old[i], stretchCur = stretched[i];
- if (oldCur && stretchCur) {
- spans: for (var j = 0; j < stretchCur.length; ++j) {
- var span = stretchCur[j];
- for (var k = 0; k < oldCur.length; ++k)
- if (oldCur[k].marker == span.marker) continue spans;
- oldCur.push(span);
- }
- } else if (stretchCur) {
- old[i] = stretchCur;
- }
- }
- return old;
- }
+CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput}
- // Used to 'clip' out readOnly ranges when making a change.
- function removeReadOnlyRanges(doc, from, to) {
- var markers = null;
- doc.iter(from.line, to.line + 1, function(line) {
- if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) {
- var mark = line.markedSpans[i].marker;
- if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
- (markers || (markers = [])).push(mark);
- }
- });
- if (!markers) return null;
- var parts = [{from: from, to: to}];
- for (var i = 0; i < markers.length; ++i) {
- var mk = markers[i], m = mk.find(0);
- for (var j = 0; j < parts.length; ++j) {
- var p = parts[j];
- if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue;
- var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
- if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
- newParts.push({from: p.from, to: m.from});
- if (dto > 0 || !mk.inclusiveRight && !dto)
- newParts.push({from: m.to, to: p.to});
- parts.splice.apply(parts, newParts);
- j += newParts.length - 1;
- }
- }
- return parts;
- }
-
- // Connect or disconnect spans from a line.
- function detachMarkedSpans(line) {
- var spans = line.markedSpans;
- if (!spans) return;
- for (var i = 0; i < spans.length; ++i)
- spans[i].marker.detachLine(line);
- line.markedSpans = null;
- }
- function attachMarkedSpans(line, spans) {
- if (!spans) return;
- for (var i = 0; i < spans.length; ++i)
- spans[i].marker.attachLine(line);
- line.markedSpans = spans;
- }
-
- // Helpers used when computing which overlapping collapsed span
- // counts as the larger one.
- function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; }
- function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; }
-
- // Returns a number indicating which of two overlapping collapsed
- // spans is larger (and thus includes the other). Falls back to
- // comparing ids when the spans cover exactly the same range.
- function compareCollapsedMarkers(a, b) {
- var lenDiff = a.lines.length - b.lines.length;
- if (lenDiff != 0) return lenDiff;
- var aPos = a.find(), bPos = b.find();
- var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
- if (fromCmp) return -fromCmp;
- var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
- if (toCmp) return toCmp;
- return b.id - a.id;
- }
-
- // Find out whether a line ends or starts in a collapsed span. If
- // so, return the marker for that span.
- function collapsedSpanAtSide(line, start) {
- var sps = sawCollapsedSpans && line.markedSpans, found;
- if (sps) for (var sp, i = 0; i < sps.length; ++i) {
- sp = sps[i];
- if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
- (!found || compareCollapsedMarkers(found, sp.marker) < 0))
- found = sp.marker;
- }
- return found;
- }
- function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); }
- function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); }
-
- // Test whether there exists a collapsed span that partially
- // overlaps (covers the start or end, but not both) of a new span.
- // Such overlap is not allowed.
- function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
- var line = getLine(doc, lineNo);
- var sps = sawCollapsedSpans && line.markedSpans;
- if (sps) for (var i = 0; i < sps.length; ++i) {
- var sp = sps[i];
- if (!sp.marker.collapsed) continue;
- var found = sp.marker.find(0);
- var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
- var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
- if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue;
- if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
- fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
- return true;
- }
- }
+// MODE DEFINITION AND QUERYING
- // A visual line is a line as drawn on the screen. Folding, for
- // example, can cause multiple logical lines to appear on the same
- // visual line. This finds the start of the visual line that the
- // given line is part of (usually that is the line itself).
- function visualLine(line) {
- var merged;
- while (merged = collapsedSpanAtStart(line))
- line = merged.find(-1, true).line;
- return line;
- }
-
- // Returns an array of logical lines that continue the visual line
- // started by the argument, or undefined if there are no such lines.
- function visualLineContinued(line) {
- var merged, lines;
- while (merged = collapsedSpanAtEnd(line)) {
- line = merged.find(1, true).line;
- (lines || (lines = [])).push(line);
- }
- return lines;
- }
-
- // Get the line number of the start of the visual line that the
- // given line number is part of.
- function visualLineNo(doc, lineN) {
- var line = getLine(doc, lineN), vis = visualLine(line);
- if (line == vis) return lineN;
- return lineNo(vis);
- }
- // Get the line number of the start of the next visual line after
- // the given line.
- function visualLineEndNo(doc, lineN) {
- if (lineN > doc.lastLine()) return lineN;
- var line = getLine(doc, lineN), merged;
- if (!lineIsHidden(doc, line)) return lineN;
- while (merged = collapsedSpanAtEnd(line))
- line = merged.find(1, true).line;
- return lineNo(line) + 1;
- }
-
- // Compute whether a line is hidden. Lines count as hidden when they
- // are part of a visual line that starts with another line, or when
- // they are entirely covered by collapsed, non-widget span.
- function lineIsHidden(doc, line) {
- var sps = sawCollapsedSpans && line.markedSpans;
- if (sps) for (var sp, i = 0; i < sps.length; ++i) {
- sp = sps[i];
- if (!sp.marker.collapsed) continue;
- if (sp.from == null) return true;
- if (sp.marker.widgetNode) continue;
- if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
- return true;
- }
- }
- function lineIsHiddenInner(doc, line, span) {
- if (span.to == null) {
- var end = span.marker.find(1, true);
- return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker));
- }
- if (span.marker.inclusiveRight && span.to == line.text.length)
- return true;
- for (var sp, i = 0; i < line.markedSpans.length; ++i) {
- sp = line.markedSpans[i];
- if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
- (sp.to == null || sp.to != span.from) &&
- (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
- lineIsHiddenInner(doc, line, sp)) return true;
- }
- }
+// Extra arguments are stored as the mode's dependencies, which is
+// used by (legacy) mechanisms like loadmode.js to automatically
+// load a mode. (Preferred mechanism is the require/define calls.)
+CodeMirror.defineMode = function(name/*, mode, …*/) {
+ if (!CodeMirror.defaults.mode && name != "null") { CodeMirror.defaults.mode = name }
+ defineMode.apply(this, arguments)
+}
- // LINE WIDGETS
+CodeMirror.defineMIME = defineMIME
- // Line widgets are block elements displayed above or below a line.
+// Minimal default mode.
+CodeMirror.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); })
+CodeMirror.defineMIME("text/plain", "null")
+
+// EXTENSIONS
+
+CodeMirror.defineExtension = function (name, func) {
+ CodeMirror.prototype[name] = func
+}
+CodeMirror.defineDocExtension = function (name, func) {
+ Doc.prototype[name] = func
+}
- var LineWidget = CodeMirror.LineWidget = function(doc, node, options) {
- if (options) for (var opt in options) if (options.hasOwnProperty(opt))
- this[opt] = options[opt];
- this.doc = doc;
- this.node = node;
- };
- eventMixin(LineWidget);
-
- function adjustScrollWhenAboveVisible(cm, line, diff) {
- if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
- addToScrollPos(cm, null, diff);
- }
-
- LineWidget.prototype.clear = function() {
- var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
- if (no == null || !ws) return;
- for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1);
- if (!ws.length) line.widgets = null;
- var height = widgetHeight(this);
- updateLineHeight(line, Math.max(0, line.height - height));
- if (cm) runInOp(cm, function() {
- adjustScrollWhenAboveVisible(cm, line, -height);
- regLineChange(cm, no, "widget");
- });
- };
- LineWidget.prototype.changed = function() {
- var oldH = this.height, cm = this.doc.cm, line = this.line;
- this.height = null;
- var diff = widgetHeight(this) - oldH;
- if (!diff) return;
- updateLineHeight(line, line.height + diff);
- if (cm) runInOp(cm, function() {
- cm.curOp.forceUpdate = true;
- adjustScrollWhenAboveVisible(cm, line, diff);
- });
- };
+CodeMirror.fromTextArea = fromTextArea
- function widgetHeight(widget) {
- if (widget.height != null) return widget.height;
- var cm = widget.doc.cm;
- if (!cm) return 0;
- if (!contains(document.body, widget.node)) {
- var parentStyle = "position: relative;";
- if (widget.coverGutter)
- parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;";
- if (widget.noHScroll)
- parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;";
- removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
- }
- return widget.height = widget.node.parentNode.offsetHeight;
- }
-
- function addLineWidget(doc, handle, node, options) {
- var widget = new LineWidget(doc, node, options);
- var cm = doc.cm;
- if (cm && widget.noHScroll) cm.display.alignWidgets = true;
- changeLine(doc, handle, "widget", function(line) {
- var widgets = line.widgets || (line.widgets = []);
- if (widget.insertAt == null) widgets.push(widget);
- else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget);
- widget.line = line;
- if (cm && !lineIsHidden(doc, line)) {
- var aboveVisible = heightAtLine(line) < doc.scrollTop;
- updateLineHeight(line, line.height + widgetHeight(widget));
- if (aboveVisible) addToScrollPos(cm, null, widget.height);
- cm.curOp.forceUpdate = true;
- }
- return true;
+addLegacyProps(CodeMirror)
+
+CodeMirror.version = "5.24.0"
+
+return CodeMirror;
+
+})));
+},{}],2:[function(require,module,exports){
+(function (global){
+/*!
+ * deep-diff.
+ * Licensed under the MIT License.
+ */
+;(function(root, factory) {
+ 'use strict';
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define([], function() {
+ return factory();
});
- return widget;
+ } else if (typeof exports === 'object') {
+ // Node. Does not work with strict CommonJS, but
+ // only CommonJS-like environments that support module.exports,
+ // like Node.
+ module.exports = factory();
+ } else {
+ // Browser globals (root is window)
+ root.DeepDiff = factory();
}
+}(this, function(undefined) {
+ 'use strict';
- // LINE DATA STRUCTURE
-
- // Line objects. These hold state related to a line, including
- // highlighting info (the styles array).
- var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) {
- this.text = text;
- attachMarkedSpans(this, markedSpans);
- this.height = estimateHeight ? estimateHeight(this) : 1;
- };
- eventMixin(Line);
- Line.prototype.lineNo = function() { return lineNo(this); };
-
- // Change the content (text, markers) of a line. Automatically
- // invalidates cached information and tries to re-estimate the
- // line's height.
- function updateLine(line, text, markedSpans, estimateHeight) {
- line.text = text;
- if (line.stateAfter) line.stateAfter = null;
- if (line.styles) line.styles = null;
- if (line.order != null) line.order = null;
- detachMarkedSpans(line);
- attachMarkedSpans(line, markedSpans);
- var estHeight = estimateHeight ? estimateHeight(line) : 1;
- if (estHeight != line.height) updateLineHeight(line, estHeight);
- }
-
- // Detach a line from the document tree and its markers.
- function cleanUpLine(line) {
- line.parent = null;
- detachMarkedSpans(line);
- }
-
- function extractLineClasses(type, output) {
- if (type) for (;;) {
- var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
- if (!lineClass) break;
- type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
- var prop = lineClass[1] ? "bgClass" : "textClass";
- if (output[prop] == null)
- output[prop] = lineClass[2];
- else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
- output[prop] += " " + lineClass[2];
- }
- return type;
+ var $scope, conflict, conflictResolution = [];
+ if (typeof global === 'object' && global) {
+ $scope = global;
+ } else if (typeof window !== 'undefined') {
+ $scope = window;
+ } else {
+ $scope = {};
}
-
- function callBlankLine(mode, state) {
- if (mode.blankLine) return mode.blankLine(state);
- if (!mode.innerMode) return;
- var inner = CodeMirror.innerMode(mode, state);
- if (inner.mode.blankLine) return inner.mode.blankLine(inner.state);
- }
-
- function readToken(mode, stream, state, inner) {
- for (var i = 0; i < 10; i++) {
- if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode;
- var style = mode.token(stream, state);
- if (stream.pos > stream.start) return style;
- }
- throw new Error("Mode " + mode.name + " failed to advance stream.");
- }
-
- // Utility for getTokenAt and getLineTokens
- function takeToken(cm, pos, precise, asArray) {
- function getObj(copy) {
- return {start: stream.start, end: stream.pos,
- string: stream.current(),
- type: style || null,
- state: copy ? copyState(doc.mode, state) : state};
- }
-
- var doc = cm.doc, mode = doc.mode, style;
- pos = clipPos(doc, pos);
- var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise);
- var stream = new StringStream(line.text, cm.options.tabSize), tokens;
- if (asArray) tokens = [];
- while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
- stream.start = stream.pos;
- style = readToken(mode, stream, state);
- if (asArray) tokens.push(getObj(true));
- }
- return asArray ? tokens : getObj();
- }
-
- // Run the given mode's parser over a line, calling f for each token.
- function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
- var flattenSpans = mode.flattenSpans;
- if (flattenSpans == null) flattenSpans = cm.options.flattenSpans;
- var curStart = 0, curStyle = null;
- var stream = new StringStream(text, cm.options.tabSize), style;
- var inner = cm.options.addModeClass && [null];
- if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses);
- while (!stream.eol()) {
- if (stream.pos > cm.options.maxHighlightLength) {
- flattenSpans = false;
- if (forceToEnd) processLine(cm, text, state, stream.pos);
- stream.pos = text.length;
- style = null;
- } else {
- style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses);
- }
- if (inner) {
- var mName = inner[0].name;
- if (mName) style = "m-" + (style ? mName + " " + style : mName);
- }
- if (!flattenSpans || curStyle != style) {
- while (curStart < stream.start) {
- curStart = Math.min(stream.start, curStart + 50000);
- f(curStart, curStyle);
- }
- curStyle = style;
- }
- stream.start = stream.pos;
- }
- while (curStart < stream.pos) {
- // Webkit seems to refuse to render text nodes longer than 57444 characters
- var pos = Math.min(stream.pos, curStart + 50000);
- f(pos, curStyle);
- curStart = pos;
- }
- }
-
- // Compute a style array (an array starting with a mode generation
- // -- for invalidation -- followed by pairs of end positions and
- // style strings), which is used to highlight the tokens on the
- // line.
- function highlightLine(cm, line, state, forceToEnd) {
- // A styles array always starts with a number identifying the
- // mode/overlays that it is based on (for easy invalidation).
- var st = [cm.state.modeGen], lineClasses = {};
- // Compute the base array of styles
- runMode(cm, line.text, cm.doc.mode, state, function(end, style) {
- st.push(end, style);
- }, lineClasses, forceToEnd);
-
- // Run overlays, adjust style array.
- for (var o = 0; o < cm.state.overlays.length; ++o) {
- var overlay = cm.state.overlays[o], i = 1, at = 0;
- runMode(cm, line.text, overlay.mode, true, function(end, style) {
- var start = i;
- // Ensure there's a token end at the current position, and that i points at it
- while (at < end) {
- var i_end = st[i];
- if (i_end > end)
- st.splice(i, 1, end, st[i+1], i_end);
- i += 2;
- at = Math.min(end, i_end);
- }
- if (!style) return;
- if (overlay.opaque) {
- st.splice(start, i - start, end, "cm-overlay " + style);
- i = start + 2;
- } else {
- for (; start < i; start += 2) {
- var cur = st[start+1];
- st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style;
- }
+ conflict = $scope.DeepDiff;
+ if (conflict) {
+ conflictResolution.push(
+ function() {
+ if ('undefined' !== typeof conflict && $scope.DeepDiff === accumulateDiff) {
+ $scope.DeepDiff = conflict;
+ conflict = undefined;
}
- }, lineClasses);
- }
-
- return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null};
- }
-
- function getLineStyles(cm, line, updateFrontier) {
- if (!line.styles || line.styles[0] != cm.state.modeGen) {
- var state = getStateBefore(cm, lineNo(line));
- var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state);
- line.stateAfter = state;
- line.styles = result.styles;
- if (result.classes) line.styleClasses = result.classes;
- else if (line.styleClasses) line.styleClasses = null;
- if (updateFrontier === cm.doc.frontier) cm.doc.frontier++;
- }
- return line.styles;
- }
-
- // Lightweight form of highlight -- proceed over this line and
- // update state, but don't save a style array. Used for lines that
- // aren't currently visible.
- function processLine(cm, text, state, startAt) {
- var mode = cm.doc.mode;
- var stream = new StringStream(text, cm.options.tabSize);
- stream.start = stream.pos = startAt || 0;
- if (text == "") callBlankLine(mode, state);
- while (!stream.eol()) {
- readToken(mode, stream, state);
- stream.start = stream.pos;
- }
- }
-
- // Convert a style as returned by a mode (either null, or a string
- // containing one or more styles) to a CSS style. This is cached,
- // and also looks for line-wide styles.
- var styleToClassCache = {}, styleToClassCacheWithMode = {};
- function interpretTokenStyle(style, options) {
- if (!style || /^\s*$/.test(style)) return null;
- var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
- return cache[style] ||
- (cache[style] = style.replace(/\S+/g, "cm-$&"));
- }
-
- // Render the DOM representation of the text of a line. Also builds
- // up a 'line map', which points at the DOM nodes that represent
- // specific stretches of text, and is used by the measuring code.
- // The returned object contains the DOM node, this map, and
- // information about line-wide styles that were set by the mode.
- function buildLineContent(cm, lineView) {
- // The padding-right forces the element to have a 'border', which
- // is needed on Webkit to be able to get line-level bounding
- // rectangles for it (in measureChar).
- var content = elt("span", null, null, webkit ? "padding-right: .1px" : null);
- var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
- col: 0, pos: 0, cm: cm,
- splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
- lineView.measure = {};
-
- // Iterate over the logical lines that make up this visual line.
- for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
- var line = i ? lineView.rest[i - 1] : lineView.line, order;
- builder.pos = 0;
- builder.addToken = buildToken;
- // Optionally wire in some hacks into the token-rendering
- // algorithm, to deal with browser quirks.
- if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
- builder.addToken = buildTokenBadBidi(builder.addToken, order);
- builder.map = [];
- var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
- insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
- if (line.styleClasses) {
- if (line.styleClasses.bgClass)
- builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "");
- if (line.styleClasses.textClass)
- builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "");
- }
-
- // Ensure at least a single node is present, for measuring.
- if (builder.map.length == 0)
- builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure)));
-
- // Store the map and a cache object for the current logical line
- if (i == 0) {
- lineView.measure.map = builder.map;
- lineView.measure.cache = {};
- } else {
- (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map);
- (lineView.measure.caches || (lineView.measure.caches = [])).push({});
+ });
+ }
+
+ // nodejs compatible on server side and in the browser.
+ function inherits(ctor, superCtor) {
+ ctor.super_ = superCtor;
+ ctor.prototype = Object.create(superCtor.prototype, {
+ constructor: {
+ value: ctor,
+ enumerable: false,
+ writable: true,
+ configurable: true
}
- }
+ });
+ }
- // See issue #2901
- if (webkit) {
- var last = builder.content.lastChild
- if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
- builder.content.className = "cm-tab-wrap-hack";
+ function Diff(kind, path) {
+ Object.defineProperty(this, 'kind', {
+ value: kind,
+ enumerable: true
+ });
+ if (path && path.length) {
+ Object.defineProperty(this, 'path', {
+ value: path,
+ enumerable: true
+ });
}
+ }
- signal(cm, "renderLine", cm, lineView.line, builder.pre);
- if (builder.pre.className)
- builder.textClass = joinClasses(builder.pre.className, builder.textClass || "");
+ function DiffEdit(path, origin, value) {
+ DiffEdit.super_.call(this, 'E', path);
+ Object.defineProperty(this, 'lhs', {
+ value: origin,
+ enumerable: true
+ });
+ Object.defineProperty(this, 'rhs', {
+ value: value,
+ enumerable: true
+ });
+ }
+ inherits(DiffEdit, Diff);
- return builder;
+ function DiffNew(path, value) {
+ DiffNew.super_.call(this, 'N', path);
+ Object.defineProperty(this, 'rhs', {
+ value: value,
+ enumerable: true
+ });
}
+ inherits(DiffNew, Diff);
- function defaultSpecialCharPlaceholder(ch) {
- var token = elt("span", "\u2022", "cm-invalidchar");
- token.title = "\\u" + ch.charCodeAt(0).toString(16);
- token.setAttribute("aria-label", token.title);
- return token;
+ function DiffDeleted(path, value) {
+ DiffDeleted.super_.call(this, 'D', path);
+ Object.defineProperty(this, 'lhs', {
+ value: value,
+ enumerable: true
+ });
}
+ inherits(DiffDeleted, Diff);
- // Build up the DOM representation for a single token, and add it to
- // the line map. Takes care to render special characters separately.
- function buildToken(builder, text, style, startStyle, endStyle, title, css) {
- if (!text) return;
- var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text;
- var special = builder.cm.state.specialChars, mustWrap = false;
- if (!special.test(text)) {
- builder.col += text.length;
- var content = document.createTextNode(displayText);
- builder.map.push(builder.pos, builder.pos + text.length, content);
- if (ie && ie_version < 9) mustWrap = true;
- builder.pos += text.length;
- } else {
- var content = document.createDocumentFragment(), pos = 0;
- while (true) {
- special.lastIndex = pos;
- var m = special.exec(text);
- var skipped = m ? m.index - pos : text.length - pos;
- if (skipped) {
- var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
- if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
- else content.appendChild(txt);
- builder.map.push(builder.pos, builder.pos + skipped, txt);
- builder.col += skipped;
- builder.pos += skipped;
- }
- if (!m) break;
- pos += skipped + 1;
- if (m[0] == "\t") {
- var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
- var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
- txt.setAttribute("role", "presentation");
- txt.setAttribute("cm-text", "\t");
- builder.col += tabWidth;
- } else if (m[0] == "\r" || m[0] == "\n") {
- var txt = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"));
- txt.setAttribute("cm-text", m[0]);
- builder.col += 1;
- } else {
- var txt = builder.cm.options.specialCharPlaceholder(m[0]);
- txt.setAttribute("cm-text", m[0]);
- if (ie && ie_version < 9) content.appendChild(elt("span", [txt]));
- else content.appendChild(txt);
- builder.col += 1;
- }
- builder.map.push(builder.pos, builder.pos + 1, txt);
- builder.pos++;
- }
- }
- if (style || startStyle || endStyle || mustWrap || css) {
- var fullStyle = style || "";
- if (startStyle) fullStyle += startStyle;
- if (endStyle) fullStyle += endStyle;
- var token = elt("span", [content], fullStyle, css);
- if (title) token.title = title;
- return builder.content.appendChild(token);
- }
- builder.content.appendChild(content);
- }
-
- function splitSpaces(old) {
- var out = " ";
- for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0";
- out += " ";
- return out;
- }
-
- // Work around nonsense dimensions being reported for stretches of
- // right-to-left text.
- function buildTokenBadBidi(inner, order) {
- return function(builder, text, style, startStyle, endStyle, title, css) {
- style = style ? style + " cm-force-border" : "cm-force-border";
- var start = builder.pos, end = start + text.length;
- for (;;) {
- // Find the part that overlaps with the start of this text
- for (var i = 0; i < order.length; i++) {
- var part = order[i];
- if (part.to > start && part.from <= start) break;
- }
- if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title, css);
- inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css);
- startStyle = null;
- text = text.slice(part.to - start);
- start = part.to;
- }
- };
+ function DiffArray(path, index, item) {
+ DiffArray.super_.call(this, 'A', path);
+ Object.defineProperty(this, 'index', {
+ value: index,
+ enumerable: true
+ });
+ Object.defineProperty(this, 'item', {
+ value: item,
+ enumerable: true
+ });
}
+ inherits(DiffArray, Diff);
- function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
- var widget = !ignoreWidget && marker.widgetNode;
- if (widget) builder.map.push(builder.pos, builder.pos + size, widget);
- if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
- if (!widget)
- widget = builder.content.appendChild(document.createElement("span"));
- widget.setAttribute("cm-marker", marker.id);
- }
- if (widget) {
- builder.cm.display.input.setUneditable(widget);
- builder.content.appendChild(widget);
- }
- builder.pos += size;
+ function arrayRemove(arr, from, to) {
+ var rest = arr.slice((to || from) + 1 || arr.length);
+ arr.length = from < 0 ? arr.length + from : from;
+ arr.push.apply(arr, rest);
+ return arr;
}
- // Outputs a number of spans to make up a line, taking highlighting
- // and marked text into account.
- function insertLineContent(line, builder, styles) {
- var spans = line.markedSpans, allText = line.text, at = 0;
- if (!spans) {
- for (var i = 1; i < styles.length; i+=2)
- builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options));
- return;
+ function realTypeOf(subject) {
+ var type = typeof subject;
+ if (type !== 'object') {
+ return type;
}
- var len = allText.length, pos = 0, i = 1, text = "", style, css;
- var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
- for (;;) {
- if (nextChange == pos) { // Update current marker set
- spanStyle = spanEndStyle = spanStartStyle = title = css = "";
- collapsed = null; nextChange = Infinity;
- var foundBookmarks = [], endStyles
- for (var j = 0; j < spans.length; ++j) {
- var sp = spans[j], m = sp.marker;
- if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
- foundBookmarks.push(m);
- } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
- if (sp.to != null && sp.to != pos && nextChange > sp.to) {
- nextChange = sp.to;
- spanEndStyle = "";
+ if (subject === Math) {
+ return 'math';
+ } else if (subject === null) {
+ return 'null';
+ } else if (Array.isArray(subject)) {
+ return 'array';
+ } else if (Object.prototype.toString.call(subject) === '[object Date]') {
+ return 'date';
+ } else if (typeof subject.toString !== 'undefined' && /^\/.*\//.test(subject.toString())) {
+ return 'regexp';
+ }
+ return 'object';
+ }
+
+ function deepDiff(lhs, rhs, changes, prefilter, path, key, stack) {
+ path = path || [];
+ var currentPath = path.slice(0);
+ if (typeof key !== 'undefined') {
+ if (prefilter) {
+ if (typeof(prefilter) === 'function' && prefilter(currentPath, key)) { return; }
+ else if (typeof(prefilter) === 'object') {
+ if (prefilter.prefilter && prefilter.prefilter(currentPath, key)) { return; }
+ if (prefilter.normalize) {
+ var alt = prefilter.normalize(currentPath, key, lhs, rhs);
+ if (alt) {
+ lhs = alt[0];
+ rhs = alt[1];
}
- if (m.className) spanStyle += " " + m.className;
- if (m.css) css = (css ? css + ";" : "") + m.css;
- if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle;
- if (m.endStyle && sp.to == nextChange) (endStyles || (endStyles = [])).push(m.endStyle, sp.to)
- if (m.title && !title) title = m.title;
- if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
- collapsed = sp;
- } else if (sp.from > pos && nextChange > sp.from) {
- nextChange = sp.from;
}
}
- if (endStyles) for (var j = 0; j < endStyles.length; j += 2)
- if (endStyles[j + 1] == nextChange) spanEndStyle += " " + endStyles[j]
-
- if (!collapsed || collapsed.from == pos) for (var j = 0; j < foundBookmarks.length; ++j)
- buildCollapsedSpan(builder, 0, foundBookmarks[j]);
- if (collapsed && (collapsed.from || 0) == pos) {
- buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
- collapsed.marker, collapsed.from == null);
- if (collapsed.to == null) return;
- if (collapsed.to == pos) collapsed = false;
- }
}
- if (pos >= len) break;
-
- var upto = Math.min(len, nextChange);
- while (true) {
- if (text) {
- var end = pos + text.length;
- if (!collapsed) {
- var tokenText = end > upto ? text.slice(0, upto - pos) : text;
- builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
- spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css);
+ currentPath.push(key);
+ }
+
+ // Use string comparison for regexes
+ if (realTypeOf(lhs) === 'regexp' && realTypeOf(rhs) === 'regexp') {
+ lhs = lhs.toString();
+ rhs = rhs.toString();
+ }
+
+ var ltype = typeof lhs;
+ var rtype = typeof rhs;
+ if (ltype === 'undefined') {
+ if (rtype !== 'undefined') {
+ changes(new DiffNew(currentPath, rhs));
+ }
+ } else if (rtype === 'undefined') {
+ changes(new DiffDeleted(currentPath, lhs));
+ } else if (realTypeOf(lhs) !== realTypeOf(rhs)) {
+ changes(new DiffEdit(currentPath, lhs, rhs));
+ } else if (Object.prototype.toString.call(lhs) === '[object Date]' && Object.prototype.toString.call(rhs) === '[object Date]' && ((lhs - rhs) !== 0)) {
+ changes(new DiffEdit(currentPath, lhs, rhs));
+ } else if (ltype === 'object' && lhs !== null && rhs !== null) {
+ stack = stack || [];
+ if (stack.indexOf(lhs) < 0) {
+ stack.push(lhs);
+ if (Array.isArray(lhs)) {
+ var i, len = lhs.length;
+ for (i = 0; i < lhs.length; i++) {
+ if (i >= rhs.length) {
+ changes(new DiffArray(currentPath, i, new DiffDeleted(undefined, lhs[i])));
+ } else {
+ deepDiff(lhs[i], rhs[i], changes, prefilter, currentPath, i, stack);
+ }
+ }
+ while (i < rhs.length) {
+ changes(new DiffArray(currentPath, i, new DiffNew(undefined, rhs[i++])));
}
- if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
- pos = end;
- spanStartStyle = "";
+ } else {
+ var akeys = Object.keys(lhs);
+ var pkeys = Object.keys(rhs);
+ akeys.forEach(function(k, i) {
+ var other = pkeys.indexOf(k);
+ if (other >= 0) {
+ deepDiff(lhs[k], rhs[k], changes, prefilter, currentPath, k, stack);
+ pkeys = arrayRemove(pkeys, other);
+ } else {
+ deepDiff(lhs[k], undefined, changes, prefilter, currentPath, k, stack);
+ }
+ });
+ pkeys.forEach(function(k) {
+ deepDiff(undefined, rhs[k], changes, prefilter, currentPath, k, stack);
+ });
}
- text = allText.slice(at, at = styles[i++]);
- style = interpretTokenStyle(styles[i++], builder.cm.options);
+ stack.length = stack.length - 1;
+ }
+ } else if (lhs !== rhs) {
+ if (!(ltype === 'number' && isNaN(lhs) && isNaN(rhs))) {
+ changes(new DiffEdit(currentPath, lhs, rhs));
}
}
}
- // DOCUMENT DATA STRUCTURE
-
- // By default, updates that start and end at the beginning of a line
- // are treated specially, in order to make the association of line
- // widgets and marker elements with the text behave more intuitive.
- function isWholeLineUpdate(doc, change) {
- return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
- (!doc.cm || doc.cm.options.wholeLineUpdateBefore);
+ function accumulateDiff(lhs, rhs, prefilter, accum) {
+ accum = accum || [];
+ deepDiff(lhs, rhs,
+ function(diff) {
+ if (diff) {
+ accum.push(diff);
+ }
+ },
+ prefilter);
+ return (accum.length) ? accum : undefined;
}
- // Perform a change on the document data structure.
- function updateDoc(doc, change, markedSpans, estimateHeight) {
- function spansFor(n) {return markedSpans ? markedSpans[n] : null;}
- function update(line, text, spans) {
- updateLine(line, text, spans, estimateHeight);
- signalLater(line, "change", line, change);
+ function applyArrayChange(arr, index, change) {
+ if (change.path && change.path.length) {
+ var it = arr[index],
+ i, u = change.path.length - 1;
+ for (i = 0; i < u; i++) {
+ it = it[change.path[i]];
+ }
+ switch (change.kind) {
+ case 'A':
+ applyArrayChange(it[change.path[i]], change.index, change.item);
+ break;
+ case 'D':
+ delete it[change.path[i]];
+ break;
+ case 'E':
+ case 'N':
+ it[change.path[i]] = change.rhs;
+ break;
+ }
+ } else {
+ switch (change.kind) {
+ case 'A':
+ applyArrayChange(arr[index], change.index, change.item);
+ break;
+ case 'D':
+ arr = arrayRemove(arr, index);
+ break;
+ case 'E':
+ case 'N':
+ arr[index] = change.rhs;
+ break;
+ }
}
- function linesFor(start, end) {
- for (var i = start, result = []; i < end; ++i)
- result.push(new Line(text[i], spansFor(i), estimateHeight));
- return result;
+ return arr;
+ }
+
+ function applyChange(target, source, change) {
+ if (target && source && change && change.kind) {
+ var it = target,
+ i = -1,
+ last = change.path ? change.path.length - 1 : 0;
+ while (++i < last) {
+ if (typeof it[change.path[i]] === 'undefined') {
+ it[change.path[i]] = (typeof change.path[i] === 'number') ? [] : {};
+ }
+ it = it[change.path[i]];
+ }
+ switch (change.kind) {
+ case 'A':
+ applyArrayChange(change.path ? it[change.path[i]] : it, change.index, change.item);
+ break;
+ case 'D':
+ delete it[change.path[i]];
+ break;
+ case 'E':
+ case 'N':
+ it[change.path[i]] = change.rhs;
+ break;
+ }
}
+ }
- var from = change.from, to = change.to, text = change.text;
- var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
- var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
-
- // Adjust the line structure
- if (change.full) {
- doc.insert(0, linesFor(0, text.length));
- doc.remove(text.length, doc.size - text.length);
- } else if (isWholeLineUpdate(doc, change)) {
- // This is a whole-line replace. Treated specially to make
- // sure line objects move the way they are supposed to.
- var added = linesFor(0, text.length - 1);
- update(lastLine, lastLine.text, lastSpans);
- if (nlines) doc.remove(from.line, nlines);
- if (added.length) doc.insert(from.line, added);
- } else if (firstLine == lastLine) {
- if (text.length == 1) {
- update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
- } else {
- var added = linesFor(1, text.length - 1);
- added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight));
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
- doc.insert(from.line + 1, added);
- }
- } else if (text.length == 1) {
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
- doc.remove(from.line + 1, nlines);
+ function revertArrayChange(arr, index, change) {
+ if (change.path && change.path.length) {
+ // the structure of the object at the index has changed...
+ var it = arr[index],
+ i, u = change.path.length - 1;
+ for (i = 0; i < u; i++) {
+ it = it[change.path[i]];
+ }
+ switch (change.kind) {
+ case 'A':
+ revertArrayChange(it[change.path[i]], change.index, change.item);
+ break;
+ case 'D':
+ it[change.path[i]] = change.lhs;
+ break;
+ case 'E':
+ it[change.path[i]] = change.lhs;
+ break;
+ case 'N':
+ delete it[change.path[i]];
+ break;
+ }
} else {
- update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
- update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
- var added = linesFor(1, text.length - 1);
- if (nlines > 1) doc.remove(from.line + 1, nlines - 1);
- doc.insert(from.line + 1, added);
+ // the array item is different...
+ switch (change.kind) {
+ case 'A':
+ revertArrayChange(arr[index], change.index, change.item);
+ break;
+ case 'D':
+ arr[index] = change.lhs;
+ break;
+ case 'E':
+ arr[index] = change.lhs;
+ break;
+ case 'N':
+ arr = arrayRemove(arr, index);
+ break;
+ }
}
-
- signalLater(doc, "change", doc, change);
+ return arr;
}
- // The document is represented as a BTree consisting of leaves, with
- // chunk of lines in them, and branches, with up to ten leaves or
- // other branch nodes below them. The top node is always a branch
- // node, and is the document object itself (meaning it has
- // additional methods and properties).
- //
- // All nodes have parent links. The tree is used both to go from
- // line numbers to line objects, and to go from objects to numbers.
- // It also indexes by height, and is used to convert between height
- // and line object, and to find the total height of the document.
- //
- // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
+ function revertChange(target, source, change) {
+ if (target && source && change && change.kind) {
+ var it = target,
+ i, u;
+ u = change.path.length - 1;
+ for (i = 0; i < u; i++) {
+ if (typeof it[change.path[i]] === 'undefined') {
+ it[change.path[i]] = {};
+ }
+ it = it[change.path[i]];
+ }
+ switch (change.kind) {
+ case 'A':
+ // Array was modified...
+ // it will be an array...
+ revertArrayChange(it[change.path[i]], change.index, change.item);
+ break;
+ case 'D':
+ // Item was deleted...
+ it[change.path[i]] = change.lhs;
+ break;
+ case 'E':
+ // Item was edited...
+ it[change.path[i]] = change.lhs;
+ break;
+ case 'N':
+ // Item is new...
+ delete it[change.path[i]];
+ break;
+ }
+ }
+ }
- function LeafChunk(lines) {
- this.lines = lines;
- this.parent = null;
- for (var i = 0, height = 0; i < lines.length; ++i) {
- lines[i].parent = this;
- height += lines[i].height;
+ function applyDiff(target, source, filter) {
+ if (target && source) {
+ var onChange = function(change) {
+ if (!filter || filter(target, source, change)) {
+ applyChange(target, source, change);
+ }
+ };
+ deepDiff(target, source, onChange);
}
- this.height = height;
}
- LeafChunk.prototype = {
- chunkSize: function() { return this.lines.length; },
- // Remove the n lines at offset 'at'.
- removeInner: function(at, n) {
- for (var i = at, e = at + n; i < e; ++i) {
- var line = this.lines[i];
- this.height -= line.height;
- cleanUpLine(line);
- signalLater(line, "delete");
- }
- this.lines.splice(at, n);
+ Object.defineProperties(accumulateDiff, {
+
+ diff: {
+ value: accumulateDiff,
+ enumerable: true
},
- // Helper used to collapse a small branch into a single leaf.
- collapse: function(lines) {
- lines.push.apply(lines, this.lines);
+ observableDiff: {
+ value: deepDiff,
+ enumerable: true
},
- // Insert the given array of lines at offset 'at', count them as
- // having the given height.
- insertInner: function(at, lines, height) {
- this.height += height;
- this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
- for (var i = 0; i < lines.length; ++i) lines[i].parent = this;
+ applyDiff: {
+ value: applyDiff,
+ enumerable: true
},
- // Used to iterate over a part of the tree.
- iterN: function(at, n, op) {
- for (var e = at + n; at < e; ++at)
- if (op(this.lines[at])) return true;
- }
- };
-
- function BranchChunk(children) {
- this.children = children;
- var size = 0, height = 0;
- for (var i = 0; i < children.length; ++i) {
- var ch = children[i];
- size += ch.chunkSize(); height += ch.height;
- ch.parent = this;
- }
- this.size = size;
- this.height = height;
- this.parent = null;
- }
-
- BranchChunk.prototype = {
- chunkSize: function() { return this.size; },
- removeInner: function(at, n) {
- this.size -= n;
- for (var i = 0; i < this.children.length; ++i) {
- var child = this.children[i], sz = child.chunkSize();
- if (at < sz) {
- var rm = Math.min(n, sz - at), oldHeight = child.height;
- child.removeInner(at, rm);
- this.height -= oldHeight - child.height;
- if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
- if ((n -= rm) == 0) break;
- at = 0;
- } else at -= sz;
- }
- // If the result is smaller than 25 lines, ensure that it is a
- // single leaf node.
- if (this.size - n < 25 &&
- (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
- var lines = [];
- this.collapse(lines);
- this.children = [new LeafChunk(lines)];
- this.children[0].parent = this;
- }
+ applyChange: {
+ value: applyChange,
+ enumerable: true
},
- collapse: function(lines) {
- for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines);
+ revertChange: {
+ value: revertChange,
+ enumerable: true
},
- insertInner: function(at, lines, height) {
- this.size += lines.length;
- this.height += height;
- for (var i = 0; i < this.children.length; ++i) {
- var child = this.children[i], sz = child.chunkSize();
- if (at <= sz) {
- child.insertInner(at, lines, height);
- if (child.lines && child.lines.length > 50) {
- // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
- // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
- var remaining = child.lines.length % 25 + 25
- for (var pos = remaining; pos < child.lines.length;) {
- var leaf = new LeafChunk(child.lines.slice(pos, pos += 25));
- child.height -= leaf.height;
- this.children.splice(++i, 0, leaf);
- leaf.parent = this;
- }
- child.lines = child.lines.slice(0, remaining);
- this.maybeSpill();
- }
- break;
- }
- at -= sz;
- }
- },
- // When a node has grown, check whether it should be split.
- maybeSpill: function() {
- if (this.children.length <= 10) return;
- var me = this;
- do {
- var spilled = me.children.splice(me.children.length - 5, 5);
- var sibling = new BranchChunk(spilled);
- if (!me.parent) { // Become the parent node
- var copy = new BranchChunk(me.children);
- copy.parent = me;
- me.children = [copy, sibling];
- me = copy;
- } else {
- me.size -= sibling.size;
- me.height -= sibling.height;
- var myIndex = indexOf(me.parent.children, me);
- me.parent.children.splice(myIndex + 1, 0, sibling);
- }
- sibling.parent = me.parent;
- } while (me.children.length > 10);
- me.parent.maybeSpill();
+ isConflict: {
+ value: function() {
+ return 'undefined' !== typeof conflict;
+ },
+ enumerable: true
},
- iterN: function(at, n, op) {
- for (var i = 0; i < this.children.length; ++i) {
- var child = this.children[i], sz = child.chunkSize();
- if (at < sz) {
- var used = Math.min(n, sz - at);
- if (child.iterN(at, used, op)) return true;
- if ((n -= used) == 0) break;
- at = 0;
- } else at -= sz;
- }
+ noConflict: {
+ value: function() {
+ if (conflictResolution) {
+ conflictResolution.forEach(function(it) {
+ it();
+ });
+ conflictResolution = null;
+ }
+ return accumulateDiff;
+ },
+ enumerable: true
}
- };
+ });
- var nextDocId = 0;
- var Doc = CodeMirror.Doc = function(text, mode, firstLine, lineSep) {
- if (!(this instanceof Doc)) return new Doc(text, mode, firstLine, lineSep);
- if (firstLine == null) firstLine = 0;
-
- BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
- this.first = firstLine;
- this.scrollTop = this.scrollLeft = 0;
- this.cantEdit = false;
- this.cleanGeneration = 1;
- this.frontier = firstLine;
- var start = Pos(firstLine, 0);
- this.sel = simpleSelection(start);
- this.history = new History(null);
- this.id = ++nextDocId;
- this.modeOption = mode;
- this.lineSep = lineSep;
- this.extend = false;
-
- if (typeof text == "string") text = this.splitLines(text);
- updateDoc(this, {from: start, to: start, text: text});
- setSelection(this, simpleSelection(start), sel_dontScroll);
- };
+ return accumulateDiff;
+}));
- Doc.prototype = createObj(BranchChunk.prototype, {
- constructor: Doc,
- // Iterate over the document. Supports two forms -- with only one
- // argument, it calls that for each line in the document. With
- // three, it iterates over the range given by the first two (with
- // the second being non-inclusive).
- iter: function(from, to, op) {
- if (op) this.iterN(from - this.first, to - from, op);
- else this.iterN(this.first, this.first + this.size, from);
- },
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- // Non-public interface for adding and removing lines.
- insert: function(at, lines) {
- var height = 0;
- for (var i = 0; i < lines.length; ++i) height += lines[i].height;
- this.insertInner(at - this.first, lines, height);
- },
- remove: function(at, n) { this.removeInner(at - this.first, n); },
+},{}],3:[function(require,module,exports){
+(function (process){
+'use strict';
- // From here, the methods are part of the public interface. Most
- // are also available from CodeMirror (editor) instances.
+/**
+ * Copyright (c) 2013-present, 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.
+ *
+ * @typechecks
+ */
- getValue: function(lineSep) {
- var lines = getLines(this, this.first, this.first + this.size);
- if (lineSep === false) return lines;
- return lines.join(lineSep || this.lineSeparator());
- },
- setValue: docMethodOp(function(code) {
- var top = Pos(this.first, 0), last = this.first + this.size - 1;
- makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
- text: this.splitLines(code), origin: "setValue", full: true}, true);
- setSelection(this, simpleSelection(top));
- }),
- replaceRange: function(code, from, to, origin) {
- from = clipPos(this, from);
- to = to ? clipPos(this, to) : from;
- replaceRange(this, code, from, to, origin);
- },
- getRange: function(from, to, lineSep) {
- var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
- if (lineSep === false) return lines;
- return lines.join(lineSep || this.lineSeparator());
- },
+var emptyFunction = require('./emptyFunction');
- getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;},
+/**
+ * Upstream version of event listener. Does not take into account specific
+ * nature of platform.
+ */
+var EventListener = {
+ /**
+ * Listen to DOM events during the bubble phase.
+ *
+ * @param {DOMEventTarget} target DOM element to register listener on.
+ * @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
+ * @param {function} callback Callback function.
+ * @return {object} Object with a `remove` method.
+ */
+ listen: function listen(target, eventType, callback) {
+ if (target.addEventListener) {
+ target.addEventListener(eventType, callback, false);
+ return {
+ remove: function remove() {
+ target.removeEventListener(eventType, callback, false);
+ }
+ };
+ } else if (target.attachEvent) {
+ target.attachEvent('on' + eventType, callback);
+ return {
+ remove: function remove() {
+ target.detachEvent('on' + eventType, callback);
+ }
+ };
+ }
+ },
- getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);},
- getLineNumber: function(line) {return lineNo(line);},
+ /**
+ * Listen to DOM events during the capture phase.
+ *
+ * @param {DOMEventTarget} target DOM element to register listener on.
+ * @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
+ * @param {function} callback Callback function.
+ * @return {object} Object with a `remove` method.
+ */
+ capture: function capture(target, eventType, callback) {
+ if (target.addEventListener) {
+ target.addEventListener(eventType, callback, true);
+ return {
+ remove: function remove() {
+ target.removeEventListener(eventType, callback, true);
+ }
+ };
+ } else {
+ if (process.env.NODE_ENV !== 'production') {
+ console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.');
+ }
+ return {
+ remove: emptyFunction
+ };
+ }
+ },
- getLineHandleVisualStart: function(line) {
- if (typeof line == "number") line = getLine(this, line);
- return visualLine(line);
- },
+ registerDefault: function registerDefault() {}
+};
- lineCount: function() {return this.size;},
- firstLine: function() {return this.first;},
- lastLine: function() {return this.first + this.size - 1;},
+module.exports = EventListener;
+}).call(this,require('_process'))
- clipPos: function(pos) {return clipPos(this, pos);},
+},{"./emptyFunction":10,"_process":43}],4:[function(require,module,exports){
+/**
+ * Copyright (c) 2013-present, 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.
+ *
+ */
- getCursor: function(start) {
- var range = this.sel.primary(), pos;
- if (start == null || start == "head") pos = range.head;
- else if (start == "anchor") pos = range.anchor;
- else if (start == "end" || start == "to" || start === false) pos = range.to();
- else pos = range.from();
- return pos;
- },
- listSelections: function() { return this.sel.ranges; },
- somethingSelected: function() {return this.sel.somethingSelected();},
+'use strict';
- setCursor: docMethodOp(function(line, ch, options) {
- setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
- }),
- setSelection: docMethodOp(function(anchor, head, options) {
- setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
- }),
- extendSelection: docMethodOp(function(head, other, options) {
- extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
- }),
- extendSelections: docMethodOp(function(heads, options) {
- extendSelections(this, clipPosArray(this, heads), options);
- }),
- extendSelectionsBy: docMethodOp(function(f, options) {
- var heads = map(this.sel.ranges, f);
- extendSelections(this, clipPosArray(this, heads), options);
- }),
- setSelections: docMethodOp(function(ranges, primary, options) {
- if (!ranges.length) return;
- for (var i = 0, out = []; i < ranges.length; i++)
- out[i] = new Range(clipPos(this, ranges[i].anchor),
- clipPos(this, ranges[i].head));
- if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex);
- setSelection(this, normalizeSelection(out, primary), options);
- }),
- addSelection: docMethodOp(function(anchor, head, options) {
- var ranges = this.sel.ranges.slice(0);
- ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
- setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);
- }),
+var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
- getSelection: function(lineSep) {
- var ranges = this.sel.ranges, lines;
- for (var i = 0; i < ranges.length; i++) {
- var sel = getBetween(this, ranges[i].from(), ranges[i].to());
- lines = lines ? lines.concat(sel) : sel;
- }
- if (lineSep === false) return lines;
- else return lines.join(lineSep || this.lineSeparator());
- },
- getSelections: function(lineSep) {
- var parts = [], ranges = this.sel.ranges;
- for (var i = 0; i < ranges.length; i++) {
- var sel = getBetween(this, ranges[i].from(), ranges[i].to());
- if (lineSep !== false) sel = sel.join(lineSep || this.lineSeparator());
- parts[i] = sel;
- }
- return parts;
- },
- replaceSelection: function(code, collapse, origin) {
- var dup = [];
- for (var i = 0; i < this.sel.ranges.length; i++)
- dup[i] = code;
- this.replaceSelections(dup, collapse, origin || "+input");
- },
- replaceSelections: docMethodOp(function(code, collapse, origin) {
- var changes = [], sel = this.sel;
- for (var i = 0; i < sel.ranges.length; i++) {
- var range = sel.ranges[i];
- changes[i] = {from: range.from(), to: range.to(), text: this.splitLines(code[i]), origin: origin};
- }
- var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
- for (var i = changes.length - 1; i >= 0; i--)
- makeChange(this, changes[i]);
- if (newSel) setSelectionReplaceHistory(this, newSel);
- else if (this.cm) ensureCursorVisible(this.cm);
- }),
- undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
- redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
- undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
- redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
-
- setExtending: function(val) {this.extend = val;},
- getExtending: function() {return this.extend;},
-
- historySize: function() {
- var hist = this.history, done = 0, undone = 0;
- for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done;
- for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone;
- return {undo: done, redo: undone};
- },
- clearHistory: function() {this.history = new History(this.history.maxGeneration);},
+/**
+ * Simple, lightweight module assisting with the detection and context of
+ * Worker. Helps avoid circular dependencies and allows code to reason about
+ * whether or not they are in a Worker, even if they never include the main
+ * `ReactWorker` dependency.
+ */
+var ExecutionEnvironment = {
- markClean: function() {
- this.cleanGeneration = this.changeGeneration(true);
- },
- changeGeneration: function(forceSplit) {
- if (forceSplit)
- this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null;
- return this.history.generation;
- },
- isClean: function (gen) {
- return this.history.generation == (gen || this.cleanGeneration);
- },
+ canUseDOM: canUseDOM,
- getHistory: function() {
- return {done: copyHistoryArray(this.history.done),
- undone: copyHistoryArray(this.history.undone)};
- },
- setHistory: function(histData) {
- var hist = this.history = new History(this.history.maxGeneration);
- hist.done = copyHistoryArray(histData.done.slice(0), null, true);
- hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
- },
+ canUseWorkers: typeof Worker !== 'undefined',
- addLineClass: docMethodOp(function(handle, where, cls) {
- return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
- var prop = where == "text" ? "textClass"
- : where == "background" ? "bgClass"
- : where == "gutter" ? "gutterClass" : "wrapClass";
- if (!line[prop]) line[prop] = cls;
- else if (classTest(cls).test(line[prop])) return false;
- else line[prop] += " " + cls;
- return true;
- });
- }),
- removeLineClass: docMethodOp(function(handle, where, cls) {
- return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) {
- var prop = where == "text" ? "textClass"
- : where == "background" ? "bgClass"
- : where == "gutter" ? "gutterClass" : "wrapClass";
- var cur = line[prop];
- if (!cur) return false;
- else if (cls == null) line[prop] = null;
- else {
- var found = cur.match(classTest(cls));
- if (!found) return false;
- var end = found.index + found[0].length;
- line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
- }
- return true;
- });
- }),
+ canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent),
- addLineWidget: docMethodOp(function(handle, node, options) {
- return addLineWidget(this, handle, node, options);
- }),
- removeLineWidget: function(widget) { widget.clear(); },
+ canUseViewport: canUseDOM && !!window.screen,
- markText: function(from, to, options) {
- return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range");
- },
- setBookmark: function(pos, options) {
- var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
- insertLeft: options && options.insertLeft,
- clearWhenEmpty: false, shared: options && options.shared,
- handleMouseEvents: options && options.handleMouseEvents};
- pos = clipPos(this, pos);
- return markText(this, pos, pos, realOpts, "bookmark");
- },
- findMarksAt: function(pos) {
- pos = clipPos(this, pos);
- var markers = [], spans = getLine(this, pos.line).markedSpans;
- if (spans) for (var i = 0; i < spans.length; ++i) {
- var span = spans[i];
- if ((span.from == null || span.from <= pos.ch) &&
- (span.to == null || span.to >= pos.ch))
- markers.push(span.marker.parent || span.marker);
- }
- return markers;
- },
- findMarks: function(from, to, filter) {
- from = clipPos(this, from); to = clipPos(this, to);
- var found = [], lineNo = from.line;
- this.iter(from.line, to.line + 1, function(line) {
- var spans = line.markedSpans;
- if (spans) for (var i = 0; i < spans.length; i++) {
- var span = spans[i];
- if (!(span.to != null && lineNo == from.line && from.ch >= span.to ||
- span.from == null && lineNo != from.line ||
- span.from != null && lineNo == to.line && span.from >= to.ch) &&
- (!filter || filter(span.marker)))
- found.push(span.marker.parent || span.marker);
- }
- ++lineNo;
- });
- return found;
- },
- getAllMarks: function() {
- var markers = [];
- this.iter(function(line) {
- var sps = line.markedSpans;
- if (sps) for (var i = 0; i < sps.length; ++i)
- if (sps[i].from != null) markers.push(sps[i].marker);
- });
- return markers;
- },
+ isInWorker: !canUseDOM // For now, this is true - might change in the future.
- posFromIndex: function(off) {
- var ch, lineNo = this.first, sepSize = this.lineSeparator().length;
- this.iter(function(line) {
- var sz = line.text.length + sepSize;
- if (sz > off) { ch = off; return true; }
- off -= sz;
- ++lineNo;
- });
- return clipPos(this, Pos(lineNo, ch));
- },
- indexFromPos: function (coords) {
- coords = clipPos(this, coords);
- var index = coords.ch;
- if (coords.line < this.first || coords.ch < 0) return 0;
- var sepSize = this.lineSeparator().length;
- this.iter(this.first, coords.line, function (line) {
- index += line.text.length + sepSize;
- });
- return index;
- },
+};
- copy: function(copyHistory) {
- var doc = new Doc(getLines(this, this.first, this.first + this.size),
- this.modeOption, this.first, this.lineSep);
- doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
- doc.sel = this.sel;
- doc.extend = false;
- if (copyHistory) {
- doc.history.undoDepth = this.history.undoDepth;
- doc.setHistory(this.getHistory());
- }
- return doc;
- },
+module.exports = ExecutionEnvironment;
+},{}],5:[function(require,module,exports){
+"use strict";
- linkedDoc: function(options) {
- if (!options) options = {};
- var from = this.first, to = this.first + this.size;
- if (options.from != null && options.from > from) from = options.from;
- if (options.to != null && options.to < to) to = options.to;
- var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep);
- if (options.sharedHist) copy.history = this.history;
- (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
- copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
- copySharedMarkers(copy, findSharedMarkers(this));
- return copy;
- },
- unlinkDoc: function(other) {
- if (other instanceof CodeMirror) other = other.doc;
- if (this.linked) for (var i = 0; i < this.linked.length; ++i) {
- var link = this.linked[i];
- if (link.doc != other) continue;
- this.linked.splice(i, 1);
- other.unlinkDoc(this);
- detachSharedMarkers(findSharedMarkers(this));
- break;
- }
- // If the histories were shared, split them again
- if (other.history == this.history) {
- var splitIds = [other.id];
- linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true);
- other.history = new History(null);
- other.history.done = copyHistoryArray(this.history.done, splitIds);
- other.history.undone = copyHistoryArray(this.history.undone, splitIds);
- }
- },
- iterLinkedDocs: function(f) {linkedDocs(this, f);},
+/**
+ * Copyright (c) 2013-present, 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
+ */
- getMode: function() {return this.mode;},
- getEditor: function() {return this.cm;},
+var _hyphenPattern = /-(.)/g;
- splitLines: function(str) {
- if (this.lineSep) return str.split(this.lineSep);
- return splitLinesAuto(str);
- },
- lineSeparator: function() { return this.lineSep || "\n"; }
+/**
+ * Camelcases a hyphenated string, for example:
+ *
+ * > camelize('background-color')
+ * < "backgroundColor"
+ *
+ * @param {string} string
+ * @return {string}
+ */
+function camelize(string) {
+ return string.replace(_hyphenPattern, function (_, character) {
+ return character.toUpperCase();
});
+}
- // Public alias.
- Doc.prototype.eachLine = Doc.prototype.iter;
-
- // Set up methods on CodeMirror's prototype to redirect to the editor's document.
- var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
- for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
- CodeMirror.prototype[prop] = (function(method) {
- return function() {return method.apply(this.doc, arguments);};
- })(Doc.prototype[prop]);
-
- eventMixin(Doc);
-
- // Call f for all linked documents.
- function linkedDocs(doc, f, sharedHistOnly) {
- function propagate(doc, skip, sharedHist) {
- if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) {
- var rel = doc.linked[i];
- if (rel.doc == skip) continue;
- var shared = sharedHist && rel.sharedHist;
- if (sharedHistOnly && !shared) continue;
- f(rel.doc, shared);
- propagate(rel.doc, doc, shared);
- }
- }
- propagate(doc, null, true);
- }
-
- // Attach a document to an editor.
- function attachDoc(cm, doc) {
- if (doc.cm) throw new Error("This document is already in use.");
- cm.doc = doc;
- doc.cm = cm;
- estimateLineHeights(cm);
- loadMode(cm);
- if (!cm.options.lineWrapping) findMaxLine(cm);
- cm.options.mode = doc.modeOption;
- regChange(cm);
- }
-
- // LINE UTILITIES
-
- // Find the line object corresponding to the given line number.
- function getLine(doc, n) {
- n -= doc.first;
- if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document.");
- for (var chunk = doc; !chunk.lines;) {
- for (var i = 0;; ++i) {
- var child = chunk.children[i], sz = child.chunkSize();
- if (n < sz) { chunk = child; break; }
- n -= sz;
- }
- }
- return chunk.lines[n];
- }
-
- // Get the part of a document between two positions, as an array of
- // strings.
- function getBetween(doc, start, end) {
- var out = [], n = start.line;
- doc.iter(start.line, end.line + 1, function(line) {
- var text = line.text;
- if (n == end.line) text = text.slice(0, end.ch);
- if (n == start.line) text = text.slice(start.ch);
- out.push(text);
- ++n;
- });
- return out;
- }
- // Get the lines between from and to, as array of strings.
- function getLines(doc, from, to) {
- var out = [];
- doc.iter(from, to, function(line) { out.push(line.text); });
- return out;
- }
+module.exports = camelize;
+},{}],6:[function(require,module,exports){
+/**
+ * Copyright (c) 2013-present, 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
+ */
- // Update the height of a line, propagating the height change
- // upwards to parent nodes.
- function updateLineHeight(line, height) {
- var diff = height - line.height;
- if (diff) for (var n = line; n; n = n.parent) n.height += diff;
- }
+'use strict';
- // Given a line object, find its line number by walking up through
- // its parent links.
- function lineNo(line) {
- if (line.parent == null) return null;
- var cur = line.parent, no = indexOf(cur.lines, line);
- for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
- for (var i = 0;; ++i) {
- if (chunk.children[i] == cur) break;
- no += chunk.children[i].chunkSize();
- }
- }
- return no + cur.first;
- }
+var camelize = require('./camelize');
- // Find the line at the given vertical position, using the height
- // information in the document tree.
- function lineAtHeight(chunk, h) {
- var n = chunk.first;
- outer: do {
- for (var i = 0; i < chunk.children.length; ++i) {
- var child = chunk.children[i], ch = child.height;
- if (h < ch) { chunk = child; continue outer; }
- h -= ch;
- n += child.chunkSize();
- }
- return n;
- } while (!chunk.lines);
- for (var i = 0; i < chunk.lines.length; ++i) {
- var line = chunk.lines[i], lh = line.height;
- if (h < lh) break;
- h -= lh;
- }
- return n + i;
- }
-
-
- // Find the height above the given line.
- function heightAtLine(lineObj) {
- lineObj = visualLine(lineObj);
-
- var h = 0, chunk = lineObj.parent;
- for (var i = 0; i < chunk.lines.length; ++i) {
- var line = chunk.lines[i];
- if (line == lineObj) break;
- else h += line.height;
- }
- for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
- for (var i = 0; i < p.children.length; ++i) {
- var cur = p.children[i];
- if (cur == chunk) break;
- else h += cur.height;
- }
- }
- return h;
- }
-
- // Get the bidi ordering for the given line (and cache it). Returns
- // false for lines that are fully left-to-right, and an array of
- // BidiSpan objects otherwise.
- function getOrder(line) {
- var order = line.order;
- if (order == null) order = line.order = bidiOrdering(line.text);
- return order;
- }
-
- // HISTORY
-
- function History(startGen) {
- // Arrays of change events and selections. Doing something adds an
- // event to done and clears undo. Undoing moves events from done
- // to undone, redoing moves them in the other direction.
- this.done = []; this.undone = [];
- this.undoDepth = Infinity;
- // Used to track when changes can be merged into a single undo
- // event
- this.lastModTime = this.lastSelTime = 0;
- this.lastOp = this.lastSelOp = null;
- this.lastOrigin = this.lastSelOrigin = null;
- // Used by the isClean() method
- this.generation = this.maxGeneration = startGen || 1;
- }
-
- // Create a history change event from an updateDoc-style change
- // object.
- function historyChangeFromChange(doc, change) {
- var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
- attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
- linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true);
- return histChange;
- }
-
- // Pop all selection events off the end of a history array. Stop at
- // a change event.
- function clearSelectionEvents(array) {
- while (array.length) {
- var last = lst(array);
- if (last.ranges) array.pop();
- else break;
- }
- }
-
- // Find the top change event in the history. Pop off selection
- // events that are in the way.
- function lastChangeEvent(hist, force) {
- if (force) {
- clearSelectionEvents(hist.done);
- return lst(hist.done);
- } else if (hist.done.length && !lst(hist.done).ranges) {
- return lst(hist.done);
- } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
- hist.done.pop();
- return lst(hist.done);
- }
- }
-
- // Register a change in the history. Merges changes that are within
- // a single operation, ore are close together with an origin that
- // allows merging (starting with "+") into a single event.
- function addChangeToHistory(doc, change, selAfter, opId) {
- var hist = doc.history;
- hist.undone.length = 0;
- var time = +new Date, cur;
-
- if ((hist.lastOp == opId ||
- hist.lastOrigin == change.origin && change.origin &&
- ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
- change.origin.charAt(0) == "*")) &&
- (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
- // Merge this change into the last event
- var last = lst(cur.changes);
- if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
- // Optimized case for simple insertion -- don't want to add
- // new changesets for every character typed
- last.to = changeEnd(change);
- } else {
- // Add new sub-event
- cur.changes.push(historyChangeFromChange(doc, change));
- }
- } else {
- // Can not be merged, start a new event.
- var before = lst(hist.done);
- if (!before || !before.ranges)
- pushSelectionToHistory(doc.sel, hist.done);
- cur = {changes: [historyChangeFromChange(doc, change)],
- generation: hist.generation};
- hist.done.push(cur);
- while (hist.done.length > hist.undoDepth) {
- hist.done.shift();
- if (!hist.done[0].ranges) hist.done.shift();
- }
- }
- hist.done.push(selAfter);
- hist.generation = ++hist.maxGeneration;
- hist.lastModTime = hist.lastSelTime = time;
- hist.lastOp = hist.lastSelOp = opId;
- hist.lastOrigin = hist.lastSelOrigin = change.origin;
-
- if (!last) signal(doc, "historyAdded");
- }
-
- function selectionEventCanBeMerged(doc, origin, prev, sel) {
- var ch = origin.charAt(0);
- return ch == "*" ||
- ch == "+" &&
- prev.ranges.length == sel.ranges.length &&
- prev.somethingSelected() == sel.somethingSelected() &&
- new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500);
- }
-
- // Called whenever the selection changes, sets the new selection as
- // the pending selection in the history, and pushes the old pending
- // selection into the 'done' array when it was significantly
- // different (in number of selected ranges, emptiness, or time).
- function addSelectionToHistory(doc, sel, opId, options) {
- var hist = doc.history, origin = options && options.origin;
-
- // A new event is started when the previous origin does not match
- // the current, or the origins don't allow matching. Origins
- // starting with * are always merged, those starting with + are
- // merged when similar and close together in time.
- if (opId == hist.lastSelOp ||
- (origin && hist.lastSelOrigin == origin &&
- (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
- selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
- hist.done[hist.done.length - 1] = sel;
- else
- pushSelectionToHistory(sel, hist.done);
+var msPattern = /^-ms-/;
- hist.lastSelTime = +new Date;
- hist.lastSelOrigin = origin;
- hist.lastSelOp = opId;
- if (options && options.clearRedo !== false)
- clearSelectionEvents(hist.undone);
- }
+/**
+ * Camelcases a hyphenated CSS property name, for example:
+ *
+ * > camelizeStyleName('background-color')
+ * < "backgroundColor"
+ * > camelizeStyleName('-moz-transition')
+ * < "MozTransition"
+ * > camelizeStyleName('-ms-transition')
+ * < "msTransition"
+ *
+ * As Andi Smith suggests
+ * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
+ * is converted to lowercase `ms`.
+ *
+ * @param {string} string
+ * @return {string}
+ */
+function camelizeStyleName(string) {
+ return camelize(string.replace(msPattern, 'ms-'));
+}
- function pushSelectionToHistory(sel, dest) {
- var top = lst(dest);
- if (!(top && top.ranges && top.equals(sel)))
- dest.push(sel);
- }
+module.exports = camelizeStyleName;
+},{"./camelize":5}],7:[function(require,module,exports){
+'use strict';
- // Used to store marked span information in the history.
- function attachLocalSpans(doc, change, from, to) {
- var existing = change["spans_" + doc.id], n = 0;
- doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) {
- if (line.markedSpans)
- (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans;
- ++n;
- });
- }
+/**
+ * Copyright (c) 2013-present, 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.
+ *
+ *
+ */
- // When un/re-doing restores text containing marked spans, those
- // that have been explicitly cleared should not be restored.
- function removeClearedSpans(spans) {
- if (!spans) return null;
- for (var i = 0, out; i < spans.length; ++i) {
- if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); }
- else if (out) out.push(spans[i]);
- }
- return !out ? spans : out.length ? out : null;
- }
+var isTextNode = require('./isTextNode');
- // Retrieve and filter the old marked spans stored in a change event.
- function getOldSpans(doc, change) {
- var found = change["spans_" + doc.id];
- if (!found) return null;
- for (var i = 0, nw = []; i < change.text.length; ++i)
- nw.push(removeClearedSpans(found[i]));
- return nw;
- }
+/*eslint-disable no-bitwise */
- // Used both to provide a JSON-safe object in .getHistory, and, when
- // detaching a document, to split the history in two
- function copyHistoryArray(events, newGroup, instantiateSel) {
- for (var i = 0, copy = []; i < events.length; ++i) {
- var event = events[i];
- if (event.ranges) {
- copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
- continue;
- }
- var changes = event.changes, newChanges = [];
- copy.push({changes: newChanges});
- for (var j = 0; j < changes.length; ++j) {
- var change = changes[j], m;
- newChanges.push({from: change.from, to: change.to, text: change.text});
- if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) {
- if (indexOf(newGroup, Number(m[1])) > -1) {
- lst(newChanges)[prop] = change[prop];
- delete change[prop];
- }
- }
- }
- }
- return copy;
+/**
+ * Checks if a given DOM node contains or is another DOM node.
+ */
+function containsNode(outerNode, innerNode) {
+ if (!outerNode || !innerNode) {
+ return false;
+ } else if (outerNode === innerNode) {
+ return true;
+ } else if (isTextNode(outerNode)) {
+ return false;
+ } else if (isTextNode(innerNode)) {
+ return containsNode(outerNode, innerNode.parentNode);
+ } else if ('contains' in outerNode) {
+ return outerNode.contains(innerNode);
+ } else if (outerNode.compareDocumentPosition) {
+ return !!(outerNode.compareDocumentPosition(innerNode) & 16);
+ } else {
+ return false;
}
+}
+
+module.exports = containsNode;
+},{"./isTextNode":20}],8:[function(require,module,exports){
+(function (process){
+'use strict';
+
+/**
+ * Copyright (c) 2013-present, 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
+ */
+
+var invariant = require('./invariant');
+
+/**
+ * Convert array-like objects to arrays.
+ *
+ * This API assumes the caller knows the contents of the data type. For less
+ * well defined inputs use createArrayFromMixed.
+ *
+ * @param {object|function|filelist} obj
+ * @return {array}
+ */
+function toArray(obj) {
+ var length = obj.length;
+
+ // Some browsers builtin objects can report typeof 'function' (e.g. NodeList
+ // in old versions of Safari).
+ !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : void 0;
+
+ !(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : void 0;
- // Rebasing/resetting history to deal with externally-sourced changes
+ !(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : void 0;
+
+ !(typeof obj.callee !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant(false) : void 0;
- function rebaseHistSelSingle(pos, from, to, diff) {
- if (to < pos.line) {
- pos.line += diff;
- } else if (from < pos.line) {
- pos.line = from;
- pos.ch = 0;
+ // Old IE doesn't give collections access to hasOwnProperty. Assume inputs
+ // without method will throw during the slice call and skip straight to the
+ // fallback.
+ if (obj.hasOwnProperty) {
+ try {
+ return Array.prototype.slice.call(obj);
+ } catch (e) {
+ // IE < 9 does not support Array#slice on collections objects
}
}
- // Tries to rebase an array of history events given a change in the
- // document. If the change touches the same lines as the event, the
- // event, and everything 'behind' it, is discarded. If the change is
- // before the event, the event's positions are updated. Uses a
- // copy-on-write scheme for the positions, to avoid having to
- // reallocate them all on every rebase, but also avoid problems with
- // shared position objects being unsafely updated.
- function rebaseHistArray(array, from, to, diff) {
- for (var i = 0; i < array.length; ++i) {
- var sub = array[i], ok = true;
- if (sub.ranges) {
- if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
- for (var j = 0; j < sub.ranges.length; j++) {
- rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
- rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
- }
- continue;
- }
- for (var j = 0; j < sub.changes.length; ++j) {
- var cur = sub.changes[j];
- if (to < cur.from.line) {
- cur.from = Pos(cur.from.line + diff, cur.from.ch);
- cur.to = Pos(cur.to.line + diff, cur.to.ch);
- } else if (from <= cur.to.line) {
- ok = false;
- break;
- }
- }
- if (!ok) {
- array.splice(0, i + 1);
- i = 0;
- }
- }
+ // Fall back to copying key by key. This assumes all keys have a value,
+ // so will not preserve sparsely populated inputs.
+ var ret = Array(length);
+ for (var ii = 0; ii < length; ii++) {
+ ret[ii] = obj[ii];
}
+ return ret;
+}
- function rebaseHist(hist, change) {
- var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
- rebaseHistArray(hist.done, from, to, diff);
- rebaseHistArray(hist.undone, from, to, diff);
+/**
+ * Perform a heuristic test to determine if an object is "array-like".
+ *
+ * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
+ * Joshu replied: "Mu."
+ *
+ * This function determines if its argument has "array nature": it returns
+ * true if the argument is an actual array, an `arguments' object, or an
+ * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
+ *
+ * It will return false for other array-like objects like Filelist.
+ *
+ * @param {*} obj
+ * @return {boolean}
+ */
+function hasArrayNature(obj) {
+ return (
+ // not null/false
+ !!obj && (
+ // arrays are objects, NodeLists are functions in Safari
+ typeof obj == 'object' || typeof obj == 'function') &&
+ // quacks like an array
+ 'length' in obj &&
+ // not window
+ !('setInterval' in obj) &&
+ // no DOM node should be considered an array-like
+ // a 'select' element has 'length' and 'item' properties on IE8
+ typeof obj.nodeType != 'number' && (
+ // a real array
+ Array.isArray(obj) ||
+ // arguments
+ 'callee' in obj ||
+ // HTMLCollection/NodeList
+ 'item' in obj)
+ );
+}
+
+/**
+ * Ensure that the argument is an array by wrapping it in an array if it is not.
+ * Creates a copy of the argument if it is already an array.
+ *
+ * This is mostly useful idiomatically:
+ *
+ * var createArrayFromMixed = require('createArrayFromMixed');
+ *
+ * function takesOneOrMoreThings(things) {
+ * things = createArrayFromMixed(things);
+ * ...
+ * }
+ *
+ * This allows you to treat `things' as an array, but accept scalars in the API.
+ *
+ * If you need to convert an array-like object, like `arguments`, into an array
+ * use toArray instead.
+ *
+ * @param {*} obj
+ * @return {array}
+ */
+function createArrayFromMixed(obj) {
+ if (!hasArrayNature(obj)) {
+ return [obj];
+ } else if (Array.isArray(obj)) {
+ return obj.slice();
+ } else {
+ return toArray(obj);
}
+}
- // EVENT UTILITIES
+module.exports = createArrayFromMixed;
+}).call(this,require('_process'))
- // Due to the fact that we still support jurassic IE versions, some
- // compatibility wrappers are needed.
+},{"./invariant":18,"_process":43}],9:[function(require,module,exports){
+(function (process){
+'use strict';
- var e_preventDefault = CodeMirror.e_preventDefault = function(e) {
- if (e.preventDefault) e.preventDefault();
- else e.returnValue = false;
- };
- var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) {
- if (e.stopPropagation) e.stopPropagation();
- else e.cancelBubble = true;
- };
- function e_defaultPrevented(e) {
- return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false;
- }
- var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);};
+/**
+ * Copyright (c) 2013-present, 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
+ */
- function e_target(e) {return e.target || e.srcElement;}
- function e_button(e) {
- var b = e.which;
- if (b == null) {
- if (e.button & 1) b = 1;
- else if (e.button & 2) b = 3;
- else if (e.button & 4) b = 2;
- }
- if (mac && e.ctrlKey && b == 1) b = 3;
- return b;
- }
+/*eslint-disable fb-www/unsafe-html*/
- // EVENT HANDLING
+var ExecutionEnvironment = require('./ExecutionEnvironment');
- // Lightweight event framework. on/off also work on DOM nodes,
- // registering native DOM handlers.
+var createArrayFromMixed = require('./createArrayFromMixed');
+var getMarkupWrap = require('./getMarkupWrap');
+var invariant = require('./invariant');
- var on = CodeMirror.on = function(emitter, type, f) {
- if (emitter.addEventListener)
- emitter.addEventListener(type, f, false);
- else if (emitter.attachEvent)
- emitter.attachEvent("on" + type, f);
- else {
- var map = emitter._handlers || (emitter._handlers = {});
- var arr = map[type] || (map[type] = []);
- arr.push(f);
- }
- };
+/**
+ * Dummy container used to render all markup.
+ */
+var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
- var noHandlers = []
- function getHandlers(emitter, type, copy) {
- var arr = emitter._handlers && emitter._handlers[type]
- if (copy) return arr && arr.length > 0 ? arr.slice() : noHandlers
- else return arr || noHandlers
- }
+/**
+ * Pattern used by `getNodeName`.
+ */
+var nodeNamePattern = /^\s*<(\w+)/;
- var off = CodeMirror.off = function(emitter, type, f) {
- if (emitter.removeEventListener)
- emitter.removeEventListener(type, f, false);
- else if (emitter.detachEvent)
- emitter.detachEvent("on" + type, f);
- else {
- var handlers = getHandlers(emitter, type, false)
- for (var i = 0; i < handlers.length; ++i)
- if (handlers[i] == f) { handlers.splice(i, 1); break; }
- }
- };
+/**
+ * Extracts the `nodeName` of the first element in a string of markup.
+ *
+ * @param {string} markup String of markup.
+ * @return {?string} Node name of the supplied markup.
+ */
+function getNodeName(markup) {
+ var nodeNameMatch = markup.match(nodeNamePattern);
+ return nodeNameMatch && nodeNameMatch[1].toLowerCase();
+}
- var signal = CodeMirror.signal = function(emitter, type /*, values...*/) {
- var handlers = getHandlers(emitter, type, true)
- if (!handlers.length) return;
- var args = Array.prototype.slice.call(arguments, 2);
- for (var i = 0; i < handlers.length; ++i) handlers[i].apply(null, args);
- };
+/**
+ * Creates an array containing the nodes rendered from the supplied markup. The
+ * optionally supplied `handleScript` function will be invoked once for each
+ * <script> element that is rendered. If no `handleScript` function is supplied,
+ * an exception is thrown if any <script> elements are rendered.
+ *
+ * @param {string} markup A string of valid HTML markup.
+ * @param {?function} handleScript Invoked once for each rendered <script>.
+ * @return {array<DOMElement|DOMTextNode>} An array of rendered nodes.
+ */
+function createNodesFromMarkup(markup, handleScript) {
+ var node = dummyNode;
+ !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup dummy not initialized') : invariant(false) : void 0;
+ var nodeName = getNodeName(markup);
- var orphanDelayedCallbacks = null;
-
- // Often, we want to signal events at a point where we are in the
- // middle of some work, but don't want the handler to start calling
- // other methods on the editor, which might be in an inconsistent
- // state or simply not expect any other events to happen.
- // signalLater looks whether there are any handlers, and schedules
- // them to be executed when the last operation ends, or, if no
- // operation is active, when a timeout fires.
- function signalLater(emitter, type /*, values...*/) {
- var arr = getHandlers(emitter, type, false)
- if (!arr.length) return;
- var args = Array.prototype.slice.call(arguments, 2), list;
- if (operationGroup) {
- list = operationGroup.delayedCallbacks;
- } else if (orphanDelayedCallbacks) {
- list = orphanDelayedCallbacks;
- } else {
- list = orphanDelayedCallbacks = [];
- setTimeout(fireOrphanDelayed, 0);
+ var wrap = nodeName && getMarkupWrap(nodeName);
+ if (wrap) {
+ node.innerHTML = wrap[1] + markup + wrap[2];
+
+ var wrapDepth = wrap[0];
+ while (wrapDepth--) {
+ node = node.lastChild;
}
- function bnd(f) {return function(){f.apply(null, args);};};
- for (var i = 0; i < arr.length; ++i)
- list.push(bnd(arr[i]));
+ } else {
+ node.innerHTML = markup;
}
- function fireOrphanDelayed() {
- var delayed = orphanDelayedCallbacks;
- orphanDelayedCallbacks = null;
- for (var i = 0; i < delayed.length; ++i) delayed[i]();
+ var scripts = node.getElementsByTagName('script');
+ if (scripts.length) {
+ !handleScript ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup(...): Unexpected <script> element rendered.') : invariant(false) : void 0;
+ createArrayFromMixed(scripts).forEach(handleScript);
}
- // The DOM events that CodeMirror handles can be overridden by
- // registering a (non-DOM) handler on the editor for the event name,
- // and preventDefault-ing the event in that handler.
- function signalDOMEvent(cm, e, override) {
- if (typeof e == "string")
- e = {type: e, preventDefault: function() { this.defaultPrevented = true; }};
- signal(cm, override || e.type, cm, e);
- return e_defaultPrevented(e) || e.codemirrorIgnore;
+ var nodes = Array.from(node.childNodes);
+ while (node.lastChild) {
+ node.removeChild(node.lastChild);
}
+ return nodes;
+}
- function signalCursorActivity(cm) {
- var arr = cm._handlers && cm._handlers.cursorActivity;
- if (!arr) return;
- var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
- for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1)
- set.push(arr[i]);
- }
+module.exports = createNodesFromMarkup;
+}).call(this,require('_process'))
- function hasHandler(emitter, type) {
- return getHandlers(emitter, type).length > 0
- }
+},{"./ExecutionEnvironment":4,"./createArrayFromMixed":8,"./getMarkupWrap":14,"./invariant":18,"_process":43}],10:[function(require,module,exports){
+"use strict";
- // Add on and off methods to a constructor's prototype, to make
- // registering events on such objects more convenient.
- function eventMixin(ctor) {
- ctor.prototype.on = function(type, f) {on(this, type, f);};
- ctor.prototype.off = function(type, f) {off(this, type, f);};
- }
+/**
+ * Copyright (c) 2013-present, 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.
+ *
+ *
+ */
- // MISC UTILITIES
+function makeEmptyFunction(arg) {
+ return function () {
+ return arg;
+ };
+}
- // Number of pixels added to scroller and sizer to hide scrollbar
- var scrollerGap = 30;
+/**
+ * This function accepts and discards inputs; it has no side effects. This is
+ * primarily useful idiomatically for overridable function endpoints which
+ * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
+ */
+var emptyFunction = function emptyFunction() {};
- // Returned or thrown by various protocols to signal 'I'm not
- // handling this'.
- var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
+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;
+};
- // Reused option objects for setSelection & friends
- var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"};
+module.exports = emptyFunction;
+},{}],11:[function(require,module,exports){
+(function (process){
+/**
+ * Copyright (c) 2013-present, 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.
+ *
+ */
- function Delayed() {this.id = null;}
- Delayed.prototype.set = function(ms, f) {
- clearTimeout(this.id);
- this.id = setTimeout(f, ms);
- };
+'use strict';
- // Counts the column offset in a string, taking tabs into account.
- // Used mostly to find indentation.
- var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) {
- if (end == null) {
- end = string.search(/[^\s\u00a0]/);
- if (end == -1) end = string.length;
- }
- for (var i = startIndex || 0, n = startValue || 0;;) {
- var nextTab = string.indexOf("\t", i);
- if (nextTab < 0 || nextTab >= end)
- return n + (end - i);
- n += nextTab - i;
- n += tabSize - (n % tabSize);
- i = nextTab + 1;
- }
- };
+var emptyObject = {};
- // The inverse of countColumn -- find the offset that corresponds to
- // a particular column.
- var findColumn = CodeMirror.findColumn = function(string, goal, tabSize) {
- for (var pos = 0, col = 0;;) {
- var nextTab = string.indexOf("\t", pos);
- if (nextTab == -1) nextTab = string.length;
- var skipped = nextTab - pos;
- if (nextTab == string.length || col + skipped >= goal)
- return pos + Math.min(skipped, goal - col);
- col += nextTab - pos;
- col += tabSize - (col % tabSize);
- pos = nextTab + 1;
- if (col >= goal) return pos;
- }
- }
+if (process.env.NODE_ENV !== 'production') {
+ Object.freeze(emptyObject);
+}
- var spaceStrs = [""];
- function spaceStr(n) {
- while (spaceStrs.length <= n)
- spaceStrs.push(lst(spaceStrs) + " ");
- return spaceStrs[n];
- }
+module.exports = emptyObject;
+}).call(this,require('_process'))
+
+},{"_process":43}],12:[function(require,module,exports){
+/**
+ * Copyright (c) 2013-present, 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.
+ *
+ */
- function lst(arr) { return arr[arr.length-1]; }
+'use strict';
- var selectInput = function(node) { node.select(); };
- if (ios) // Mobile Safari apparently has a bug where select() is broken.
- selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; };
- else if (ie) // Suppress mysterious IE10 errors
- selectInput = function(node) { try { node.select(); } catch(_e) {} };
+/**
+ * @param {DOMElement} node input/textarea to focus
+ */
- function indexOf(array, elt) {
- for (var i = 0; i < array.length; ++i)
- if (array[i] == elt) return i;
- return -1;
+function focusNode(node) {
+ // 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;
+},{}],13:[function(require,module,exports){
+'use strict';
+
+/**
+ * Copyright (c) 2013-present, 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
+ */
+
+/* eslint-disable fb-www/typeof-undefined */
+
+/**
+ * Same as document.activeElement but wraps in a try-catch block. In IE it is
+ * not safe to call document.activeElement if there is nothing focused.
+ *
+ * The activeElement will be null only if the document or document body is not
+ * yet defined.
+ */
+function getActiveElement() /*?DOMElement*/{
+ if (typeof document === 'undefined') {
+ return null;
}
- function map(array, f) {
- var out = [];
- for (var i = 0; i < array.length; i++) out[i] = f(array[i], i);
- return out;
+ try {
+ return document.activeElement || document.body;
+ } catch (e) {
+ return document.body;
}
+}
- function nothing() {}
+module.exports = getActiveElement;
+},{}],14:[function(require,module,exports){
+(function (process){
+'use strict';
- function createObj(base, props) {
- var inst;
- if (Object.create) {
- inst = Object.create(base);
- } else {
- nothing.prototype = base;
- inst = new nothing();
- }
- if (props) copyObj(props, inst);
- return inst;
- };
+/**
+ * Copyright (c) 2013-present, 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.
+ *
+ */
- function copyObj(obj, target, overwrite) {
- if (!target) target = {};
- for (var prop in obj)
- if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
- target[prop] = obj[prop];
- return target;
- }
+/*eslint-disable fb-www/unsafe-html */
- function bind(f) {
- var args = Array.prototype.slice.call(arguments, 1);
- return function(){return f.apply(null, args);};
- }
+var ExecutionEnvironment = require('./ExecutionEnvironment');
- var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
- var isWordCharBasic = CodeMirror.isWordChar = function(ch) {
- return /\w/.test(ch) || ch > "\x80" &&
- (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch));
- };
- function isWordChar(ch, helper) {
- if (!helper) return isWordCharBasic(ch);
- if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true;
- return helper.test(ch);
- }
+var invariant = require('./invariant');
- function isEmpty(obj) {
- for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false;
- return true;
- }
+/**
+ * Dummy container used to detect which wraps are necessary.
+ */
+var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
- // Extending unicode characters. A series of a non-extending char +
- // any number of extending chars is treated as a single unit as far
- // as editing and measuring is concerned. This is not fully correct,
- // since some scripts/fonts/browsers also treat other configurations
- // of code points as a group.
- var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;
- function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); }
+/**
+ * Some browsers cannot use `innerHTML` to render certain elements standalone,
+ * so we wrap them, render the wrapped nodes, then extract the desired node.
+ *
+ * In IE8, certain elements cannot render alone, so wrap all elements ('*').
+ */
- // DOM UTILITIES
+var shouldWrap = {};
- function elt(tag, content, className, style) {
- var e = document.createElement(tag);
- if (className) e.className = className;
- if (style) e.style.cssText = style;
- if (typeof content == "string") e.appendChild(document.createTextNode(content));
- else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]);
- return e;
- }
+var selectWrap = [1, '<select multiple="true">', '</select>'];
+var tableWrap = [1, '<table>', '</table>'];
+var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
- var range;
- if (document.createRange) range = function(node, start, end, endNode) {
- var r = document.createRange();
- r.setEnd(endNode || node, end);
- r.setStart(node, start);
- return r;
- };
- else range = function(node, start, end) {
- var r = document.body.createTextRange();
- try { r.moveToElementText(node.parentNode); }
- catch(e) { return r; }
- r.collapse(true);
- r.moveEnd("character", end);
- r.moveStart("character", start);
- return r;
- };
+var svgWrap = [1, '<svg xmlns="http://www.w3.org/2000/svg">', '</svg>'];
- function removeChildren(e) {
- for (var count = e.childNodes.length; count > 0; --count)
- e.removeChild(e.firstChild);
- return e;
- }
+var markupWrap = {
+ '*': [1, '?<div>', '</div>'],
- function removeChildrenAndAdd(parent, e) {
- return removeChildren(parent).appendChild(e);
- }
+ 'area': [1, '<map>', '</map>'],
+ 'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
+ 'legend': [1, '<fieldset>', '</fieldset>'],
+ 'param': [1, '<object>', '</object>'],
+ 'tr': [2, '<table><tbody>', '</tbody></table>'],
- var contains = CodeMirror.contains = function(parent, child) {
- if (child.nodeType == 3) // Android browser always returns false when child is a textnode
- child = child.parentNode;
- if (parent.contains)
- return parent.contains(child);
- do {
- if (child.nodeType == 11) child = child.host;
- if (child == parent) return true;
- } while (child = child.parentNode);
- };
+ 'optgroup': selectWrap,
+ 'option': selectWrap,
- function activeElt() {
- var activeElement = document.activeElement;
- while (activeElement && activeElement.root && activeElement.root.activeElement)
- activeElement = activeElement.root.activeElement;
- return activeElement;
- }
- // Older versions of IE throws unspecified error when touching
- // document.activeElement in some cases (during loading, in iframe)
- if (ie && ie_version < 11) activeElt = function() {
- try { return document.activeElement; }
- catch(e) { return document.body; }
- };
+ 'caption': tableWrap,
+ 'colgroup': tableWrap,
+ 'tbody': tableWrap,
+ 'tfoot': tableWrap,
+ 'thead': tableWrap,
+
+ 'td': trWrap,
+ 'th': trWrap
+};
+
+// Initialize the SVG elements since we know they'll always need to be wrapped
+// consistently. If they are created inside a <div> they will be initialized in
+// the wrong namespace (and will not display).
+var svgElements = ['circle', 'clipPath', 'defs', 'ellipse', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'text', 'tspan'];
+svgElements.forEach(function (nodeName) {
+ markupWrap[nodeName] = svgWrap;
+ shouldWrap[nodeName] = true;
+});
- function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*"); }
- var rmClass = CodeMirror.rmClass = function(node, cls) {
- var current = node.className;
- var match = classTest(cls).exec(current);
- if (match) {
- var after = current.slice(match.index + match[0].length);
- node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
+/**
+ * Gets the markup wrap configuration for the supplied `nodeName`.
+ *
+ * NOTE: This lazily detects which wraps are necessary for the current browser.
+ *
+ * @param {string} nodeName Lowercase `nodeName`.
+ * @return {?array} Markup wrap configuration, if applicable.
+ */
+function getMarkupWrap(nodeName) {
+ !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Markup wrapping node not initialized') : invariant(false) : void 0;
+ if (!markupWrap.hasOwnProperty(nodeName)) {
+ nodeName = '*';
+ }
+ if (!shouldWrap.hasOwnProperty(nodeName)) {
+ if (nodeName === '*') {
+ dummyNode.innerHTML = '<link />';
+ } else {
+ dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>';
}
- };
- var addClass = CodeMirror.addClass = function(node, cls) {
- var current = node.className;
- if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls;
- };
- function joinClasses(a, b) {
- var as = a.split(" ");
- for (var i = 0; i < as.length; i++)
- if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i];
- return b;
- }
-
- // WINDOW-WIDE EVENTS
-
- // These must be handled carefully, because naively registering a
- // handler for each editor will cause the editors to never be
- // garbage collected.
-
- function forEachCodeMirror(f) {
- if (!document.body.getElementsByClassName) return;
- var byClass = document.body.getElementsByClassName("CodeMirror");
- for (var i = 0; i < byClass.length; i++) {
- var cm = byClass[i].CodeMirror;
- if (cm) f(cm);
- }
- }
-
- var globalsRegistered = false;
- function ensureGlobalHandlers() {
- if (globalsRegistered) return;
- registerGlobalHandlers();
- globalsRegistered = true;
- }
- function registerGlobalHandlers() {
- // When the window resizes, we need to refresh active editors.
- var resizeTimer;
- on(window, "resize", function() {
- if (resizeTimer == null) resizeTimer = setTimeout(function() {
- resizeTimer = null;
- forEachCodeMirror(onResize);
- }, 100);
- });
- // When the window loses focus, we want to show the editor as blurred
- on(window, "blur", function() {
- forEachCodeMirror(onBlur);
- });
+ shouldWrap[nodeName] = !dummyNode.firstChild;
}
+ return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
+}
- // FEATURE DETECTION
-
- // Detect drag-and-drop
- var dragAndDrop = function() {
- // There is *some* kind of drag-and-drop support in IE6-8, but I
- // couldn't get it to work yet.
- if (ie && ie_version < 9) return false;
- var div = elt('div');
- return "draggable" in div || "dragDrop" in div;
- }();
-
- var zwspSupported;
- function zeroWidthElement(measure) {
- if (zwspSupported == null) {
- var test = elt("span", "\u200b");
- removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
- if (measure.firstChild.offsetHeight != 0)
- zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8);
- }
- var node = zwspSupported ? elt("span", "\u200b") :
- elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
- node.setAttribute("cm-text", "");
- return node;
- }
-
- // Feature-detect IE's crummy client rect reporting for bidi text
- var badBidiRects;
- function hasBadBidiRects(measure) {
- if (badBidiRects != null) return badBidiRects;
- var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
- var r0 = range(txt, 0, 1).getBoundingClientRect();
- if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780)
- var r1 = range(txt, 1, 2).getBoundingClientRect();
- return badBidiRects = (r1.right - r0.right < 3);
- }
-
- // See if "".split is the broken IE version, if so, provide an
- // alternative way to split lines.
- var splitLinesAuto = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
- var pos = 0, result = [], l = string.length;
- while (pos <= l) {
- var nl = string.indexOf("\n", pos);
- if (nl == -1) nl = string.length;
- var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
- var rt = line.indexOf("\r");
- if (rt != -1) {
- result.push(line.slice(0, rt));
- pos += rt + 1;
- } else {
- result.push(line);
- pos = nl + 1;
- }
- }
- return result;
- } : function(string){return string.split(/\r\n?|\n/);};
-
- var hasSelection = window.getSelection ? function(te) {
- try { return te.selectionStart != te.selectionEnd; }
- catch(e) { return false; }
- } : function(te) {
- try {var range = te.ownerDocument.selection.createRange();}
- catch(e) {}
- if (!range || range.parentElement() != te) return false;
- return range.compareEndPoints("StartToEnd", range) != 0;
- };
+module.exports = getMarkupWrap;
+}).call(this,require('_process'))
- var hasCopyEvent = (function() {
- var e = elt("div");
- if ("oncopy" in e) return true;
- e.setAttribute("oncopy", "return;");
- return typeof e.oncopy == "function";
- })();
+},{"./ExecutionEnvironment":4,"./invariant":18,"_process":43}],15:[function(require,module,exports){
+/**
+ * Copyright (c) 2013-present, 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
+ */
- var badZoomedRects = null;
- function hasBadZoomedRects(measure) {
- if (badZoomedRects != null) return badZoomedRects;
- var node = removeChildrenAndAdd(measure, elt("span", "x"));
- var normal = node.getBoundingClientRect();
- var fromRange = range(node, 0, 1).getBoundingClientRect();
- return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1;
- }
-
- // KEY NAMES
-
- var keyNames = CodeMirror.keyNames = {
- 3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
- 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
- 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
- 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
- 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete",
- 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
- 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
- 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
- };
- (function() {
- // Number keys
- for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i);
- // Alphabetic keys
- for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i);
- // Function keys
- for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
- })();
+'use strict';
- // BIDI HELPERS
-
- function iterateBidiSections(order, from, to, f) {
- if (!order) return f(from, to, "ltr");
- var found = false;
- for (var i = 0; i < order.length; ++i) {
- var part = order[i];
- if (part.from < to && part.to > from || from == to && part.to == from) {
- f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr");
- found = true;
- }
- }
- if (!found) f(from, to, "ltr");
- }
-
- function bidiLeft(part) { return part.level % 2 ? part.to : part.from; }
- function bidiRight(part) { return part.level % 2 ? part.from : part.to; }
-
- function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; }
- function lineRight(line) {
- var order = getOrder(line);
- if (!order) return line.text.length;
- return bidiRight(lst(order));
- }
-
- function lineStart(cm, lineN) {
- var line = getLine(cm.doc, lineN);
- var visual = visualLine(line);
- if (visual != line) lineN = lineNo(visual);
- var order = getOrder(visual);
- var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual);
- return Pos(lineN, ch);
- }
- function lineEnd(cm, lineN) {
- var merged, line = getLine(cm.doc, lineN);
- while (merged = collapsedSpanAtEnd(line)) {
- line = merged.find(1, true).line;
- lineN = null;
- }
- var order = getOrder(line);
- var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line);
- return Pos(lineN == null ? lineNo(line) : lineN, ch);
- }
- function lineStartSmart(cm, pos) {
- var start = lineStart(cm, pos.line);
- var line = getLine(cm.doc, start.line);
- var order = getOrder(line);
- if (!order || order[0].level == 0) {
- var firstNonWS = Math.max(0, line.text.search(/\S/));
- var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
- return Pos(start.line, inWS ? 0 : firstNonWS);
- }
- return start;
- }
-
- function compareBidiLevel(order, a, b) {
- var linedir = order[0].level;
- if (a == linedir) return true;
- if (b == linedir) return false;
- return a < b;
- }
- var bidiOther;
- function getBidiPartAt(order, pos) {
- bidiOther = null;
- for (var i = 0, found; i < order.length; ++i) {
- var cur = order[i];
- if (cur.from < pos && cur.to > pos) return i;
- if ((cur.from == pos || cur.to == pos)) {
- if (found == null) {
- found = i;
- } else if (compareBidiLevel(order, cur.level, order[found].level)) {
- if (cur.from != cur.to) bidiOther = found;
- return i;
- } else {
- if (cur.from != cur.to) bidiOther = i;
- return found;
- }
- }
- }
- return found;
- }
+/**
+ * Gets the scroll position of the supplied element or window.
+ *
+ * The return values are unbounded, unlike `getScrollPosition`. This means they
+ * may be negative or exceed the element boundaries (which is possible using
+ * inertial scrolling).
+ *
+ * @param {DOMWindow|DOMElement} scrollable
+ * @return {object} Map with `x` and `y` keys.
+ */
- function moveInLine(line, pos, dir, byUnit) {
- if (!byUnit) return pos + dir;
- do pos += dir;
- while (pos > 0 && isExtendingChar(line.text.charAt(pos)));
- return pos;
+function getUnboundedScrollPosition(scrollable) {
+ if (scrollable === window) {
+ return {
+ x: window.pageXOffset || document.documentElement.scrollLeft,
+ y: window.pageYOffset || document.documentElement.scrollTop
+ };
}
+ return {
+ x: scrollable.scrollLeft,
+ y: scrollable.scrollTop
+ };
+}
- // This is needed in order to move 'visually' through bi-directional
- // text -- i.e., pressing left should make the cursor go left, even
- // when in RTL text. The tricky part is the 'jumps', where RTL and
- // LTR text touch each other. This often requires the cursor offset
- // to move more than one unit, in order to visually move one unit.
- function moveVisually(line, start, dir, byUnit) {
- var bidi = getOrder(line);
- if (!bidi) return moveLogically(line, start, dir, byUnit);
- var pos = getBidiPartAt(bidi, start), part = bidi[pos];
- var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit);
+module.exports = getUnboundedScrollPosition;
+},{}],16:[function(require,module,exports){
+'use strict';
- for (;;) {
- if (target > part.from && target < part.to) return target;
- if (target == part.from || target == part.to) {
- if (getBidiPartAt(bidi, target) == pos) return target;
- part = bidi[pos += dir];
- return (dir > 0) == part.level % 2 ? part.to : part.from;
- } else {
- part = bidi[pos += dir];
- if (!part) return null;
- if ((dir > 0) == part.level % 2)
- target = moveInLine(line, part.to, -1, byUnit);
- else
- target = moveInLine(line, part.from, 1, byUnit);
- }
- }
- }
-
- function moveLogically(line, start, dir, byUnit) {
- var target = start + dir;
- if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir;
- return target < 0 || target > line.text.length ? null : target;
- }
-
- // Bidirectional ordering algorithm
- // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
- // that this (partially) implements.
-
- // One-char codes used for character types:
- // L (L): Left-to-Right
- // R (R): Right-to-Left
- // r (AL): Right-to-Left Arabic
- // 1 (EN): European Number
- // + (ES): European Number Separator
- // % (ET): European Number Terminator
- // n (AN): Arabic Number
- // , (CS): Common Number Separator
- // m (NSM): Non-Spacing Mark
- // b (BN): Boundary Neutral
- // s (B): Paragraph Separator
- // t (S): Segment Separator
- // w (WS): Whitespace
- // N (ON): Other Neutrals
-
- // Returns null if characters are ordered as they appear
- // (left-to-right), or an array of sections ({from, to, level}
- // objects) in the order in which they occur visually.
- var bidiOrdering = (function() {
- // Character types for codepoints 0 to 0xff
- var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
- // Character types for codepoints 0x600 to 0x6ff
- var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm";
- function charType(code) {
- if (code <= 0xf7) return lowTypes.charAt(code);
- else if (0x590 <= code && code <= 0x5f4) return "R";
- else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600);
- else if (0x6ee <= code && code <= 0x8ac) return "r";
- else if (0x2000 <= code && code <= 0x200b) return "w";
- else if (code == 0x200c) return "b";
- else return "L";
- }
-
- var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
- var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
- // Browsers seem to always treat the boundaries of block elements as being L.
- var outerType = "L";
-
- function BidiSpan(level, from, to) {
- this.level = level;
- this.from = from; this.to = to;
- }
-
- return function(str) {
- if (!bidiRE.test(str)) return false;
- var len = str.length, types = [];
- for (var i = 0, type; i < len; ++i)
- types.push(type = charType(str.charCodeAt(i)));
-
- // W1. Examine each non-spacing mark (NSM) in the level run, and
- // change the type of the NSM to the type of the previous
- // character. If the NSM is at the start of the level run, it will
- // get the type of sor.
- for (var i = 0, prev = outerType; i < len; ++i) {
- var type = types[i];
- if (type == "m") types[i] = prev;
- else prev = type;
- }
-
- // W2. Search backwards from each instance of a European number
- // until the first strong type (R, L, AL, or sor) is found. If an
- // AL is found, change the type of the European number to Arabic
- // number.
- // W3. Change all ALs to R.
- for (var i = 0, cur = outerType; i < len; ++i) {
- var type = types[i];
- if (type == "1" && cur == "r") types[i] = "n";
- else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; }
- }
-
- // W4. A single European separator between two European numbers
- // changes to a European number. A single common separator between
- // two numbers of the same type changes to that type.
- for (var i = 1, prev = types[0]; i < len - 1; ++i) {
- var type = types[i];
- if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1";
- else if (type == "," && prev == types[i+1] &&
- (prev == "1" || prev == "n")) types[i] = prev;
- prev = type;
- }
-
- // W5. A sequence of European terminators adjacent to European
- // numbers changes to all European numbers.
- // W6. Otherwise, separators and terminators change to Other
- // Neutral.
- for (var i = 0; i < len; ++i) {
- var type = types[i];
- if (type == ",") types[i] = "N";
- else if (type == "%") {
- for (var end = i + 1; end < len && types[end] == "%"; ++end) {}
- var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
- for (var j = i; j < end; ++j) types[j] = replace;
- i = end - 1;
- }
- }
-
- // W7. Search backwards from each instance of a European number
- // until the first strong type (R, L, or sor) is found. If an L is
- // found, then change the type of the European number to L.
- for (var i = 0, cur = outerType; i < len; ++i) {
- var type = types[i];
- if (cur == "L" && type == "1") types[i] = "L";
- else if (isStrong.test(type)) cur = type;
- }
-
- // N1. A sequence of neutrals takes the direction of the
- // surrounding strong text if the text on both sides has the same
- // direction. European and Arabic numbers act as if they were R in
- // terms of their influence on neutrals. Start-of-level-run (sor)
- // and end-of-level-run (eor) are used at level run boundaries.
- // N2. Any remaining neutrals take the embedding direction.
- for (var i = 0; i < len; ++i) {
- if (isNeutral.test(types[i])) {
- for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {}
- var before = (i ? types[i-1] : outerType) == "L";
- var after = (end < len ? types[end] : outerType) == "L";
- var replace = before || after ? "L" : "R";
- for (var j = i; j < end; ++j) types[j] = replace;
- i = end - 1;
- }
- }
-
- // Here we depart from the documented algorithm, in order to avoid
- // building up an actual levels array. Since there are only three
- // levels (0, 1, 2) in an implementation that doesn't take
- // explicit embedding into account, we can build up the order on
- // the fly, without following the level-based algorithm.
- var order = [], m;
- for (var i = 0; i < len;) {
- if (countsAsLeft.test(types[i])) {
- var start = i;
- for (++i; i < len && countsAsLeft.test(types[i]); ++i) {}
- order.push(new BidiSpan(0, start, i));
- } else {
- var pos = i, at = order.length;
- for (++i; i < len && types[i] != "L"; ++i) {}
- for (var j = pos; j < i;) {
- if (countsAsNum.test(types[j])) {
- if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j));
- var nstart = j;
- for (++j; j < i && countsAsNum.test(types[j]); ++j) {}
- order.splice(at, 0, new BidiSpan(2, nstart, j));
- pos = j;
- } else ++j;
- }
- if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i));
- }
- }
- if (order[0].level == 1 && (m = str.match(/^\s+/))) {
- order[0].from = m[0].length;
- order.unshift(new BidiSpan(0, 0, m[0].length));
- }
- if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
- lst(order).to -= m[0].length;
- order.push(new BidiSpan(0, len - m[0].length, len));
- }
- if (order[0].level == 2)
- order.unshift(new BidiSpan(1, order[0].to, order[0].to));
- if (order[0].level != lst(order).level)
- order.push(new BidiSpan(order[0].level, len, len));
+/**
+ * Copyright (c) 2013-present, 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
+ */
- return order;
- };
- })();
+var _uppercasePattern = /([A-Z])/g;
- // THE END
+/**
+ * Hyphenates a camelcased string, for example:
+ *
+ * > hyphenate('backgroundColor')
+ * < "background-color"
+ *
+ * For CSS style names, use `hyphenateStyleName` instead which works properly
+ * with all vendor prefixes, including `ms`.
+ *
+ * @param {string} string
+ * @return {string}
+ */
+function hyphenate(string) {
+ return string.replace(_uppercasePattern, '-$1').toLowerCase();
+}
- CodeMirror.version = "5.16.0";
+module.exports = hyphenate;
+},{}],17:[function(require,module,exports){
+/**
+ * Copyright (c) 2013-present, 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
+ */
- return CodeMirror;
-});
+'use strict';
-},{}],2:[function(require,module,exports){
+var hyphenate = require('./hyphenate');
+
+var msPattern = /^ms-/;
+
+/**
+ * Hyphenates a camelcased CSS property name, for example:
+ *
+ * > hyphenateStyleName('backgroundColor')
+ * < "background-color"
+ * > hyphenateStyleName('MozTransition')
+ * < "-moz-transition"
+ * > hyphenateStyleName('msTransition')
+ * < "-ms-transition"
+ *
+ * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
+ * is converted to `-ms-`.
+ *
+ * @param {string} string
+ * @return {string}
+ */
+function hyphenateStyleName(string) {
+ return hyphenate(string).replace(msPattern, '-ms-');
+}
+
+module.exports = hyphenateStyleName;
+},{"./hyphenate":16}],18:[function(require,module,exports){
(function (process){
/**
- * Copyright 2013-2015, Facebook, Inc.
+ * Copyright (c) 2013-present, 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 invariant
*/
-"use strict";
+'use strict';
/**
* Use invariant() to assert state which your program assumes to be true.
@@ -8948,12 +10459,18 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof requ
* will remain to ensure logic does not differ in production.
*/
-var invariant = function (condition, format, a, b, c, d, e, f) {
- if (process.env.NODE_ENV !== 'production') {
+var validateFormat = function validateFormat(format) {};
+
+if (process.env.NODE_ENV !== 'production') {
+ validateFormat = function validateFormat(format) {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
- }
+ };
+}
+
+function invariant(condition, format, a, b, c, d, e, f) {
+ validateFormat(format);
if (!condition) {
var error;
@@ -8962,255 +10479,294 @@ var invariant = function (condition, format, a, b, c, d, e, f) {
} else {
var args = [a, b, c, d, e, f];
var argIndex = 0;
- error = new Error('Invariant Violation: ' + format.replace(/%s/g, function () {
+ error = new Error(format.replace(/%s/g, function () {
return args[argIndex++];
}));
+ error.name = 'Invariant Violation';
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
-};
+}
module.exports = invariant;
}).call(this,require('_process'))
-},{"_process":15}],3:[function(require,module,exports){
-(function (process){
+},{"_process":43}],19:[function(require,module,exports){
+'use strict';
+
/**
- * Copyright (c) 2014-2015, Facebook, Inc.
+ * Copyright (c) 2013-present, 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 Dispatcher
- *
- * @preventMunge
+ * @typechecks
*/
-'use strict';
+/**
+ * @param {*} object The object to check.
+ * @return {boolean} Whether or not the object is a DOM node.
+ */
+function isNode(object) {
+ return !!(object && (typeof Node === 'function' ? object instanceof Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'));
+}
-exports.__esModule = true;
+module.exports = isNode;
+},{}],20:[function(require,module,exports){
+'use strict';
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+/**
+ * Copyright (c) 2013-present, 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
+ */
-var invariant = require('fbjs/lib/invariant');
+var isNode = require('./isNode');
-var _prefix = 'ID_';
+/**
+ * @param {*} object The object to check.
+ * @return {boolean} Whether or not the object is a DOM text node.
+ */
+function isTextNode(object) {
+ return isNode(object) && object.nodeType == 3;
+}
+module.exports = isTextNode;
+},{"./isNode":19}],21:[function(require,module,exports){
/**
- * Dispatcher is used to broadcast payloads to registered callbacks. This is
- * different from generic pub-sub systems in two ways:
- *
- * 1) Callbacks are not subscribed to particular events. Every payload is
- * dispatched to every registered callback.
- * 2) Callbacks can be deferred in whole or part until other callbacks have
- * been executed.
- *
- * For example, consider this hypothetical flight destination form, which
- * selects a default city when a country is selected:
- *
- * var flightDispatcher = new Dispatcher();
- *
- * // Keeps track of which country is selected
- * var CountryStore = {country: null};
- *
- * // Keeps track of which city is selected
- * var CityStore = {city: null};
- *
- * // Keeps track of the base flight price of the selected city
- * var FlightPriceStore = {price: null}
- *
- * When a user changes the selected city, we dispatch the payload:
- *
- * flightDispatcher.dispatch({
- * actionType: 'city-update',
- * selectedCity: 'paris'
- * });
- *
- * This payload is digested by `CityStore`:
- *
- * flightDispatcher.register(function(payload) {
- * if (payload.actionType === 'city-update') {
- * CityStore.city = payload.selectedCity;
- * }
- * });
- *
- * When the user selects a country, we dispatch the payload:
+ * Copyright (c) 2013-present, Facebook, Inc.
+ * All rights reserved.
*
- * flightDispatcher.dispatch({
- * actionType: 'country-update',
- * selectedCountry: 'australia'
- * });
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
*
- * This payload is digested by both stores:
+ *
+ * @typechecks static-only
+ */
+
+'use strict';
+
+/**
+ * Memoizes the return value of a function that accepts one string argument.
+ */
+
+function memoizeStringOnly(callback) {
+ var cache = {};
+ return function (string) {
+ if (!cache.hasOwnProperty(string)) {
+ cache[string] = callback.call(this, string);
+ }
+ return cache[string];
+ };
+}
+
+module.exports = memoizeStringOnly;
+},{}],22:[function(require,module,exports){
+/**
+ * Copyright (c) 2013-present, Facebook, Inc.
+ * All rights reserved.
*
- * CountryStore.dispatchToken = flightDispatcher.register(function(payload) {
- * if (payload.actionType === 'country-update') {
- * CountryStore.country = payload.selectedCountry;
- * }
- * });
+ * 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.
*
- * When the callback to update `CountryStore` is registered, we save a reference
- * to the returned token. Using this token with `waitFor()`, we can guarantee
- * that `CountryStore` is updated before the callback that updates `CityStore`
- * needs to query its data.
+ * @typechecks
+ */
+
+'use strict';
+
+var ExecutionEnvironment = require('./ExecutionEnvironment');
+
+var performance;
+
+if (ExecutionEnvironment.canUseDOM) {
+ performance = window.performance || window.msPerformance || window.webkitPerformance;
+}
+
+module.exports = performance || {};
+},{"./ExecutionEnvironment":4}],23:[function(require,module,exports){
+'use strict';
+
+/**
+ * Copyright (c) 2013-present, Facebook, Inc.
+ * All rights reserved.
*
- * CityStore.dispatchToken = flightDispatcher.register(function(payload) {
- * if (payload.actionType === 'country-update') {
- * // `CountryStore.country` may not be updated.
- * flightDispatcher.waitFor([CountryStore.dispatchToken]);
- * // `CountryStore.country` is now guaranteed to be updated.
+ * 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.
*
- * // Select the default city for the new country
- * CityStore.city = getDefaultCityForCountry(CountryStore.country);
- * }
- * });
+ * @typechecks
+ */
+
+var performance = require('./performance');
+
+var performanceNow;
+
+/**
+ * Detect if we can use `window.performance.now()` and gracefully fallback to
+ * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
+ * because of Facebook's testing infrastructure.
+ */
+if (performance.now) {
+ performanceNow = function performanceNow() {
+ return performance.now();
+ };
+} else {
+ performanceNow = function performanceNow() {
+ return Date.now();
+ };
+}
+
+module.exports = performanceNow;
+},{"./performance":22}],24:[function(require,module,exports){
+/**
+ * Copyright (c) 2013-present, Facebook, Inc.
+ * All rights reserved.
*
- * The usage of `waitFor()` can be chained, for example:
- *
- * FlightPriceStore.dispatchToken =
- * flightDispatcher.register(function(payload) {
- * switch (payload.actionType) {
- * case 'country-update':
- * case 'city-update':
- * flightDispatcher.waitFor([CityStore.dispatchToken]);
- * FlightPriceStore.price =
- * getFlightPriceStore(CountryStore.country, CityStore.city);
- * break;
- * }
- * });
+ * 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.
*
- * The `country-update` payload will be guaranteed to invoke the stores'
- * registered callbacks in order: `CountryStore`, `CityStore`, then
- * `FlightPriceStore`.
+ * @typechecks
+ *
*/
-var Dispatcher = (function () {
- function Dispatcher() {
- _classCallCheck(this, Dispatcher);
+/*eslint-disable no-self-compare */
- this._callbacks = {};
- this._isDispatching = false;
- this._isHandled = {};
- this._isPending = {};
- this._lastID = 1;
- }
+'use strict';
- /**
- * Registers a callback to be invoked with every dispatched payload. Returns
- * a token that can be used with `waitFor()`.
- */
+var hasOwnProperty = Object.prototype.hasOwnProperty;
- Dispatcher.prototype.register = function register(callback) {
- var id = _prefix + this._lastID++;
- this._callbacks[id] = callback;
- return id;
- };
+/**
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
+ */
+function is(x, y) {
+ // SameValue algorithm
+ if (x === y) {
+ // Steps 1-5, 7-10
+ // Steps 6.b-6.e: +0 != -0
+ // Added the nonzero y check to make Flow happy, but it is redundant
+ return x !== 0 || y !== 0 || 1 / x === 1 / y;
+ } else {
+ // Step 6.a: NaN == NaN
+ return x !== x && y !== y;
+ }
+}
- /**
- * Removes a callback based on its token.
- */
+/**
+ * Performs equality by iterating through keys on an object and returning false
+ * when any key has values which are not strictly equal between the arguments.
+ * Returns true when the values of all keys are strictly equal.
+ */
+function shallowEqual(objA, objB) {
+ if (is(objA, objB)) {
+ return true;
+ }
- Dispatcher.prototype.unregister = function unregister(id) {
- !this._callbacks[id] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Dispatcher.unregister(...): `%s` does not map to a registered callback.', id) : invariant(false) : undefined;
- delete this._callbacks[id];
- };
+ if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
+ return false;
+ }
- /**
- * Waits for the callbacks specified to be invoked before continuing execution
- * of the current callback. This method should only be used by a callback in
- * response to a dispatched payload.
- */
+ var keysA = Object.keys(objA);
+ var keysB = Object.keys(objB);
- Dispatcher.prototype.waitFor = function waitFor(ids) {
- !this._isDispatching ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Dispatcher.waitFor(...): Must be invoked while dispatching.') : invariant(false) : undefined;
- for (var ii = 0; ii < ids.length; ii++) {
- var id = ids[ii];
- if (this._isPending[id]) {
- !this._isHandled[id] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Dispatcher.waitFor(...): Circular dependency detected while ' + 'waiting for `%s`.', id) : invariant(false) : undefined;
- continue;
- }
- !this._callbacks[id] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Dispatcher.waitFor(...): `%s` does not map to a registered callback.', id) : invariant(false) : undefined;
- this._invokeCallback(id);
+ if (keysA.length !== keysB.length) {
+ return false;
+ }
+
+ // Test for A's keys different from B.
+ for (var i = 0; i < keysA.length; i++) {
+ if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
+ return false;
}
- };
+ }
- /**
- * Dispatches a payload to all registered callbacks.
- */
+ return true;
+}
- Dispatcher.prototype.dispatch = function dispatch(payload) {
- !!this._isDispatching ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.') : invariant(false) : undefined;
- this._startDispatching(payload);
- try {
- for (var id in this._callbacks) {
- if (this._isPending[id]) {
- continue;
- }
- this._invokeCallback(id);
- }
- } finally {
- this._stopDispatching();
- }
- };
+module.exports = shallowEqual;
+},{}],25:[function(require,module,exports){
+(function (process){
+/**
+ * Copyright 2014-2015, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ *
+ */
- /**
- * Is this Dispatcher currently dispatching.
- */
+'use strict';
- Dispatcher.prototype.isDispatching = function isDispatching() {
- return this._isDispatching;
- };
+var emptyFunction = require('./emptyFunction');
- /**
- * Call the callback stored with the given id. Also do some internal
- * bookkeeping.
- *
- * @internal
- */
+/**
+ * Similar to invariant but only logs a warning if the condition is not met.
+ * This can be used to log issues in development environments in critical
+ * paths. Removing the logging code for production environments will keep the
+ * same logic and follow the same code paths.
+ */
- Dispatcher.prototype._invokeCallback = function _invokeCallback(id) {
- this._isPending[id] = true;
- this._callbacks[id](this._pendingPayload);
- this._isHandled[id] = true;
- };
+var warning = emptyFunction;
- /**
- * Set up bookkeeping needed when dispatching.
- *
- * @internal
- */
+if (process.env.NODE_ENV !== 'production') {
+ (function () {
+ var printWarning = function printWarning(format) {
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ args[_key - 1] = arguments[_key];
+ }
- Dispatcher.prototype._startDispatching = function _startDispatching(payload) {
- for (var id in this._callbacks) {
- this._isPending[id] = false;
- this._isHandled[id] = false;
- }
- this._pendingPayload = payload;
- this._isDispatching = true;
- };
+ var argIndex = 0;
+ var message = 'Warning: ' + format.replace(/%s/g, function () {
+ return args[argIndex++];
+ });
+ if (typeof console !== 'undefined') {
+ console.error(message);
+ }
+ try {
+ // --- Welcome to debugging React ---
+ // This error was thrown as a convenience so that you can use this stack
+ // to find the callsite that caused this warning to fire.
+ throw new Error(message);
+ } catch (x) {}
+ };
- /**
- * Clear bookkeeping used for dispatching.
- *
- * @internal
- */
+ warning = function warning(condition, format) {
+ if (format === undefined) {
+ throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
+ }
- Dispatcher.prototype._stopDispatching = function _stopDispatching() {
- delete this._pendingPayload;
- this._isDispatching = false;
- };
+ if (format.indexOf('Failed Composite propType: ') === 0) {
+ return; // Ignore CompositeComponent proptype check.
+ }
- return Dispatcher;
-})();
+ if (!condition) {
+ for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
+ args[_key2 - 2] = arguments[_key2];
+ }
+
+ printWarning.apply(undefined, [format].concat(args));
+ }
+ };
+ })();
+}
-module.exports = Dispatcher;
+module.exports = warning;
}).call(this,require('_process'))
-},{"_process":15,"fbjs/lib/invariant":2}],4:[function(require,module,exports){
+},{"./emptyFunction":10,"_process":43}],26:[function(require,module,exports){
/**
* Copyright 2015, Yahoo! Inc.
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
@@ -9262,7 +10818,7 @@ module.exports = function hoistNonReactStatics(targetComponent, sourceComponent,
return targetComponent;
};
-},{}],5:[function(require,module,exports){
+},{}],27:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-2015, Facebook, Inc.
@@ -9318,7 +10874,7 @@ module.exports = invariant;
}).call(this,require('_process'))
-},{"_process":15}],6:[function(require,module,exports){
+},{"_process":43}],28:[function(require,module,exports){
/**
* lodash 3.9.1 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
@@ -9457,9 +11013,10 @@ function isNative(value) {
module.exports = getNative;
-},{}],7:[function(require,module,exports){
+},{}],29:[function(require,module,exports){
+(function (global){
/**
- * lodash 4.0.6 (Custom Build) <https://lodash.com/>
+ * lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
* Released under MIT license <https://lodash.com/license>
@@ -9474,9 +11031,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
var NAN = 0 / 0;
/** `Object#toString` result references. */
-var funcTag = '[object Function]',
- genTag = '[object GeneratorFunction]',
- symbolTag = '[object Symbol]';
+var symbolTag = '[object Symbol]';
/** Used to match leading and trailing whitespace. */
var reTrim = /^\s+|\s+$/g;
@@ -9493,12 +11048,21 @@ var reIsOctal = /^0o[0-7]+$/i;
/** Built-in method references without a dependency on `root`. */
var freeParseInt = parseInt;
+/** Detect free variable `global` from Node.js. */
+var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+
+/** Detect free variable `self`. */
+var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+/** Used as a reference to the global object. */
+var root = freeGlobal || freeSelf || Function('return this')();
+
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
@@ -9514,7 +11078,6 @@ var nativeMax = Math.max,
* @static
* @memberOf _
* @since 2.4.0
- * @type {Function}
* @category Date
* @returns {number} Returns the timestamp.
* @example
@@ -9522,23 +11085,29 @@ var nativeMax = Math.max,
* _.defer(function(stamp) {
* console.log(_.now() - stamp);
* }, _.now());
- * // => Logs the number of milliseconds it took for the deferred function to be invoked.
+ * // => Logs the number of milliseconds it took for the deferred invocation.
*/
-var now = Date.now;
+var now = function() {
+ return root.Date.now();
+};
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
- * Provide an options object to indicate whether `func` should be invoked on
- * the leading and/or trailing edge of the `wait` timeout. The `func` is invoked
- * with the last arguments provided to the debounced function. Subsequent calls
- * to the debounced function return the result of the last `func` invocation.
+ * Provide `options` to indicate whether `func` should be invoked on the
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
+ * with the last arguments provided to the debounced function. Subsequent
+ * calls to the debounced function return the result of the last `func`
+ * invocation.
+ *
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
+ * invoked on the trailing edge of the timeout only if the debounced function
+ * is invoked more than once during the `wait` timeout.
*
- * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
- * on the trailing edge of the timeout only if the debounced function is
- * invoked more than once during the `wait` timeout.
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
@@ -9582,7 +11151,7 @@ function debounce(func, wait, options) {
maxWait,
result,
timerId,
- lastCallTime = 0,
+ lastCallTime,
lastInvokeTime = 0,
leading = false,
maxing = false,
@@ -9633,7 +11202,7 @@ function debounce(func, wait, options) {
// Either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
- return (!lastCallTime || (timeSinceLastCall >= wait) ||
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
}
@@ -9647,7 +11216,6 @@ function debounce(func, wait, options) {
}
function trailingEdge(time) {
- clearTimeout(timerId);
timerId = undefined;
// Only invoke if we have `lastArgs` which means `func` has been
@@ -9663,8 +11231,8 @@ function debounce(func, wait, options) {
if (timerId !== undefined) {
clearTimeout(timerId);
}
- lastCallTime = lastInvokeTime = 0;
- lastArgs = lastThis = timerId = undefined;
+ lastInvokeTime = 0;
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
}
function flush() {
@@ -9685,7 +11253,6 @@ function debounce(func, wait, options) {
}
if (maxing) {
// Handle invocations in a tight loop.
- clearTimeout(timerId);
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
@@ -9701,34 +11268,8 @@ function debounce(func, wait, options) {
}
/**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @since 0.1.0
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
-function isFunction(value) {
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 8 which returns 'object' for typed array and weak map constructors,
- // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
- var tag = isObject(value) ? objectToString.call(value) : '';
- return tag == funcTag || tag == genTag;
-}
-
-/**
* Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
@@ -9792,8 +11333,7 @@ function isObjectLike(value) {
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
@@ -9818,8 +11358,8 @@ function isSymbol(value) {
* @returns {number} Returns the number.
* @example
*
- * _.toNumber(3);
- * // => 3
+ * _.toNumber(3.2);
+ * // => 3.2
*
* _.toNumber(Number.MIN_VALUE);
* // => 5e-324
@@ -9827,8 +11367,8 @@ function isSymbol(value) {
* _.toNumber(Infinity);
* // => Infinity
*
- * _.toNumber('3');
- * // => 3
+ * _.toNumber('3.2');
+ * // => 3.2
*/
function toNumber(value) {
if (typeof value == 'number') {
@@ -9838,7 +11378,7 @@ function toNumber(value) {
return NAN;
}
if (isObject(value)) {
- var other = isFunction(value.valueOf) ? value.valueOf() : value;
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
value = isObject(other) ? (other + '') : other;
}
if (typeof value != 'string') {
@@ -9853,14 +11393,16 @@ function toNumber(value) {
module.exports = debounce;
-},{}],8:[function(require,module,exports){
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+
+},{}],30:[function(require,module,exports){
/**
- * lodash 3.0.8 (Custom Build) <https://lodash.com/>
+ * lodash (Custom Build) <https://lodash.com/>
* Build: `lodash modularize exports="npm" -o ./`
- * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
+ * Copyright jQuery Foundation and other contributors <https://jquery.org/>
+ * Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
- * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license <https://lodash.com/license>
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/
/** Used as references for various `Number` constants. */
@@ -9878,7 +11420,8 @@ var objectProto = Object.prototype;
var hasOwnProperty = objectProto.hasOwnProperty;
/**
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var objectToString = objectProto.toString;
@@ -9887,38 +11430,15 @@ var objectToString = objectProto.toString;
var propertyIsEnumerable = objectProto.propertyIsEnumerable;
/**
- * The base implementation of `_.property` without support for deep paths.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new function.
- */
-function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
- };
-}
-
-/**
- * Gets the "length" property value of `object`.
- *
- * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
- * that affects Safari on at least iOS 8.1-8.3 ARM64.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {*} Returns the "length" value.
- */
-var getLength = baseProperty('length');
-
-/**
* Checks if `value` is likely an `arguments` object.
*
* @static
* @memberOf _
+ * @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ * else `false`.
* @example
*
* _.isArguments(function() { return arguments; }());
@@ -9928,7 +11448,7 @@ var getLength = baseProperty('length');
* // => false
*/
function isArguments(value) {
- // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
+ // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
(!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
}
@@ -9940,6 +11460,7 @@ function isArguments(value) {
*
* @static
* @memberOf _
+ * @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
@@ -9958,7 +11479,7 @@ function isArguments(value) {
* // => false
*/
function isArrayLike(value) {
- return value != null && isLength(getLength(value)) && !isFunction(value);
+ return value != null && isLength(value.length) && !isFunction(value);
}
/**
@@ -9967,9 +11488,11 @@ function isArrayLike(value) {
*
* @static
* @memberOf _
+ * @since 4.0.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
+ * @returns {boolean} Returns `true` if `value` is an array-like object,
+ * else `false`.
* @example
*
* _.isArrayLikeObject([1, 2, 3]);
@@ -9993,9 +11516,10 @@ function isArrayLikeObject(value) {
*
* @static
* @memberOf _
+ * @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
@@ -10006,8 +11530,7 @@ function isArrayLikeObject(value) {
*/
function isFunction(value) {
// The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 8 which returns 'object' for typed array and weak map constructors,
- // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
+ // in Safari 8-9 which returns 'object' for typed array and other constructors.
var tag = isObject(value) ? objectToString.call(value) : '';
return tag == funcTag || tag == genTag;
}
@@ -10015,10 +11538,12 @@ function isFunction(value) {
/**
* Checks if `value` is a valid array-like length.
*
- * **Note:** This function is loosely based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
+ * **Note:** This method is loosely based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
*
* @static
* @memberOf _
+ * @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
@@ -10042,11 +11567,13 @@ function isLength(value) {
}
/**
- * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
- * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ * Checks if `value` is the
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
+ * @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
@@ -10075,6 +11602,7 @@ function isObject(value) {
*
* @static
* @memberOf _
+ * @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
@@ -10098,7 +11626,7 @@ function isObjectLike(value) {
module.exports = isArguments;
-},{}],9:[function(require,module,exports){
+},{}],31:[function(require,module,exports){
/**
* lodash 3.0.4 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
@@ -10280,46 +11808,400 @@ function isNative(value) {
module.exports = isArray;
-},{}],10:[function(require,module,exports){
-/* Built-in method references for those with the same name as other `lodash` methods. */
-var nativeGetPrototype = Object.getPrototypeOf;
+},{}],32:[function(require,module,exports){
+/**
+ * lodash 3.1.2 (Custom Build) <https://lodash.com/>
+ * Build: `lodash modern modularize exports="npm" -o ./`
+ * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
+ * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+ * Available under MIT license <https://lodash.com/license>
+ */
+var getNative = require('lodash._getnative'),
+ isArguments = require('lodash.isarguments'),
+ isArray = require('lodash.isarray');
+
+/** Used to detect unsigned integer values. */
+var reIsUint = /^\d+$/;
+
+/** Used for native method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/* Native method references for those with the same name as other `lodash` methods. */
+var nativeKeys = getNative(Object, 'keys');
+
+/**
+ * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
+ * of an array-like value.
+ */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/**
+ * The base implementation of `_.property` without support for deep paths.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @returns {Function} Returns the new function.
+ */
+function baseProperty(key) {
+ return function(object) {
+ return object == null ? undefined : object[key];
+ };
+}
+
+/**
+ * Gets the "length" property value of `object`.
+ *
+ * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
+ * that affects Safari on at least iOS 8.1-8.3 ARM64.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {*} Returns the "length" value.
+ */
+var getLength = baseProperty('length');
+
+/**
+ * Checks if `value` is array-like.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
+ */
+function isArrayLike(value) {
+ return value != null && isLength(getLength(value));
+}
+
+/**
+ * Checks if `value` is a valid array-like index.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
+ */
+function isIndex(value, length) {
+ value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
+ length = length == null ? MAX_SAFE_INTEGER : length;
+ return value > -1 && value % 1 == 0 && value < length;
+}
+
+/**
+ * Checks if `value` is a valid array-like length.
+ *
+ * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
+ */
+function isLength(value) {
+ return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+}
+
+/**
+ * A fallback implementation of `Object.keys` which creates an array of the
+ * own enumerable property names of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+function shimKeys(object) {
+ var props = keysIn(object),
+ propsLength = props.length,
+ length = propsLength && object.length;
+
+ var allowIndexes = !!length && isLength(length) &&
+ (isArray(object) || isArguments(object));
+
+ var index = -1,
+ result = [];
+
+ while (++index < propsLength) {
+ var key = props[index];
+ if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+/**
+ * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
+ * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
+ * @example
+ *
+ * _.isObject({});
+ * // => true
+ *
+ * _.isObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isObject(1);
+ * // => false
+ */
+function isObject(value) {
+ // Avoid a V8 JIT bug in Chrome 19-20.
+ // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
+ var type = typeof value;
+ return !!value && (type == 'object' || type == 'function');
+}
+
+/**
+ * Creates an array of the own enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects. See the
+ * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
+ * for more details.
+ *
+ * @static
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keys(new Foo);
+ * // => ['a', 'b'] (iteration order is not guaranteed)
+ *
+ * _.keys('hi');
+ * // => ['0', '1']
+ */
+var keys = !nativeKeys ? shimKeys : function(object) {
+ var Ctor = object == null ? undefined : object.constructor;
+ if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
+ (typeof object != 'function' && isArrayLike(object))) {
+ return shimKeys(object);
+ }
+ return isObject(object) ? nativeKeys(object) : [];
+};
/**
- * Gets the `[[Prototype]]` of `value`.
+ * Creates an array of the own and inherited enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keysIn(new Foo);
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
+ */
+function keysIn(object) {
+ if (object == null) {
+ return [];
+ }
+ if (!isObject(object)) {
+ object = Object(object);
+ }
+ var length = object.length;
+ length = (length && isLength(length) &&
+ (isArray(object) || isArguments(object)) && length) || 0;
+
+ var Ctor = object.constructor,
+ index = -1,
+ isProto = typeof Ctor == 'function' && Ctor.prototype === object,
+ result = Array(length),
+ skipIndexes = length > 0;
+
+ while (++index < length) {
+ result[index] = (index + '');
+ }
+ for (var key in object) {
+ if (!(skipIndexes && isIndex(key, length)) &&
+ !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+module.exports = keys;
+
+},{"lodash._getnative":28,"lodash.isarguments":30,"lodash.isarray":31}],33:[function(require,module,exports){
+var root = require('./_root');
+
+/** Built-in value references. */
+var Symbol = root.Symbol;
+
+module.exports = Symbol;
+
+},{"./_root":40}],34:[function(require,module,exports){
+var Symbol = require('./_Symbol'),
+ getRawTag = require('./_getRawTag'),
+ objectToString = require('./_objectToString');
+
+/** `Object#toString` result references. */
+var nullTag = '[object Null]',
+ undefinedTag = '[object Undefined]';
+
+/** Built-in value references. */
+var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
+
+/**
+ * The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
- * @returns {null|Object} Returns the `[[Prototype]]`.
+ * @returns {string} Returns the `toStringTag`.
*/
-function getPrototype(value) {
- return nativeGetPrototype(Object(value));
+function baseGetTag(value) {
+ if (value == null) {
+ return value === undefined ? undefinedTag : nullTag;
+ }
+ return (symToStringTag && symToStringTag in Object(value))
+ ? getRawTag(value)
+ : objectToString(value);
}
+module.exports = baseGetTag;
+
+},{"./_Symbol":33,"./_getRawTag":37,"./_objectToString":38}],35:[function(require,module,exports){
+(function (global){
+/** Detect free variable `global` from Node.js. */
+var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+
+module.exports = freeGlobal;
+
+}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
+
+},{}],36:[function(require,module,exports){
+var overArg = require('./_overArg');
+
+/** Built-in value references. */
+var getPrototype = overArg(Object.getPrototypeOf, Object);
+
module.exports = getPrototype;
-},{}],11:[function(require,module,exports){
+},{"./_overArg":39}],37:[function(require,module,exports){
+var Symbol = require('./_Symbol');
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var nativeObjectToString = objectProto.toString;
+
+/** Built-in value references. */
+var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
+
/**
- * Checks if `value` is a host object in IE < 9.
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
+ * @param {*} value The value to query.
+ * @returns {string} Returns the raw `toStringTag`.
*/
-function isHostObject(value) {
- // Many host objects are `Object` objects that can coerce to strings
- // despite having improperly defined `toString` methods.
- var result = false;
- if (value != null && typeof value.toString != 'function') {
- try {
- result = !!(value + '');
- } catch (e) {}
+function getRawTag(value) {
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
+ tag = value[symToStringTag];
+
+ try {
+ value[symToStringTag] = undefined;
+ var unmasked = true;
+ } catch (e) {}
+
+ var result = nativeObjectToString.call(value);
+ if (unmasked) {
+ if (isOwn) {
+ value[symToStringTag] = tag;
+ } else {
+ delete value[symToStringTag];
+ }
}
return result;
}
-module.exports = isHostObject;
+module.exports = getRawTag;
+
+},{"./_Symbol":33}],38:[function(require,module,exports){
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var nativeObjectToString = objectProto.toString;
+
+/**
+ * Converts `value` to a string using `Object.prototype.toString`.
+ *
+ * @private
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ */
+function objectToString(value) {
+ return nativeObjectToString.call(value);
+}
+
+module.exports = objectToString;
-},{}],12:[function(require,module,exports){
+},{}],39:[function(require,module,exports){
+/**
+ * Creates a unary function that invokes `func` with its argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+function overArg(func, transform) {
+ return function(arg) {
+ return func(transform(arg));
+ };
+}
+
+module.exports = overArg;
+
+},{}],40:[function(require,module,exports){
+var freeGlobal = require('./_freeGlobal');
+
+/** Detect free variable `self`. */
+var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+/** Used as a reference to the global object. */
+var root = freeGlobal || freeSelf || Function('return this')();
+
+module.exports = root;
+
+},{"./_freeGlobal":35}],41:[function(require,module,exports){
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
@@ -10345,24 +12227,25 @@ module.exports = isHostObject;
* // => false
*/
function isObjectLike(value) {
- return !!value && typeof value == 'object';
+ return value != null && typeof value == 'object';
}
module.exports = isObjectLike;
-},{}],13:[function(require,module,exports){
-var getPrototype = require('./_getPrototype'),
- isHostObject = require('./_isHostObject'),
+},{}],42:[function(require,module,exports){
+var baseGetTag = require('./_baseGetTag'),
+ getPrototype = require('./_getPrototype'),
isObjectLike = require('./isObjectLike');
/** `Object#toString` result references. */
var objectTag = '[object Object]';
/** Used for built-in method references. */
-var objectProto = Object.prototype;
+var funcProto = Function.prototype,
+ objectProto = Object.prototype;
/** Used to resolve the decompiled source of functions. */
-var funcToString = Function.prototype.toString;
+var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
@@ -10371,13 +12254,6 @@ var hasOwnProperty = objectProto.hasOwnProperty;
var objectCtorString = funcToString.call(Object);
/**
- * Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
-var objectToString = objectProto.toString;
-
-/**
* Checks if `value` is a plain object, that is, an object created by the
* `Object` constructor or one with a `[[Prototype]]` of `null`.
*
@@ -10386,8 +12262,7 @@ var objectToString = objectProto.toString;
* @since 0.8.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a plain object,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
* @example
*
* function Foo() {
@@ -10407,8 +12282,7 @@ var objectToString = objectProto.toString;
* // => true
*/
function isPlainObject(value) {
- if (!isObjectLike(value) ||
- objectToString.call(value) != objectTag || isHostObject(value)) {
+ if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
return false;
}
var proto = getPrototype(value);
@@ -10416,100 +12290,14 @@ function isPlainObject(value) {
return true;
}
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
- return (typeof Ctor == 'function' &&
- Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
+ return typeof Ctor == 'function' && Ctor instanceof Ctor &&
+ funcToString.call(Ctor) == objectCtorString;
}
module.exports = isPlainObject;
-},{"./_getPrototype":10,"./_isHostObject":11,"./isObjectLike":12}],14:[function(require,module,exports){
-'use strict';
-/* eslint-disable no-unused-vars */
-var hasOwnProperty = Object.prototype.hasOwnProperty;
-var propIsEnumerable = Object.prototype.propertyIsEnumerable;
-
-function toObject(val) {
- if (val === null || val === undefined) {
- throw new TypeError('Object.assign cannot be called with null or undefined');
- }
-
- return Object(val);
-}
-
-function shouldUseNative() {
- try {
- if (!Object.assign) {
- return false;
- }
-
- // Detect buggy property enumeration order in older V8 versions.
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
- var test1 = new String('abc'); // eslint-disable-line
- test1[5] = 'de';
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test2 = {};
- for (var i = 0; i < 10; i++) {
- test2['_' + String.fromCharCode(i)] = i;
- }
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
- return test2[n];
- });
- if (order2.join('') !== '0123456789') {
- return false;
- }
-
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
- var test3 = {};
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
- test3[letter] = letter;
- });
- if (Object.keys(Object.assign({}, test3)).join('') !==
- 'abcdefghijklmnopqrst') {
- return false;
- }
-
- return true;
- } catch (e) {
- // We don't expect any of the above to throw, but better to be safe.
- return false;
- }
-}
-
-module.exports = shouldUseNative() ? Object.assign : function (target, source) {
- var from;
- var to = toObject(target);
- var symbols;
-
- for (var s = 1; s < arguments.length; s++) {
- from = Object(arguments[s]);
-
- for (var key in from) {
- if (hasOwnProperty.call(from, key)) {
- to[key] = from[key];
- }
- }
-
- if (Object.getOwnPropertySymbols) {
- symbols = Object.getOwnPropertySymbols(from);
- for (var i = 0; i < symbols.length; i++) {
- if (propIsEnumerable.call(from, symbols[i])) {
- to[symbols[i]] = from[symbols[i]];
- }
- }
- }
- }
-
- return to;
-};
-
-},{}],15:[function(require,module,exports){
+},{"./_baseGetTag":34,"./_getPrototype":36,"./isObjectLike":41}],43:[function(require,module,exports){
// shim for using process in browser
-
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
@@ -10520,22 +12308,84 @@ var process = module.exports = {};
var cachedSetTimeout;
var cachedClearTimeout;
+function defaultSetTimout() {
+ throw new Error('setTimeout has not been defined');
+}
+function defaultClearTimeout () {
+ throw new Error('clearTimeout has not been defined');
+}
(function () {
- try {
- cachedSetTimeout = setTimeout;
- } catch (e) {
- cachedSetTimeout = function () {
- throw new Error('setTimeout is not defined');
+ try {
+ if (typeof setTimeout === 'function') {
+ cachedSetTimeout = setTimeout;
+ } else {
+ cachedSetTimeout = defaultSetTimout;
+ }
+ } catch (e) {
+ cachedSetTimeout = defaultSetTimout;
}
- }
- try {
- cachedClearTimeout = clearTimeout;
- } catch (e) {
- cachedClearTimeout = function () {
- throw new Error('clearTimeout is not defined');
+ try {
+ if (typeof clearTimeout === 'function') {
+ cachedClearTimeout = clearTimeout;
+ } else {
+ cachedClearTimeout = defaultClearTimeout;
+ }
+ } catch (e) {
+ cachedClearTimeout = defaultClearTimeout;
}
- }
} ())
+function runTimeout(fun) {
+ if (cachedSetTimeout === setTimeout) {
+ //normal enviroments in sane situations
+ return setTimeout(fun, 0);
+ }
+ // if setTimeout wasn't available but was latter defined
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
+ cachedSetTimeout = setTimeout;
+ return setTimeout(fun, 0);
+ }
+ try {
+ // when when somebody has screwed with setTimeout but no I.E. maddness
+ return cachedSetTimeout(fun, 0);
+ } catch(e){
+ try {
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
+ return cachedSetTimeout.call(null, fun, 0);
+ } catch(e){
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
+ return cachedSetTimeout.call(this, fun, 0);
+ }
+ }
+
+
+}
+function runClearTimeout(marker) {
+ if (cachedClearTimeout === clearTimeout) {
+ //normal enviroments in sane situations
+ return clearTimeout(marker);
+ }
+ // if clearTimeout wasn't available but was latter defined
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
+ cachedClearTimeout = clearTimeout;
+ return clearTimeout(marker);
+ }
+ try {
+ // when when somebody has screwed with setTimeout but no I.E. maddness
+ return cachedClearTimeout(marker);
+ } catch (e){
+ try {
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
+ return cachedClearTimeout.call(null, marker);
+ } catch (e){
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
+ // Some versions of I.E. have different rules for clearTimeout vs setTimeout
+ return cachedClearTimeout.call(this, marker);
+ }
+ }
+
+
+
+}
var queue = [];
var draining = false;
var currentQueue;
@@ -10560,7 +12410,7 @@ function drainQueue() {
if (draining) {
return;
}
- var timeout = cachedSetTimeout(cleanUpNextTick);
+ var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
@@ -10577,7 +12427,7 @@ function drainQueue() {
}
currentQueue = null;
draining = false;
- cachedClearTimeout(timeout);
+ runClearTimeout(timeout);
}
process.nextTick = function (fun) {
@@ -10589,7 +12439,7 @@ process.nextTick = function (fun) {
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
- cachedSetTimeout(drainQueue, 0);
+ runTimeout(drainQueue);
}
};
@@ -10628,563 +12478,81 @@ process.chdir = function (dir) {
};
process.umask = function() { return 0; };
-},{}],16:[function(require,module,exports){
-(function (process){
-'use strict';
-
-exports.__esModule = true;
-exports["default"] = undefined;
-
-var _react = require('react');
-
-var _storeShape = require('../utils/storeShape');
-
-var _storeShape2 = _interopRequireDefault(_storeShape);
-
-var _warning = require('../utils/warning');
-
-var _warning2 = _interopRequireDefault(_warning);
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-var didWarnAboutReceivingStore = false;
-function warnAboutReceivingStore() {
- if (didWarnAboutReceivingStore) {
- return;
- }
- didWarnAboutReceivingStore = true;
-
- (0, _warning2["default"])('<Provider> does not support changing `store` on the fly. ' + 'It is most likely that you see this error because you updated to ' + 'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' + 'automatically. See https://github.com/reactjs/react-redux/releases/' + 'tag/v2.0.0 for the migration instructions.');
-}
-
-var Provider = function (_Component) {
- _inherits(Provider, _Component);
-
- Provider.prototype.getChildContext = function getChildContext() {
- return { store: this.store };
- };
-
- function Provider(props, context) {
- _classCallCheck(this, Provider);
-
- var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
-
- _this.store = props.store;
- return _this;
- }
-
- Provider.prototype.render = function render() {
- var children = this.props.children;
-
- return _react.Children.only(children);
- };
-
- return Provider;
-}(_react.Component);
-
-exports["default"] = Provider;
-
-if (process.env.NODE_ENV !== 'production') {
- Provider.prototype.componentWillReceiveProps = function (nextProps) {
- var store = this.store;
- var nextStore = nextProps.store;
-
- if (store !== nextStore) {
- warnAboutReceivingStore();
- }
- };
-}
-
-Provider.propTypes = {
- store: _storeShape2["default"].isRequired,
- children: _react.PropTypes.element.isRequired
-};
-Provider.childContextTypes = {
- store: _storeShape2["default"].isRequired
-};
-}).call(this,require('_process'))
-
-},{"../utils/storeShape":19,"../utils/warning":20,"_process":15,"react":"react"}],17:[function(require,module,exports){
-(function (process){
-'use strict';
-
-var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-
-exports.__esModule = true;
-exports["default"] = connect;
-
-var _react = require('react');
-
-var _storeShape = require('../utils/storeShape');
-
-var _storeShape2 = _interopRequireDefault(_storeShape);
-
-var _shallowEqual = require('../utils/shallowEqual');
-
-var _shallowEqual2 = _interopRequireDefault(_shallowEqual);
-
-var _wrapActionCreators = require('../utils/wrapActionCreators');
-
-var _wrapActionCreators2 = _interopRequireDefault(_wrapActionCreators);
-
-var _warning = require('../utils/warning');
-
-var _warning2 = _interopRequireDefault(_warning);
-
-var _isPlainObject = require('lodash/isPlainObject');
-
-var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
-
-var _hoistNonReactStatics = require('hoist-non-react-statics');
-
-var _hoistNonReactStatics2 = _interopRequireDefault(_hoistNonReactStatics);
-
-var _invariant = require('invariant');
-
-var _invariant2 = _interopRequireDefault(_invariant);
-
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
-function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
-
-function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
-
-var defaultMapStateToProps = function defaultMapStateToProps(state) {
- return {};
-}; // eslint-disable-line no-unused-vars
-var defaultMapDispatchToProps = function defaultMapDispatchToProps(dispatch) {
- return { dispatch: dispatch };
-};
-var defaultMergeProps = function defaultMergeProps(stateProps, dispatchProps, parentProps) {
- return _extends({}, parentProps, stateProps, dispatchProps);
-};
-
-function getDisplayName(WrappedComponent) {
- return WrappedComponent.displayName || WrappedComponent.name || 'Component';
-}
-
-var errorObject = { value: null };
-function tryCatch(fn, ctx) {
- try {
- return fn.apply(ctx);
- } catch (e) {
- errorObject.value = e;
- return errorObject;
- }
-}
-
-// Helps track hot reloading.
-var nextVersion = 0;
-
-function connect(mapStateToProps, mapDispatchToProps, mergeProps) {
- var options = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
-
- var shouldSubscribe = Boolean(mapStateToProps);
- var mapState = mapStateToProps || defaultMapStateToProps;
-
- var mapDispatch = undefined;
- if (typeof mapDispatchToProps === 'function') {
- mapDispatch = mapDispatchToProps;
- } else if (!mapDispatchToProps) {
- mapDispatch = defaultMapDispatchToProps;
- } else {
- mapDispatch = (0, _wrapActionCreators2["default"])(mapDispatchToProps);
- }
-
- var finalMergeProps = mergeProps || defaultMergeProps;
- var _options$pure = options.pure;
- var pure = _options$pure === undefined ? true : _options$pure;
- var _options$withRef = options.withRef;
- var withRef = _options$withRef === undefined ? false : _options$withRef;
-
- var checkMergedEquals = pure && finalMergeProps !== defaultMergeProps;
-
- // Helps track hot reloading.
- var version = nextVersion++;
-
- return function wrapWithConnect(WrappedComponent) {
- var connectDisplayName = 'Connect(' + getDisplayName(WrappedComponent) + ')';
-
- function checkStateShape(props, methodName) {
- if (!(0, _isPlainObject2["default"])(props)) {
- (0, _warning2["default"])(methodName + '() in ' + connectDisplayName + ' must return a plain object. ' + ('Instead received ' + props + '.'));
- }
- }
-
- function computeMergedProps(stateProps, dispatchProps, parentProps) {
- var mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps);
- if (process.env.NODE_ENV !== 'production') {
- checkStateShape(mergedProps, 'mergeProps');
- }
- return mergedProps;
- }
-
- var Connect = function (_Component) {
- _inherits(Connect, _Component);
-
- Connect.prototype.shouldComponentUpdate = function shouldComponentUpdate() {
- return !pure || this.haveOwnPropsChanged || this.hasStoreStateChanged;
- };
-
- function Connect(props, context) {
- _classCallCheck(this, Connect);
-
- var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
-
- _this.version = version;
- _this.store = props.store || context.store;
-
- (0, _invariant2["default"])(_this.store, 'Could not find "store" in either the context or ' + ('props of "' + connectDisplayName + '". ') + 'Either wrap the root component in a <Provider>, ' + ('or explicitly pass "store" as a prop to "' + connectDisplayName + '".'));
-
- var storeState = _this.store.getState();
- _this.state = { storeState: storeState };
- _this.clearCache();
- return _this;
- }
-
- Connect.prototype.computeStateProps = function computeStateProps(store, props) {
- if (!this.finalMapStateToProps) {
- return this.configureFinalMapState(store, props);
- }
-
- var state = store.getState();
- var stateProps = this.doStatePropsDependOnOwnProps ? this.finalMapStateToProps(state, props) : this.finalMapStateToProps(state);
-
- if (process.env.NODE_ENV !== 'production') {
- checkStateShape(stateProps, 'mapStateToProps');
- }
- return stateProps;
- };
-
- Connect.prototype.configureFinalMapState = function configureFinalMapState(store, props) {
- var mappedState = mapState(store.getState(), props);
- var isFactory = typeof mappedState === 'function';
-
- this.finalMapStateToProps = isFactory ? mappedState : mapState;
- this.doStatePropsDependOnOwnProps = this.finalMapStateToProps.length !== 1;
-
- if (isFactory) {
- return this.computeStateProps(store, props);
- }
-
- if (process.env.NODE_ENV !== 'production') {
- checkStateShape(mappedState, 'mapStateToProps');
- }
- return mappedState;
- };
-
- Connect.prototype.computeDispatchProps = function computeDispatchProps(store, props) {
- if (!this.finalMapDispatchToProps) {
- return this.configureFinalMapDispatch(store, props);
- }
-
- var dispatch = store.dispatch;
-
- var dispatchProps = this.doDispatchPropsDependOnOwnProps ? this.finalMapDispatchToProps(dispatch, props) : this.finalMapDispatchToProps(dispatch);
-
- if (process.env.NODE_ENV !== 'production') {
- checkStateShape(dispatchProps, 'mapDispatchToProps');
- }
- return dispatchProps;
- };
-
- Connect.prototype.configureFinalMapDispatch = function configureFinalMapDispatch(store, props) {
- var mappedDispatch = mapDispatch(store.dispatch, props);
- var isFactory = typeof mappedDispatch === 'function';
-
- this.finalMapDispatchToProps = isFactory ? mappedDispatch : mapDispatch;
- this.doDispatchPropsDependOnOwnProps = this.finalMapDispatchToProps.length !== 1;
-
- if (isFactory) {
- return this.computeDispatchProps(store, props);
- }
-
- if (process.env.NODE_ENV !== 'production') {
- checkStateShape(mappedDispatch, 'mapDispatchToProps');
- }
- return mappedDispatch;
- };
-
- Connect.prototype.updateStatePropsIfNeeded = function updateStatePropsIfNeeded() {
- var nextStateProps = this.computeStateProps(this.store, this.props);
- if (this.stateProps && (0, _shallowEqual2["default"])(nextStateProps, this.stateProps)) {
- return false;
- }
-
- this.stateProps = nextStateProps;
- return true;
- };
-
- Connect.prototype.updateDispatchPropsIfNeeded = function updateDispatchPropsIfNeeded() {
- var nextDispatchProps = this.computeDispatchProps(this.store, this.props);
- if (this.dispatchProps && (0, _shallowEqual2["default"])(nextDispatchProps, this.dispatchProps)) {
- return false;
- }
-
- this.dispatchProps = nextDispatchProps;
- return true;
- };
-
- Connect.prototype.updateMergedPropsIfNeeded = function updateMergedPropsIfNeeded() {
- var nextMergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props);
- if (this.mergedProps && checkMergedEquals && (0, _shallowEqual2["default"])(nextMergedProps, this.mergedProps)) {
- return false;
- }
-
- this.mergedProps = nextMergedProps;
- return true;
- };
-
- Connect.prototype.isSubscribed = function isSubscribed() {
- return typeof this.unsubscribe === 'function';
- };
-
- Connect.prototype.trySubscribe = function trySubscribe() {
- if (shouldSubscribe && !this.unsubscribe) {
- this.unsubscribe = this.store.subscribe(this.handleChange.bind(this));
- this.handleChange();
- }
- };
-
- Connect.prototype.tryUnsubscribe = function tryUnsubscribe() {
- if (this.unsubscribe) {
- this.unsubscribe();
- this.unsubscribe = null;
- }
- };
-
- Connect.prototype.componentDidMount = function componentDidMount() {
- this.trySubscribe();
- };
-
- Connect.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
- if (!pure || !(0, _shallowEqual2["default"])(nextProps, this.props)) {
- this.haveOwnPropsChanged = true;
- }
- };
-
- Connect.prototype.componentWillUnmount = function componentWillUnmount() {
- this.tryUnsubscribe();
- this.clearCache();
- };
-
- Connect.prototype.clearCache = function clearCache() {
- this.dispatchProps = null;
- this.stateProps = null;
- this.mergedProps = null;
- this.haveOwnPropsChanged = true;
- this.hasStoreStateChanged = true;
- this.haveStatePropsBeenPrecalculated = false;
- this.statePropsPrecalculationError = null;
- this.renderedElement = null;
- this.finalMapDispatchToProps = null;
- this.finalMapStateToProps = null;
- };
-
- Connect.prototype.handleChange = function handleChange() {
- if (!this.unsubscribe) {
- return;
- }
-
- var storeState = this.store.getState();
- var prevStoreState = this.state.storeState;
- if (pure && prevStoreState === storeState) {
- return;
- }
-
- if (pure && !this.doStatePropsDependOnOwnProps) {
- var haveStatePropsChanged = tryCatch(this.updateStatePropsIfNeeded, this);
- if (!haveStatePropsChanged) {
- return;
- }
- if (haveStatePropsChanged === errorObject) {
- this.statePropsPrecalculationError = errorObject.value;
- }
- this.haveStatePropsBeenPrecalculated = true;
- }
-
- this.hasStoreStateChanged = true;
- this.setState({ storeState: storeState });
- };
-
- Connect.prototype.getWrappedInstance = function getWrappedInstance() {
- (0, _invariant2["default"])(withRef, 'To access the wrapped instance, you need to specify ' + '{ withRef: true } as the fourth argument of the connect() call.');
-
- return this.refs.wrappedInstance;
- };
-
- Connect.prototype.render = function render() {
- var haveOwnPropsChanged = this.haveOwnPropsChanged;
- var hasStoreStateChanged = this.hasStoreStateChanged;
- var haveStatePropsBeenPrecalculated = this.haveStatePropsBeenPrecalculated;
- var statePropsPrecalculationError = this.statePropsPrecalculationError;
- var renderedElement = this.renderedElement;
-
- this.haveOwnPropsChanged = false;
- this.hasStoreStateChanged = false;
- this.haveStatePropsBeenPrecalculated = false;
- this.statePropsPrecalculationError = null;
-
- if (statePropsPrecalculationError) {
- throw statePropsPrecalculationError;
- }
-
- var shouldUpdateStateProps = true;
- var shouldUpdateDispatchProps = true;
- if (pure && renderedElement) {
- shouldUpdateStateProps = hasStoreStateChanged || haveOwnPropsChanged && this.doStatePropsDependOnOwnProps;
- shouldUpdateDispatchProps = haveOwnPropsChanged && this.doDispatchPropsDependOnOwnProps;
- }
-
- var haveStatePropsChanged = false;
- var haveDispatchPropsChanged = false;
- if (haveStatePropsBeenPrecalculated) {
- haveStatePropsChanged = true;
- } else if (shouldUpdateStateProps) {
- haveStatePropsChanged = this.updateStatePropsIfNeeded();
- }
- if (shouldUpdateDispatchProps) {
- haveDispatchPropsChanged = this.updateDispatchPropsIfNeeded();
- }
-
- var haveMergedPropsChanged = true;
- if (haveStatePropsChanged || haveDispatchPropsChanged || haveOwnPropsChanged) {
- haveMergedPropsChanged = this.updateMergedPropsIfNeeded();
- } else {
- haveMergedPropsChanged = false;
- }
-
- if (!haveMergedPropsChanged && renderedElement) {
- return renderedElement;
- }
-
- if (withRef) {
- this.renderedElement = (0, _react.createElement)(WrappedComponent, _extends({}, this.mergedProps, {
- ref: 'wrappedInstance'
- }));
- } else {
- this.renderedElement = (0, _react.createElement)(WrappedComponent, this.mergedProps);
- }
-
- return this.renderedElement;
- };
-
- return Connect;
- }(_react.Component);
-
- Connect.displayName = connectDisplayName;
- Connect.WrappedComponent = WrappedComponent;
- Connect.contextTypes = {
- store: _storeShape2["default"]
- };
- Connect.propTypes = {
- store: _storeShape2["default"]
- };
-
- if (process.env.NODE_ENV !== 'production') {
- Connect.prototype.componentWillUpdate = function componentWillUpdate() {
- if (this.version === version) {
- return;
- }
-
- // We are hot reloading!
- this.version = version;
- this.trySubscribe();
- this.clearCache();
- };
- }
-
- return (0, _hoistNonReactStatics2["default"])(Connect, WrappedComponent);
- };
-}
-}).call(this,require('_process'))
-
-},{"../utils/shallowEqual":18,"../utils/storeShape":19,"../utils/warning":20,"../utils/wrapActionCreators":21,"_process":15,"hoist-non-react-statics":4,"invariant":5,"lodash/isPlainObject":13,"react":"react"}],18:[function(require,module,exports){
-"use strict";
-
-exports.__esModule = true;
-exports["default"] = shallowEqual;
-function shallowEqual(objA, objB) {
- if (objA === objB) {
- return true;
- }
-
- var keysA = Object.keys(objA);
- var keysB = Object.keys(objB);
-
- if (keysA.length !== keysB.length) {
- return false;
- }
-
- // Test for A's keys different from B.
- var hasOwn = Object.prototype.hasOwnProperty;
- for (var i = 0; i < keysA.length; i++) {
- if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
- return false;
- }
- }
-
- return true;
-}
-},{}],19:[function(require,module,exports){
-'use strict';
-
-exports.__esModule = true;
-
-var _react = require('react');
-
-exports["default"] = _react.PropTypes.shape({
- subscribe: _react.PropTypes.func.isRequired,
- dispatch: _react.PropTypes.func.isRequired,
- getState: _react.PropTypes.func.isRequired
-});
-},{"react":"react"}],20:[function(require,module,exports){
-'use strict';
-
-exports.__esModule = true;
-exports["default"] = warning;
+},{}],44:[function(require,module,exports){
/**
- * Prints a warning in the console if it exists.
+ * Copyright 2013-present, 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.
*
- * @param {String} message The warning message.
- * @returns {void}
*/
-function warning(message) {
- /* eslint-disable no-console */
- if (typeof console !== 'undefined' && typeof console.error === 'function') {
- console.error(message);
- }
- /* eslint-enable no-console */
- try {
- // This error was thrown as a convenience so that you can use this stack
- // to find the callsite that caused this warning to fire.
- throw new Error(message);
- /* eslint-disable no-empty */
- } catch (e) {}
- /* eslint-enable no-empty */
-}
-},{}],21:[function(require,module,exports){
-'use strict';
-exports.__esModule = true;
-exports["default"] = wrapActionCreators;
+'use strict';
-var _redux = require('redux');
+var ARIADOMPropertyConfig = {
+ Properties: {
+ // Global States and Properties
+ 'aria-current': 0, // state
+ 'aria-details': 0,
+ 'aria-disabled': 0, // state
+ 'aria-hidden': 0, // state
+ 'aria-invalid': 0, // state
+ 'aria-keyshortcuts': 0,
+ 'aria-label': 0,
+ 'aria-roledescription': 0,
+ // Widget Attributes
+ 'aria-autocomplete': 0,
+ 'aria-checked': 0,
+ 'aria-expanded': 0,
+ 'aria-haspopup': 0,
+ 'aria-level': 0,
+ 'aria-modal': 0,
+ 'aria-multiline': 0,
+ 'aria-multiselectable': 0,
+ 'aria-orientation': 0,
+ 'aria-placeholder': 0,
+ 'aria-pressed': 0,
+ 'aria-readonly': 0,
+ 'aria-required': 0,
+ 'aria-selected': 0,
+ 'aria-sort': 0,
+ 'aria-valuemax': 0,
+ 'aria-valuemin': 0,
+ 'aria-valuenow': 0,
+ 'aria-valuetext': 0,
+ // Live Region Attributes
+ 'aria-atomic': 0,
+ 'aria-busy': 0,
+ 'aria-live': 0,
+ 'aria-relevant': 0,
+ // Drag-and-Drop Attributes
+ 'aria-dropeffect': 0,
+ 'aria-grabbed': 0,
+ // Relationship Attributes
+ 'aria-activedescendant': 0,
+ 'aria-colcount': 0,
+ 'aria-colindex': 0,
+ 'aria-colspan': 0,
+ 'aria-controls': 0,
+ 'aria-describedby': 0,
+ 'aria-errormessage': 0,
+ 'aria-flowto': 0,
+ 'aria-labelledby': 0,
+ 'aria-owns': 0,
+ 'aria-posinset': 0,
+ 'aria-rowcount': 0,
+ 'aria-rowindex': 0,
+ 'aria-rowspan': 0,
+ 'aria-setsize': 0
+ },
+ DOMAttributeNames: {},
+ DOMPropertyNames: {}
+};
-function wrapActionCreators(actionCreators) {
- return function (dispatch) {
- return (0, _redux.bindActionCreators)(actionCreators, dispatch);
- };
-}
-},{"redux":"redux"}],22:[function(require,module,exports){
+module.exports = ARIADOMPropertyConfig;
+},{}],45:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -11193,7 +12561,6 @@ function wrapActionCreators(actionCreators) {
* 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 AutoFocusUtils
*/
'use strict';
@@ -11209,7 +12576,7 @@ var AutoFocusUtils = {
};
module.exports = AutoFocusUtils;
-},{"./ReactDOMComponentTree":62,"fbjs/lib/focusNode":172}],23:[function(require,module,exports){
+},{"./ReactDOMComponentTree":76,"fbjs/lib/focusNode":12}],46:[function(require,module,exports){
/**
* Copyright 2013-present Facebook, Inc.
* All rights reserved.
@@ -11218,20 +12585,16 @@ module.exports = AutoFocusUtils;
* 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
*/
'use strict';
-var EventConstants = require('./EventConstants');
var EventPropagators = require('./EventPropagators');
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
var FallbackCompositionState = require('./FallbackCompositionState');
var SyntheticCompositionEvent = require('./SyntheticCompositionEvent');
var SyntheticInputEvent = require('./SyntheticInputEvent');
-var keyOf = require('fbjs/lib/keyOf');
-
var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
var START_KEYCODE = 229;
@@ -11264,37 +12627,35 @@ function isPresto() {
var SPACEBAR_CODE = 32;
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
-var topLevelTypes = EventConstants.topLevelTypes;
-
// Events and their corresponding property names.
var eventTypes = {
beforeInput: {
phasedRegistrationNames: {
- bubbled: keyOf({ onBeforeInput: null }),
- captured: keyOf({ onBeforeInputCapture: null })
+ bubbled: 'onBeforeInput',
+ captured: 'onBeforeInputCapture'
},
- dependencies: [topLevelTypes.topCompositionEnd, topLevelTypes.topKeyPress, topLevelTypes.topTextInput, topLevelTypes.topPaste]
+ dependencies: ['topCompositionEnd', 'topKeyPress', 'topTextInput', 'topPaste']
},
compositionEnd: {
phasedRegistrationNames: {
- bubbled: keyOf({ onCompositionEnd: null }),
- captured: keyOf({ onCompositionEndCapture: null })
+ bubbled: 'onCompositionEnd',
+ captured: 'onCompositionEndCapture'
},
- dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionEnd, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
+ dependencies: ['topBlur', 'topCompositionEnd', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown']
},
compositionStart: {
phasedRegistrationNames: {
- bubbled: keyOf({ onCompositionStart: null }),
- captured: keyOf({ onCompositionStartCapture: null })
+ bubbled: 'onCompositionStart',
+ captured: 'onCompositionStartCapture'
},
- dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionStart, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
+ dependencies: ['topBlur', 'topCompositionStart', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown']
},
compositionUpdate: {
phasedRegistrationNames: {
- bubbled: keyOf({ onCompositionUpdate: null }),
- captured: keyOf({ onCompositionUpdateCapture: null })
+ bubbled: 'onCompositionUpdate',
+ captured: 'onCompositionUpdateCapture'
},
- dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionUpdate, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
+ dependencies: ['topBlur', 'topCompositionUpdate', 'topKeyDown', 'topKeyPress', 'topKeyUp', 'topMouseDown']
}
};
@@ -11320,11 +12681,11 @@ function isKeypressCommand(nativeEvent) {
*/
function getCompositionEventType(topLevelType) {
switch (topLevelType) {
- case topLevelTypes.topCompositionStart:
+ case 'topCompositionStart':
return eventTypes.compositionStart;
- case topLevelTypes.topCompositionEnd:
+ case 'topCompositionEnd':
return eventTypes.compositionEnd;
- case topLevelTypes.topCompositionUpdate:
+ case 'topCompositionUpdate':
return eventTypes.compositionUpdate;
}
}
@@ -11338,7 +12699,7 @@ function getCompositionEventType(topLevelType) {
* @return {boolean}
*/
function isFallbackCompositionStart(topLevelType, nativeEvent) {
- return topLevelType === topLevelTypes.topKeyDown && nativeEvent.keyCode === START_KEYCODE;
+ return topLevelType === 'topKeyDown' && nativeEvent.keyCode === START_KEYCODE;
}
/**
@@ -11350,16 +12711,16 @@ function isFallbackCompositionStart(topLevelType, nativeEvent) {
*/
function isFallbackCompositionEnd(topLevelType, nativeEvent) {
switch (topLevelType) {
- case topLevelTypes.topKeyUp:
+ case 'topKeyUp':
// Command keys insert or clear IME input.
return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
- case topLevelTypes.topKeyDown:
+ case 'topKeyDown':
// Expect IME keyCode on each keydown. If we get any other
// code we must have exited earlier.
return nativeEvent.keyCode !== START_KEYCODE;
- case topLevelTypes.topKeyPress:
- case topLevelTypes.topMouseDown:
- case topLevelTypes.topBlur:
+ case 'topKeyPress':
+ case 'topMouseDown':
+ case 'topBlur':
// Events are not possible without cancelling IME.
return true;
default:
@@ -11444,9 +12805,9 @@ function extractCompositionEvent(topLevelType, targetInst, nativeEvent, nativeEv
*/
function getNativeBeforeInputChars(topLevelType, nativeEvent) {
switch (topLevelType) {
- case topLevelTypes.topCompositionEnd:
+ case 'topCompositionEnd':
return getDataFromCustomEvent(nativeEvent);
- case topLevelTypes.topKeyPress:
+ case 'topKeyPress':
/**
* If native `textInput` events are available, our goal is to make
* use of them. However, there is a special case: the spacebar key.
@@ -11469,7 +12830,7 @@ function getNativeBeforeInputChars(topLevelType, nativeEvent) {
hasSpaceKeypress = true;
return SPACEBAR_CHAR;
- case topLevelTypes.topTextInput:
+ case 'topTextInput':
// Record the characters to be added to the DOM.
var chars = nativeEvent.data;
@@ -11499,8 +12860,10 @@ function getNativeBeforeInputChars(topLevelType, nativeEvent) {
function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
// If we are currently composing (IME) and using a fallback to do so,
// try to extract the composed characters from the fallback object.
+ // If composition event is available, we extract a string only at
+ // compositionevent, otherwise extract it at fallback events.
if (currentComposition) {
- if (topLevelType === topLevelTypes.topCompositionEnd || isFallbackCompositionEnd(topLevelType, nativeEvent)) {
+ if (topLevelType === 'topCompositionEnd' || !canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) {
var chars = currentComposition.getData();
FallbackCompositionState.release(currentComposition);
currentComposition = null;
@@ -11510,11 +12873,11 @@ function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
}
switch (topLevelType) {
- case topLevelTypes.topPaste:
+ case 'topPaste':
// If a paste event occurs after a keypress, throw out the input
// chars. Paste events should not lead to BeforeInput events.
return null;
- case topLevelTypes.topKeyPress:
+ case 'topKeyPress':
/**
* As of v27, Firefox may fire keypress events even when no character
* will be inserted. A few possibilities:
@@ -11535,7 +12898,7 @@ function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
return String.fromCharCode(nativeEvent.which);
}
return null;
- case topLevelTypes.topCompositionEnd:
+ case 'topCompositionEnd':
return useFallbackCompositionData ? null : nativeEvent.data;
default:
return null;
@@ -11598,7 +12961,7 @@ var BeforeInputEventPlugin = {
};
module.exports = BeforeInputEventPlugin;
-},{"./EventConstants":37,"./EventPropagators":41,"./FallbackCompositionState":42,"./SyntheticCompositionEvent":119,"./SyntheticInputEvent":123,"fbjs/lib/ExecutionEnvironment":164,"fbjs/lib/keyOf":182}],24:[function(require,module,exports){
+},{"./EventPropagators":62,"./FallbackCompositionState":63,"./SyntheticCompositionEvent":127,"./SyntheticInputEvent":131,"fbjs/lib/ExecutionEnvironment":4}],47:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -11607,7 +12970,6 @@ module.exports = BeforeInputEventPlugin;
* 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
*/
'use strict';
@@ -11747,7 +13109,7 @@ var CSSProperty = {
};
module.exports = CSSProperty;
-},{}],25:[function(require,module,exports){
+},{}],48:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -11757,7 +13119,6 @@ module.exports = CSSProperty;
* 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
*/
'use strict';
@@ -11919,7 +13280,11 @@ var CSSPropertyOperations = {
*/
setValueForStyles: function (node, styles, component) {
if (process.env.NODE_ENV !== 'production') {
- ReactInstrumentation.debugTool.onHostOperation(component._debugID, 'update styles', styles);
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: component._debugID,
+ type: 'update styles',
+ payload: styles
+ });
}
var style = node.style;
@@ -11956,7 +13321,7 @@ var CSSPropertyOperations = {
module.exports = CSSPropertyOperations;
}).call(this,require('_process'))
-},{"./CSSProperty":24,"./ReactInstrumentation":94,"./dangerousStyleValue":137,"_process":15,"fbjs/lib/ExecutionEnvironment":164,"fbjs/lib/camelizeStyleName":166,"fbjs/lib/hyphenateStyleName":177,"fbjs/lib/memoizeStringOnly":184,"fbjs/lib/warning":188}],26:[function(require,module,exports){
+},{"./CSSProperty":47,"./ReactInstrumentation":105,"./dangerousStyleValue":144,"_process":43,"fbjs/lib/ExecutionEnvironment":4,"fbjs/lib/camelizeStyleName":6,"fbjs/lib/hyphenateStyleName":17,"fbjs/lib/memoizeStringOnly":21,"fbjs/lib/warning":25}],49:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -11966,13 +13331,14 @@ module.exports = CSSPropertyOperations;
* 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
+ *
*/
'use strict';
-var _prodInvariant = require('./reactProdInvariant'),
- _assign = require('object-assign');
+var _prodInvariant = require('./reactProdInvariant');
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var PooledClass = require('./PooledClass');
@@ -11989,12 +13355,15 @@ var invariant = require('fbjs/lib/invariant');
* @implements PooledClass
* @internal
*/
-function CallbackQueue() {
- this._callbacks = null;
- this._contexts = null;
-}
-_assign(CallbackQueue.prototype, {
+var CallbackQueue = function () {
+ function CallbackQueue(arg) {
+ _classCallCheck(this, CallbackQueue);
+
+ this._callbacks = null;
+ this._contexts = null;
+ this._arg = arg;
+ }
/**
* Enqueues a callback to be invoked when `notifyAll` is invoked.
@@ -12003,12 +13372,14 @@ _assign(CallbackQueue.prototype, {
* @param {?object} context Context to call `callback` with.
* @internal
*/
- enqueue: function (callback, context) {
+
+
+ CallbackQueue.prototype.enqueue = function enqueue(callback, context) {
this._callbacks = this._callbacks || [];
- this._contexts = this._contexts || [];
this._callbacks.push(callback);
+ this._contexts = this._contexts || [];
this._contexts.push(context);
- },
+ };
/**
* Invokes all enqueued callbacks and clears the queue. This is invoked after
@@ -12016,57 +13387,63 @@ _assign(CallbackQueue.prototype, {
*
* @internal
*/
- notifyAll: function () {
+
+
+ CallbackQueue.prototype.notifyAll = function notifyAll() {
var callbacks = this._callbacks;
var contexts = this._contexts;
- if (callbacks) {
+ var arg = this._arg;
+ if (callbacks && contexts) {
!(callbacks.length === contexts.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Mismatched list of contexts in callback queue') : _prodInvariant('24') : void 0;
this._callbacks = null;
this._contexts = null;
for (var i = 0; i < callbacks.length; i++) {
- callbacks[i].call(contexts[i]);
+ callbacks[i].call(contexts[i], arg);
}
callbacks.length = 0;
contexts.length = 0;
}
- },
+ };
- checkpoint: function () {
+ CallbackQueue.prototype.checkpoint = function checkpoint() {
return this._callbacks ? this._callbacks.length : 0;
- },
+ };
- rollback: function (len) {
- if (this._callbacks) {
+ CallbackQueue.prototype.rollback = function rollback(len) {
+ if (this._callbacks && this._contexts) {
this._callbacks.length = len;
this._contexts.length = len;
}
- },
+ };
/**
* Resets the internal queue.
*
* @internal
*/
- reset: function () {
+
+
+ CallbackQueue.prototype.reset = function reset() {
this._callbacks = null;
this._contexts = null;
- },
+ };
/**
* `PooledClass` looks for this.
*/
- destructor: function () {
- this.reset();
- }
-});
-PooledClass.addPoolingTo(CallbackQueue);
+ CallbackQueue.prototype.destructor = function destructor() {
+ this.reset();
+ };
+
+ return CallbackQueue;
+}();
-module.exports = CallbackQueue;
+module.exports = PooledClass.addPoolingTo(CallbackQueue);
}).call(this,require('_process'))
-},{"./PooledClass":46,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"object-assign":14}],27:[function(require,module,exports){
+},{"./PooledClass":67,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],50:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -12075,12 +13452,10 @@ module.exports = CallbackQueue;
* 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
*/
'use strict';
-var EventConstants = require('./EventConstants');
var EventPluginHub = require('./EventPluginHub');
var EventPropagators = require('./EventPropagators');
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
@@ -12091,17 +13466,14 @@ var SyntheticEvent = require('./SyntheticEvent');
var getEventTarget = require('./getEventTarget');
var isEventSupported = require('./isEventSupported');
var isTextInputElement = require('./isTextInputElement');
-var keyOf = require('fbjs/lib/keyOf');
-
-var topLevelTypes = EventConstants.topLevelTypes;
var eventTypes = {
change: {
phasedRegistrationNames: {
- bubbled: keyOf({ onChange: null }),
- captured: keyOf({ onChangeCapture: null })
+ bubbled: 'onChange',
+ captured: 'onChangeCapture'
},
- dependencies: [topLevelTypes.topBlur, topLevelTypes.topChange, topLevelTypes.topClick, topLevelTypes.topFocus, topLevelTypes.topInput, topLevelTypes.topKeyDown, topLevelTypes.topKeyUp, topLevelTypes.topSelectionChange]
+ dependencies: ['topBlur', 'topChange', 'topClick', 'topFocus', 'topInput', 'topKeyDown', 'topKeyUp', 'topSelectionChange']
}
};
@@ -12124,7 +13496,7 @@ function shouldUseChangeEvent(elem) {
var doesChangeEventBubble = false;
if (ExecutionEnvironment.canUseDOM) {
// See `handleChange` comment below
- doesChangeEventBubble = isEventSupported('change') && (!('documentMode' in document) || document.documentMode > 8);
+ doesChangeEventBubble = isEventSupported('change') && (!document.documentMode || document.documentMode > 8);
}
function manualDispatchChangeEvent(nativeEvent) {
@@ -12166,17 +13538,17 @@ function stopWatchingForChangeEventIE8() {
}
function getTargetInstForChangeEvent(topLevelType, targetInst) {
- if (topLevelType === topLevelTypes.topChange) {
+ if (topLevelType === 'topChange') {
return targetInst;
}
}
function handleEventsForChangeEventIE8(topLevelType, target, targetInst) {
- if (topLevelType === topLevelTypes.topFocus) {
+ if (topLevelType === 'topFocus') {
// stopWatching() should be a noop here but we call it just in case we
// missed a blur event somehow.
stopWatchingForChangeEventIE8();
startWatchingForChangeEventIE8(target, targetInst);
- } else if (topLevelType === topLevelTypes.topBlur) {
+ } else if (topLevelType === 'topBlur') {
stopWatchingForChangeEventIE8();
}
}
@@ -12190,7 +13562,7 @@ if (ExecutionEnvironment.canUseDOM) {
// deleting text, so we ignore its input events.
// IE10+ fire input events to often, such when a placeholder
// changes or when an input with a placeholder is focused.
- isInputEventSupported = isEventSupported('input') && (!('documentMode' in document) || document.documentMode > 11);
+ isInputEventSupported = isEventSupported('input') && (!document.documentMode || document.documentMode > 11);
}
/**
@@ -12274,7 +13646,7 @@ function handlePropertyChange(nativeEvent) {
* If a `change` event should be fired, returns the target's ID.
*/
function getTargetInstForInputEvent(topLevelType, targetInst) {
- if (topLevelType === topLevelTypes.topInput) {
+ if (topLevelType === 'topInput') {
// In modern browsers (i.e., not IE8 or IE9), the input event is exactly
// what we want so fall through here and trigger an abstract event
return targetInst;
@@ -12282,7 +13654,7 @@ function getTargetInstForInputEvent(topLevelType, targetInst) {
}
function handleEventsForInputEventIE(topLevelType, target, targetInst) {
- if (topLevelType === topLevelTypes.topFocus) {
+ if (topLevelType === 'topFocus') {
// In IE8, we can capture almost all .value changes by adding a
// propertychange handler and looking for events with propertyName
// equal to 'value'
@@ -12298,14 +13670,14 @@ function handleEventsForInputEventIE(topLevelType, target, targetInst) {
// missed a blur event somehow.
stopWatchingForValueChange();
startWatchingForValueChange(target, targetInst);
- } else if (topLevelType === topLevelTypes.topBlur) {
+ } else if (topLevelType === 'topBlur') {
stopWatchingForValueChange();
}
}
// For IE8 and IE9.
function getTargetInstForInputEventIE(topLevelType, targetInst) {
- if (topLevelType === topLevelTypes.topSelectionChange || topLevelType === topLevelTypes.topKeyUp || topLevelType === topLevelTypes.topKeyDown) {
+ if (topLevelType === 'topSelectionChange' || topLevelType === 'topKeyUp' || topLevelType === 'topKeyDown') {
// On the selectionchange event, the target is just document which isn't
// helpful for us so just check activeElement instead.
//
@@ -12334,7 +13706,7 @@ function shouldUseClickEvent(elem) {
}
function getTargetInstForClickEvent(topLevelType, targetInst) {
- if (topLevelType === topLevelTypes.topClick) {
+ if (topLevelType === 'topClick') {
return targetInst;
}
}
@@ -12392,7 +13764,7 @@ var ChangeEventPlugin = {
};
module.exports = ChangeEventPlugin;
-},{"./EventConstants":37,"./EventPluginHub":38,"./EventPropagators":41,"./ReactDOMComponentTree":62,"./ReactUpdates":112,"./SyntheticEvent":121,"./getEventTarget":145,"./isEventSupported":152,"./isTextInputElement":153,"fbjs/lib/ExecutionEnvironment":164,"fbjs/lib/keyOf":182}],28:[function(require,module,exports){
+},{"./EventPluginHub":59,"./EventPropagators":62,"./ReactDOMComponentTree":76,"./ReactUpdates":120,"./SyntheticEvent":129,"./getEventTarget":152,"./isEventSupported":160,"./isTextInputElement":161,"fbjs/lib/ExecutionEnvironment":4}],51:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -12402,14 +13774,12 @@ module.exports = ChangeEventPlugin;
* 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
*/
'use strict';
var DOMLazyTree = require('./DOMLazyTree');
var Danger = require('./Danger');
-var ReactMultiChildUpdateTypes = require('./ReactMultiChildUpdateTypes');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
var ReactInstrumentation = require('./ReactInstrumentation');
@@ -12508,7 +13878,11 @@ function replaceDelimitedText(openingComment, closingComment, stringText) {
}
if (process.env.NODE_ENV !== 'production') {
- ReactInstrumentation.debugTool.onHostOperation(ReactDOMComponentTree.getInstanceFromNode(openingComment)._debugID, 'replace text', stringText);
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: ReactDOMComponentTree.getInstanceFromNode(openingComment)._debugID,
+ type: 'replace text',
+ payload: stringText
+ });
}
}
@@ -12517,11 +13891,19 @@ if (process.env.NODE_ENV !== 'production') {
dangerouslyReplaceNodeWithMarkup = function (oldChild, markup, prevInstance) {
Danger.dangerouslyReplaceNodeWithMarkup(oldChild, markup);
if (prevInstance._debugID !== 0) {
- ReactInstrumentation.debugTool.onHostOperation(prevInstance._debugID, 'replace with', markup.toString());
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: prevInstance._debugID,
+ type: 'replace with',
+ payload: markup.toString()
+ });
} else {
var nextInstance = ReactDOMComponentTree.getInstanceFromNode(markup.node);
if (nextInstance._debugID !== 0) {
- ReactInstrumentation.debugTool.onHostOperation(nextInstance._debugID, 'mount', markup.toString());
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: nextInstance._debugID,
+ type: 'mount',
+ payload: markup.toString()
+ });
}
}
};
@@ -12551,34 +13933,54 @@ var DOMChildrenOperations = {
for (var k = 0; k < updates.length; k++) {
var update = updates[k];
switch (update.type) {
- case ReactMultiChildUpdateTypes.INSERT_MARKUP:
+ case 'INSERT_MARKUP':
insertLazyTreeChildAt(parentNode, update.content, getNodeAfter(parentNode, update.afterNode));
if (process.env.NODE_ENV !== 'production') {
- ReactInstrumentation.debugTool.onHostOperation(parentNodeDebugID, 'insert child', { toIndex: update.toIndex, content: update.content.toString() });
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: parentNodeDebugID,
+ type: 'insert child',
+ payload: { toIndex: update.toIndex, content: update.content.toString() }
+ });
}
break;
- case ReactMultiChildUpdateTypes.MOVE_EXISTING:
+ case 'MOVE_EXISTING':
moveChild(parentNode, update.fromNode, getNodeAfter(parentNode, update.afterNode));
if (process.env.NODE_ENV !== 'production') {
- ReactInstrumentation.debugTool.onHostOperation(parentNodeDebugID, 'move child', { fromIndex: update.fromIndex, toIndex: update.toIndex });
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: parentNodeDebugID,
+ type: 'move child',
+ payload: { fromIndex: update.fromIndex, toIndex: update.toIndex }
+ });
}
break;
- case ReactMultiChildUpdateTypes.SET_MARKUP:
+ case 'SET_MARKUP':
setInnerHTML(parentNode, update.content);
if (process.env.NODE_ENV !== 'production') {
- ReactInstrumentation.debugTool.onHostOperation(parentNodeDebugID, 'replace children', update.content.toString());
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: parentNodeDebugID,
+ type: 'replace children',
+ payload: update.content.toString()
+ });
}
break;
- case ReactMultiChildUpdateTypes.TEXT_CONTENT:
+ case 'TEXT_CONTENT':
setTextContent(parentNode, update.content);
if (process.env.NODE_ENV !== 'production') {
- ReactInstrumentation.debugTool.onHostOperation(parentNodeDebugID, 'replace text', update.content.toString());
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: parentNodeDebugID,
+ type: 'replace text',
+ payload: update.content.toString()
+ });
}
break;
- case ReactMultiChildUpdateTypes.REMOVE_NODE:
+ case 'REMOVE_NODE':
removeChild(parentNode, update.fromNode);
if (process.env.NODE_ENV !== 'production') {
- ReactInstrumentation.debugTool.onHostOperation(parentNodeDebugID, 'remove child', { fromIndex: update.fromIndex });
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: parentNodeDebugID,
+ type: 'remove child',
+ payload: { fromIndex: update.fromIndex }
+ });
}
break;
}
@@ -12590,7 +13992,7 @@ var DOMChildrenOperations = {
module.exports = DOMChildrenOperations;
}).call(this,require('_process'))
-},{"./DOMLazyTree":29,"./Danger":33,"./ReactDOMComponentTree":62,"./ReactInstrumentation":94,"./ReactMultiChildUpdateTypes":99,"./createMicrosoftUnsafeLocalFunction":136,"./setInnerHTML":158,"./setTextContent":159,"_process":15}],29:[function(require,module,exports){
+},{"./DOMLazyTree":52,"./Danger":56,"./ReactDOMComponentTree":76,"./ReactInstrumentation":105,"./createMicrosoftUnsafeLocalFunction":143,"./setInnerHTML":165,"./setTextContent":166,"_process":43}],52:[function(require,module,exports){
/**
* Copyright 2015-present, Facebook, Inc.
* All rights reserved.
@@ -12599,7 +14001,6 @@ module.exports = DOMChildrenOperations;
* 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 DOMLazyTree
*/
'use strict';
@@ -12709,7 +14110,7 @@ DOMLazyTree.queueHTML = queueHTML;
DOMLazyTree.queueText = queueText;
module.exports = DOMLazyTree;
-},{"./DOMNamespaces":30,"./createMicrosoftUnsafeLocalFunction":136,"./setInnerHTML":158,"./setTextContent":159}],30:[function(require,module,exports){
+},{"./DOMNamespaces":53,"./createMicrosoftUnsafeLocalFunction":143,"./setInnerHTML":165,"./setTextContent":166}],53:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -12718,7 +14119,6 @@ module.exports = DOMLazyTree;
* 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 DOMNamespaces
*/
'use strict';
@@ -12730,7 +14130,7 @@ var DOMNamespaces = {
};
module.exports = DOMNamespaces;
-},{}],31:[function(require,module,exports){
+},{}],54:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -12740,7 +14140,6 @@ module.exports = DOMNamespaces;
* 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
*/
'use strict';
@@ -12911,9 +14310,13 @@ var DOMProperty = {
/**
* Mapping from lowercase property names to the properly cased version, used
* to warn in the case of missing properties. Available only in __DEV__.
+ *
+ * autofocus is predefined, because adding it to the property whitelist
+ * causes unintended side effects.
+ *
* @type {Object}
*/
- getPossibleStandardName: process.env.NODE_ENV !== 'production' ? {} : null,
+ getPossibleStandardName: process.env.NODE_ENV !== 'production' ? { autofocus: 'autoFocus' } : null,
/**
* All of the isCustomAttribute() functions that have been injected.
@@ -12940,7 +14343,7 @@ var DOMProperty = {
module.exports = DOMProperty;
}).call(this,require('_process'))
-},{"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],32:[function(require,module,exports){
+},{"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],55:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -12950,14 +14353,12 @@ module.exports = DOMProperty;
* 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
*/
'use strict';
var DOMProperty = require('./DOMProperty');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
-var ReactDOMInstrumentation = require('./ReactDOMInstrumentation');
var ReactInstrumentation = require('./ReactInstrumentation');
var quoteAttributeValueForBrowser = require('./quoteAttributeValueForBrowser');
@@ -13022,9 +14423,6 @@ var DOMPropertyOperations = {
* @return {?string} Markup string, or null if the property was invalid.
*/
createMarkupForProperty: function (name, value) {
- if (process.env.NODE_ENV !== 'production') {
- ReactDOMInstrumentation.debugTool.onCreateMarkupForProperty(name, value);
- }
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
if (propertyInfo) {
if (shouldIgnoreValue(propertyInfo, value)) {
@@ -13097,10 +14495,13 @@ var DOMPropertyOperations = {
}
if (process.env.NODE_ENV !== 'production') {
- ReactDOMInstrumentation.debugTool.onSetValueForProperty(node, name, value);
var payload = {};
payload[name] = value;
- ReactInstrumentation.debugTool.onHostOperation(ReactDOMComponentTree.getInstanceFromNode(node)._debugID, 'update attribute', payload);
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
+ type: 'update attribute',
+ payload: payload
+ });
}
},
@@ -13117,7 +14518,11 @@ var DOMPropertyOperations = {
if (process.env.NODE_ENV !== 'production') {
var payload = {};
payload[name] = value;
- ReactInstrumentation.debugTool.onHostOperation(ReactDOMComponentTree.getInstanceFromNode(node)._debugID, 'update attribute', payload);
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
+ type: 'update attribute',
+ payload: payload
+ });
}
},
@@ -13130,8 +14535,11 @@ var DOMPropertyOperations = {
deleteValueForAttribute: function (node, name) {
node.removeAttribute(name);
if (process.env.NODE_ENV !== 'production') {
- ReactDOMInstrumentation.debugTool.onDeleteValueForProperty(node, name);
- ReactInstrumentation.debugTool.onHostOperation(ReactDOMComponentTree.getInstanceFromNode(node)._debugID, 'remove attribute', name);
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
+ type: 'remove attribute',
+ payload: name
+ });
}
},
@@ -13162,8 +14570,11 @@ var DOMPropertyOperations = {
}
if (process.env.NODE_ENV !== 'production') {
- ReactDOMInstrumentation.debugTool.onDeleteValueForProperty(node, name);
- ReactInstrumentation.debugTool.onHostOperation(ReactDOMComponentTree.getInstanceFromNode(node)._debugID, 'remove attribute', name);
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: ReactDOMComponentTree.getInstanceFromNode(node)._debugID,
+ type: 'remove attribute',
+ payload: name
+ });
}
}
@@ -13172,7 +14583,7 @@ var DOMPropertyOperations = {
module.exports = DOMPropertyOperations;
}).call(this,require('_process'))
-},{"./DOMProperty":31,"./ReactDOMComponentTree":62,"./ReactDOMInstrumentation":70,"./ReactInstrumentation":94,"./quoteAttributeValueForBrowser":155,"_process":15,"fbjs/lib/warning":188}],33:[function(require,module,exports){
+},{"./DOMProperty":54,"./ReactDOMComponentTree":76,"./ReactInstrumentation":105,"./quoteAttributeValueForBrowser":162,"_process":43,"fbjs/lib/warning":25}],56:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -13182,7 +14593,6 @@ module.exports = DOMPropertyOperations;
* 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
*/
'use strict';
@@ -13224,7 +14634,7 @@ var Danger = {
module.exports = Danger;
}).call(this,require('_process'))
-},{"./DOMLazyTree":29,"./reactProdInvariant":156,"_process":15,"fbjs/lib/ExecutionEnvironment":164,"fbjs/lib/createNodesFromMarkup":169,"fbjs/lib/emptyFunction":170,"fbjs/lib/invariant":178}],34:[function(require,module,exports){
+},{"./DOMLazyTree":52,"./reactProdInvariant":163,"_process":43,"fbjs/lib/ExecutionEnvironment":4,"fbjs/lib/createNodesFromMarkup":9,"fbjs/lib/emptyFunction":10,"fbjs/lib/invariant":18}],57:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -13233,13 +14643,10 @@ module.exports = Danger;
* 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
*/
'use strict';
-var keyOf = require('fbjs/lib/keyOf');
-
/**
* Module that is injectable into `EventPluginHub`, that specifies a
* deterministic ordering of `EventPlugin`s. A convenient way to reason about
@@ -13249,61 +14656,11 @@ var keyOf = require('fbjs/lib/keyOf');
* `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
* preventing default on events is convenient in `SimpleEventPlugin` handlers.
*/
-var DefaultEventPluginOrder = [keyOf({ ResponderEventPlugin: null }), keyOf({ SimpleEventPlugin: null }), keyOf({ TapEventPlugin: null }), keyOf({ EnterLeaveEventPlugin: null }), keyOf({ ChangeEventPlugin: null }), keyOf({ SelectEventPlugin: null }), keyOf({ BeforeInputEventPlugin: null })];
-module.exports = DefaultEventPluginOrder;
-},{"fbjs/lib/keyOf":182}],35:[function(require,module,exports){
-/**
- * Copyright 2013-present, 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 DisabledInputUtils
- */
-
-'use strict';
-
-var disableableMouseListenerNames = {
- onClick: true,
- onDoubleClick: true,
- onMouseDown: true,
- onMouseMove: true,
- onMouseUp: true,
-
- onClickCapture: true,
- onDoubleClickCapture: true,
- onMouseDownCapture: true,
- onMouseMoveCapture: true,
- onMouseUpCapture: true
-};
+var DefaultEventPluginOrder = ['ResponderEventPlugin', 'SimpleEventPlugin', 'TapEventPlugin', 'EnterLeaveEventPlugin', 'ChangeEventPlugin', 'SelectEventPlugin', 'BeforeInputEventPlugin'];
-/**
- * Implements a host component that does not receive mouse events
- * when `disabled` is set.
- */
-var DisabledInputUtils = {
- getHostProps: function (inst, props) {
- if (!props.disabled) {
- return props;
- }
-
- // Copy the props, except the mouse listeners
- var hostProps = {};
- for (var key in props) {
- if (!disableableMouseListenerNames[key] && props.hasOwnProperty(key)) {
- hostProps[key] = props[key];
- }
- }
-
- return hostProps;
- }
-};
-
-module.exports = DisabledInputUtils;
-},{}],36:[function(require,module,exports){
+module.exports = DefaultEventPluginOrder;
+},{}],58:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -13312,28 +14669,22 @@ module.exports = DisabledInputUtils;
* 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
*/
'use strict';
-var EventConstants = require('./EventConstants');
var EventPropagators = require('./EventPropagators');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
var SyntheticMouseEvent = require('./SyntheticMouseEvent');
-var keyOf = require('fbjs/lib/keyOf');
-
-var topLevelTypes = EventConstants.topLevelTypes;
-
var eventTypes = {
mouseEnter: {
- registrationName: keyOf({ onMouseEnter: null }),
- dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
+ registrationName: 'onMouseEnter',
+ dependencies: ['topMouseOut', 'topMouseOver']
},
mouseLeave: {
- registrationName: keyOf({ onMouseLeave: null }),
- dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
+ registrationName: 'onMouseLeave',
+ dependencies: ['topMouseOut', 'topMouseOver']
}
};
@@ -13349,10 +14700,10 @@ var EnterLeaveEventPlugin = {
* the `mouseover` top-level event.
*/
extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
- if (topLevelType === topLevelTypes.topMouseOver && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
+ if (topLevelType === 'topMouseOver' && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
return null;
}
- if (topLevelType !== topLevelTypes.topMouseOut && topLevelType !== topLevelTypes.topMouseOver) {
+ if (topLevelType !== 'topMouseOut' && topLevelType !== 'topMouseOver') {
// Must not be a mouse in or mouse out - ignoring.
return null;
}
@@ -13373,7 +14724,7 @@ var EnterLeaveEventPlugin = {
var from;
var to;
- if (topLevelType === topLevelTypes.topMouseOut) {
+ if (topLevelType === 'topMouseOut') {
from = targetInst;
var related = nativeEvent.relatedTarget || nativeEvent.toElement;
to = related ? ReactDOMComponentTree.getClosestInstanceFromNode(related) : null;
@@ -13409,105 +14760,7 @@ var EnterLeaveEventPlugin = {
};
module.exports = EnterLeaveEventPlugin;
-},{"./EventConstants":37,"./EventPropagators":41,"./ReactDOMComponentTree":62,"./SyntheticMouseEvent":125,"fbjs/lib/keyOf":182}],37:[function(require,module,exports){
-/**
- * Copyright 2013-present, 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 EventConstants
- */
-
-'use strict';
-
-var keyMirror = require('fbjs/lib/keyMirror');
-
-var PropagationPhases = keyMirror({ bubbled: null, captured: null });
-
-/**
- * Types of raw signals from the browser caught at the top level.
- */
-var topLevelTypes = keyMirror({
- topAbort: null,
- topAnimationEnd: null,
- topAnimationIteration: null,
- topAnimationStart: null,
- topBlur: null,
- topCanPlay: null,
- topCanPlayThrough: null,
- topChange: null,
- topClick: null,
- topCompositionEnd: null,
- topCompositionStart: null,
- topCompositionUpdate: null,
- topContextMenu: null,
- topCopy: null,
- topCut: null,
- topDoubleClick: null,
- topDrag: null,
- topDragEnd: null,
- topDragEnter: null,
- topDragExit: null,
- topDragLeave: null,
- topDragOver: null,
- topDragStart: null,
- topDrop: null,
- topDurationChange: null,
- topEmptied: null,
- topEncrypted: null,
- topEnded: null,
- topError: null,
- topFocus: null,
- topInput: null,
- topInvalid: null,
- topKeyDown: null,
- topKeyPress: null,
- topKeyUp: null,
- topLoad: null,
- topLoadedData: null,
- topLoadedMetadata: null,
- topLoadStart: null,
- topMouseDown: null,
- topMouseMove: null,
- topMouseOut: null,
- topMouseOver: null,
- topMouseUp: null,
- topPaste: null,
- topPause: null,
- topPlay: null,
- topPlaying: null,
- topProgress: null,
- topRateChange: null,
- topReset: null,
- topScroll: null,
- topSeeked: null,
- topSeeking: null,
- topSelectionChange: null,
- topStalled: null,
- topSubmit: null,
- topSuspend: null,
- topTextInput: null,
- topTimeUpdate: null,
- topTouchCancel: null,
- topTouchEnd: null,
- topTouchMove: null,
- topTouchStart: null,
- topTransitionEnd: null,
- topVolumeChange: null,
- topWaiting: null,
- topWheel: null
-});
-
-var EventConstants = {
- topLevelTypes: topLevelTypes,
- PropagationPhases: PropagationPhases
-};
-
-module.exports = EventConstants;
-},{"fbjs/lib/keyMirror":181}],38:[function(require,module,exports){
+},{"./EventPropagators":62,"./ReactDOMComponentTree":76,"./SyntheticMouseEvent":133}],59:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -13517,7 +14770,6 @@ module.exports = EventConstants;
* 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
*/
'use strict';
@@ -13566,6 +14818,34 @@ var executeDispatchesAndReleaseTopLevel = function (e) {
return executeDispatchesAndRelease(e, false);
};
+var getDictionaryKey = function (inst) {
+ // Prevents V8 performance issue:
+ // https://github.com/facebook/react/pull/7232
+ return '.' + inst._rootNodeID;
+};
+
+function isInteractive(tag) {
+ return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
+}
+
+function shouldPreventMouseEvent(name, type, props) {
+ switch (name) {
+ case 'onClick':
+ case 'onClickCapture':
+ case 'onDoubleClick':
+ case 'onDoubleClickCapture':
+ case 'onMouseDown':
+ case 'onMouseDownCapture':
+ case 'onMouseMove':
+ case 'onMouseMoveCapture':
+ case 'onMouseUp':
+ case 'onMouseUpCapture':
+ return !!(props.disabled && isInteractive(type));
+ default:
+ return false;
+ }
+}
+
/**
* This is a unified interface for event plugins to be installed and configured.
*
@@ -13609,7 +14889,7 @@ var EventPluginHub = {
},
/**
- * Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
+ * Stores `listener` at `listenerBank[registrationName][key]`. Is idempotent.
*
* @param {object} inst The instance, which is the source of events.
* @param {string} registrationName Name of listener (e.g. `onClick`).
@@ -13618,8 +14898,9 @@ var EventPluginHub = {
putListener: function (inst, registrationName, listener) {
!(typeof listener === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener) : _prodInvariant('94', registrationName, typeof listener) : void 0;
+ var key = getDictionaryKey(inst);
var bankForRegistrationName = listenerBank[registrationName] || (listenerBank[registrationName] = {});
- bankForRegistrationName[inst._rootNodeID] = listener;
+ bankForRegistrationName[key] = listener;
var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
if (PluginModule && PluginModule.didPutListener) {
@@ -13633,8 +14914,14 @@ var EventPluginHub = {
* @return {?function} The stored callback.
*/
getListener: function (inst, registrationName) {
+ // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not
+ // live here; needs to be moved to a better place soon
var bankForRegistrationName = listenerBank[registrationName];
- return bankForRegistrationName && bankForRegistrationName[inst._rootNodeID];
+ if (shouldPreventMouseEvent(registrationName, inst._currentElement.type, inst._currentElement.props)) {
+ return null;
+ }
+ var key = getDictionaryKey(inst);
+ return bankForRegistrationName && bankForRegistrationName[key];
},
/**
@@ -13652,7 +14939,8 @@ var EventPluginHub = {
var bankForRegistrationName = listenerBank[registrationName];
// TODO: This should never be null -- when is it?
if (bankForRegistrationName) {
- delete bankForRegistrationName[inst._rootNodeID];
+ var key = getDictionaryKey(inst);
+ delete bankForRegistrationName[key];
}
},
@@ -13662,12 +14950,13 @@ var EventPluginHub = {
* @param {object} inst The instance, which is the source of events.
*/
deleteAllListeners: function (inst) {
+ var key = getDictionaryKey(inst);
for (var registrationName in listenerBank) {
if (!listenerBank.hasOwnProperty(registrationName)) {
continue;
}
- if (!listenerBank[registrationName][inst._rootNodeID]) {
+ if (!listenerBank[registrationName][key]) {
continue;
}
@@ -13676,7 +14965,7 @@ var EventPluginHub = {
PluginModule.willDeleteListener(inst, registrationName);
}
- delete listenerBank[registrationName][inst._rootNodeID];
+ delete listenerBank[registrationName][key];
}
},
@@ -13752,7 +15041,7 @@ var EventPluginHub = {
module.exports = EventPluginHub;
}).call(this,require('_process'))
-},{"./EventPluginRegistry":39,"./EventPluginUtils":40,"./ReactErrorUtils":85,"./accumulateInto":132,"./forEachAccumulated":141,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],39:[function(require,module,exports){
+},{"./EventPluginRegistry":60,"./EventPluginUtils":61,"./ReactErrorUtils":96,"./accumulateInto":140,"./forEachAccumulated":148,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],60:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -13762,7 +15051,7 @@ module.exports = EventPluginHub;
* 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
+ *
*/
'use strict';
@@ -13774,7 +15063,7 @@ var invariant = require('fbjs/lib/invariant');
/**
* Injectable ordering of event plugins.
*/
-var EventPluginOrder = null;
+var eventPluginOrder = null;
/**
* Injectable mapping from names to event plugin modules.
@@ -13787,22 +15076,22 @@ var namesToPlugins = {};
* @private
*/
function recomputePluginOrdering() {
- if (!EventPluginOrder) {
- // Wait until an `EventPluginOrder` is injected.
+ if (!eventPluginOrder) {
+ // Wait until an `eventPluginOrder` is injected.
return;
}
for (var pluginName in namesToPlugins) {
- var PluginModule = namesToPlugins[pluginName];
- var pluginIndex = EventPluginOrder.indexOf(pluginName);
+ var pluginModule = namesToPlugins[pluginName];
+ var pluginIndex = eventPluginOrder.indexOf(pluginName);
!(pluginIndex > -1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.', pluginName) : _prodInvariant('96', pluginName) : void 0;
if (EventPluginRegistry.plugins[pluginIndex]) {
continue;
}
- !PluginModule.extractEvents ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.', pluginName) : _prodInvariant('97', pluginName) : void 0;
- EventPluginRegistry.plugins[pluginIndex] = PluginModule;
- var publishedEvents = PluginModule.eventTypes;
+ !pluginModule.extractEvents ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.', pluginName) : _prodInvariant('97', pluginName) : void 0;
+ EventPluginRegistry.plugins[pluginIndex] = pluginModule;
+ var publishedEvents = pluginModule.eventTypes;
for (var eventName in publishedEvents) {
- !publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : _prodInvariant('98', eventName, pluginName) : void 0;
+ !publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : _prodInvariant('98', eventName, pluginName) : void 0;
}
}
}
@@ -13815,7 +15104,7 @@ function recomputePluginOrdering() {
* @return {boolean} True if the event was successfully published.
* @private
*/
-function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
+function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
!!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.', eventName) : _prodInvariant('99', eventName) : void 0;
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
@@ -13824,12 +15113,12 @@ function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
for (var phaseName in phasedRegistrationNames) {
if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
var phasedRegistrationName = phasedRegistrationNames[phaseName];
- publishRegistrationName(phasedRegistrationName, PluginModule, eventName);
+ publishRegistrationName(phasedRegistrationName, pluginModule, eventName);
}
}
return true;
} else if (dispatchConfig.registrationName) {
- publishRegistrationName(dispatchConfig.registrationName, PluginModule, eventName);
+ publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName);
return true;
}
return false;
@@ -13843,10 +15132,10 @@ function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
* @param {object} PluginModule Plugin publishing the event.
* @private
*/
-function publishRegistrationName(registrationName, PluginModule, eventName) {
+function publishRegistrationName(registrationName, pluginModule, eventName) {
!!EventPluginRegistry.registrationNameModules[registrationName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.', registrationName) : _prodInvariant('100', registrationName) : void 0;
- EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
- EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies;
+ EventPluginRegistry.registrationNameModules[registrationName] = pluginModule;
+ EventPluginRegistry.registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
if (process.env.NODE_ENV !== 'production') {
var lowerCasedName = registrationName.toLowerCase();
@@ -13892,6 +15181,7 @@ var EventPluginRegistry = {
* @type {Object}
*/
possibleRegistrationNames: process.env.NODE_ENV !== 'production' ? {} : null,
+ // Trust the developer to only use possibleRegistrationNames in __DEV__
/**
* Injects an ordering of plugins (by plugin name). This allows the ordering
@@ -13902,10 +15192,10 @@ var EventPluginRegistry = {
* @internal
* @see {EventPluginHub.injection.injectEventPluginOrder}
*/
- injectEventPluginOrder: function (InjectedEventPluginOrder) {
- !!EventPluginOrder ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.') : _prodInvariant('101') : void 0;
+ injectEventPluginOrder: function (injectedEventPluginOrder) {
+ !!eventPluginOrder ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React.') : _prodInvariant('101') : void 0;
// Clone the ordering so it cannot be dynamically mutated.
- EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
+ eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder);
recomputePluginOrdering();
},
@@ -13925,10 +15215,10 @@ var EventPluginRegistry = {
if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
continue;
}
- var PluginModule = injectedNamesToPlugins[pluginName];
- if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== PluginModule) {
+ var pluginModule = injectedNamesToPlugins[pluginName];
+ if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule) {
!!namesToPlugins[pluginName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.', pluginName) : _prodInvariant('102', pluginName) : void 0;
- namesToPlugins[pluginName] = PluginModule;
+ namesToPlugins[pluginName] = pluginModule;
isOrderingDirty = true;
}
}
@@ -13949,13 +15239,19 @@ var EventPluginRegistry = {
if (dispatchConfig.registrationName) {
return EventPluginRegistry.registrationNameModules[dispatchConfig.registrationName] || null;
}
- for (var phase in dispatchConfig.phasedRegistrationNames) {
- if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
- continue;
- }
- var PluginModule = EventPluginRegistry.registrationNameModules[dispatchConfig.phasedRegistrationNames[phase]];
- if (PluginModule) {
- return PluginModule;
+ if (dispatchConfig.phasedRegistrationNames !== undefined) {
+ // pulling phasedRegistrationNames out of dispatchConfig helps Flow see
+ // that it is not undefined.
+ var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
+
+ for (var phase in phasedRegistrationNames) {
+ if (!phasedRegistrationNames.hasOwnProperty(phase)) {
+ continue;
+ }
+ var pluginModule = EventPluginRegistry.registrationNameModules[phasedRegistrationNames[phase]];
+ if (pluginModule) {
+ return pluginModule;
+ }
}
}
return null;
@@ -13966,7 +15262,7 @@ var EventPluginRegistry = {
* @private
*/
_resetEventPlugins: function () {
- EventPluginOrder = null;
+ eventPluginOrder = null;
for (var pluginName in namesToPlugins) {
if (namesToPlugins.hasOwnProperty(pluginName)) {
delete namesToPlugins[pluginName];
@@ -14003,7 +15299,7 @@ var EventPluginRegistry = {
module.exports = EventPluginRegistry;
}).call(this,require('_process'))
-},{"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],40:[function(require,module,exports){
+},{"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],61:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -14013,14 +15309,12 @@ module.exports = EventPluginRegistry;
* 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
*/
'use strict';
var _prodInvariant = require('./reactProdInvariant');
-var EventConstants = require('./EventConstants');
var ReactErrorUtils = require('./ReactErrorUtils');
var invariant = require('fbjs/lib/invariant');
@@ -14051,17 +15345,15 @@ var injection = {
}
};
-var topLevelTypes = EventConstants.topLevelTypes;
-
function isEndish(topLevelType) {
- return topLevelType === topLevelTypes.topMouseUp || topLevelType === topLevelTypes.topTouchEnd || topLevelType === topLevelTypes.topTouchCancel;
+ return topLevelType === 'topMouseUp' || topLevelType === 'topTouchEnd' || topLevelType === 'topTouchCancel';
}
function isMoveish(topLevelType) {
- return topLevelType === topLevelTypes.topMouseMove || topLevelType === topLevelTypes.topTouchMove;
+ return topLevelType === 'topMouseMove' || topLevelType === 'topTouchMove';
}
function isStartish(topLevelType) {
- return topLevelType === topLevelTypes.topMouseDown || topLevelType === topLevelTypes.topTouchStart;
+ return topLevelType === 'topMouseDown' || topLevelType === 'topTouchStart';
}
var validateEventDispatches;
@@ -14236,7 +15528,7 @@ var EventPluginUtils = {
module.exports = EventPluginUtils;
}).call(this,require('_process'))
-},{"./EventConstants":37,"./ReactErrorUtils":85,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"fbjs/lib/warning":188}],41:[function(require,module,exports){
+},{"./ReactErrorUtils":96,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25}],62:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -14246,12 +15538,10 @@ module.exports = EventPluginUtils;
* 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
*/
'use strict';
-var EventConstants = require('./EventConstants');
var EventPluginHub = require('./EventPluginHub');
var EventPluginUtils = require('./EventPluginUtils');
@@ -14259,7 +15549,6 @@ var accumulateInto = require('./accumulateInto');
var forEachAccumulated = require('./forEachAccumulated');
var warning = require('fbjs/lib/warning');
-var PropagationPhases = EventConstants.PropagationPhases;
var getListener = EventPluginHub.getListener;
/**
@@ -14277,11 +15566,10 @@ function listenerAtPhase(inst, event, propagationPhase) {
* Mutating the event's members allows us to not have to create a wrapping
* "dispatch" object that pairs the event with the listener.
*/
-function accumulateDirectionalDispatches(inst, upwards, event) {
+function accumulateDirectionalDispatches(inst, phase, event) {
if (process.env.NODE_ENV !== 'production') {
process.env.NODE_ENV !== 'production' ? warning(inst, 'Dispatching inst must not be null') : void 0;
}
- var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
var listener = listenerAtPhase(inst, event, phase);
if (listener) {
event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
@@ -14377,7 +15665,7 @@ var EventPropagators = {
module.exports = EventPropagators;
}).call(this,require('_process'))
-},{"./EventConstants":37,"./EventPluginHub":38,"./EventPluginUtils":40,"./accumulateInto":132,"./forEachAccumulated":141,"_process":15,"fbjs/lib/warning":188}],42:[function(require,module,exports){
+},{"./EventPluginHub":59,"./EventPluginUtils":61,"./accumulateInto":140,"./forEachAccumulated":148,"_process":43,"fbjs/lib/warning":25}],63:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -14386,7 +15674,6 @@ module.exports = EventPropagators;
* 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 FallbackCompositionState
*/
'use strict';
@@ -14473,7 +15760,7 @@ _assign(FallbackCompositionState.prototype, {
PooledClass.addPoolingTo(FallbackCompositionState);
module.exports = FallbackCompositionState;
-},{"./PooledClass":46,"./getTextContentAccessor":149,"object-assign":14}],43:[function(require,module,exports){
+},{"./PooledClass":67,"./getTextContentAccessor":157,"object-assign":170}],64:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -14482,7 +15769,6 @@ module.exports = FallbackCompositionState;
* 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
*/
'use strict';
@@ -14508,6 +15794,8 @@ var HTMLDOMPropertyConfig = {
allowFullScreen: HAS_BOOLEAN_VALUE,
allowTransparency: 0,
alt: 0,
+ // specifies target context for links with `preload` type
+ as: 0,
async: HAS_BOOLEAN_VALUE,
autoComplete: 0,
// autoFocus is polyfilled/normalized by AutoFocusUtils
@@ -14588,11 +15876,13 @@ var HTMLDOMPropertyConfig = {
optimum: 0,
pattern: 0,
placeholder: 0,
+ playsInline: HAS_BOOLEAN_VALUE,
poster: 0,
preload: 0,
profile: 0,
radioGroup: 0,
readOnly: HAS_BOOLEAN_VALUE,
+ referrerPolicy: 0,
rel: 0,
required: HAS_BOOLEAN_VALUE,
reversed: HAS_BOOLEAN_VALUE,
@@ -14682,7 +15972,7 @@ var HTMLDOMPropertyConfig = {
};
module.exports = HTMLDOMPropertyConfig;
-},{"./DOMProperty":31}],44:[function(require,module,exports){
+},{"./DOMProperty":54}],65:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -14691,7 +15981,6 @@ module.exports = HTMLDOMPropertyConfig;
* 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 KeyEscapeUtils
*
*/
@@ -14742,7 +16031,7 @@ var KeyEscapeUtils = {
};
module.exports = KeyEscapeUtils;
-},{}],45:[function(require,module,exports){
+},{}],66:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -14752,15 +16041,14 @@ module.exports = KeyEscapeUtils;
* 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
*/
'use strict';
var _prodInvariant = require('./reactProdInvariant');
-var ReactPropTypes = require('./ReactPropTypes');
-var ReactPropTypeLocations = require('./ReactPropTypeLocations');
+var React = require('react/lib/React');
+var ReactPropTypesSecret = require('./ReactPropTypesSecret');
var invariant = require('fbjs/lib/invariant');
var warning = require('fbjs/lib/warning');
@@ -14801,7 +16089,7 @@ var propTypes = {
}
return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
},
- onChange: ReactPropTypes.func
+ onChange: React.PropTypes.func
};
var loggedTypeFailures = {};
@@ -14823,7 +16111,7 @@ var LinkedValueUtils = {
checkPropTypes: function (tagName, props, owner) {
for (var propName in propTypes) {
if (propTypes.hasOwnProperty(propName)) {
- var error = propTypes[propName](props, propName, tagName, ReactPropTypeLocations.prop);
+ var error = propTypes[propName](props, propName, tagName, 'prop', null, ReactPropTypesSecret);
}
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
// Only monitor this failure once because there tends to be a lot of the
@@ -14881,7 +16169,7 @@ var LinkedValueUtils = {
module.exports = LinkedValueUtils;
}).call(this,require('_process'))
-},{"./ReactPropTypeLocations":104,"./ReactPropTypes":105,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"fbjs/lib/warning":188}],46:[function(require,module,exports){
+},{"./ReactPropTypesSecret":113,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25,"react/lib/React":187}],67:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -14891,7 +16179,7 @@ module.exports = LinkedValueUtils;
* 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
+ *
*/
'use strict';
@@ -14951,17 +16239,6 @@ var fourArgumentPooler = function (a1, a2, a3, a4) {
}
};
-var fiveArgumentPooler = function (a1, a2, a3, a4, a5) {
- var Klass = this;
- if (Klass.instancePool.length) {
- var instance = Klass.instancePool.pop();
- Klass.call(instance, a1, a2, a3, a4, a5);
- return instance;
- } else {
- return new Klass(a1, a2, a3, a4, a5);
- }
-};
-
var standardReleaser = function (instance) {
var Klass = this;
!(instance instanceof Klass) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : _prodInvariant('25') : void 0;
@@ -14984,6 +16261,8 @@ var DEFAULT_POOLER = oneArgumentPooler;
* @param {Function} pooler Customizable pooler.
*/
var addPoolingTo = function (CopyConstructor, pooler) {
+ // Casting as any so that flow ignores the actual implementation and trusts
+ // it to match the type we declared
var NewKlass = CopyConstructor;
NewKlass.instancePool = [];
NewKlass.getPooled = pooler || DEFAULT_POOLER;
@@ -14999,15 +16278,13 @@ var PooledClass = {
oneArgumentPooler: oneArgumentPooler,
twoArgumentPooler: twoArgumentPooler,
threeArgumentPooler: threeArgumentPooler,
- fourArgumentPooler: fourArgumentPooler,
- fiveArgumentPooler: fiveArgumentPooler
+ fourArgumentPooler: fourArgumentPooler
};
module.exports = PooledClass;
}).call(this,require('_process'))
-},{"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],47:[function(require,module,exports){
-(function (process){
+},{"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],68:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -15016,104 +16293,12 @@ module.exports = PooledClass;
* 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
*/
'use strict';
var _assign = require('object-assign');
-var ReactChildren = require('./ReactChildren');
-var ReactComponent = require('./ReactComponent');
-var ReactClass = require('./ReactClass');
-var ReactDOMFactories = require('./ReactDOMFactories');
-var ReactElement = require('./ReactElement');
-var ReactPropTypes = require('./ReactPropTypes');
-var ReactVersion = require('./ReactVersion');
-
-var onlyChild = require('./onlyChild');
-var warning = require('fbjs/lib/warning');
-
-var createElement = ReactElement.createElement;
-var createFactory = ReactElement.createFactory;
-var cloneElement = ReactElement.cloneElement;
-
-if (process.env.NODE_ENV !== 'production') {
- var ReactElementValidator = require('./ReactElementValidator');
- createElement = ReactElementValidator.createElement;
- createFactory = ReactElementValidator.createFactory;
- cloneElement = ReactElementValidator.cloneElement;
-}
-
-var __spread = _assign;
-
-if (process.env.NODE_ENV !== 'production') {
- var warned = false;
- __spread = function () {
- process.env.NODE_ENV !== 'production' ? warning(warned, 'React.__spread is deprecated and should not be used. Use ' + 'Object.assign directly or another helper function with similar ' + 'semantics. You may be seeing this warning due to your compiler. ' + 'See https://fb.me/react-spread-deprecation for more details.') : void 0;
- warned = true;
- return _assign.apply(null, arguments);
- };
-}
-
-var React = {
-
- // Modern
-
- Children: {
- map: ReactChildren.map,
- forEach: ReactChildren.forEach,
- count: ReactChildren.count,
- toArray: ReactChildren.toArray,
- only: onlyChild
- },
-
- Component: ReactComponent,
-
- createElement: createElement,
- cloneElement: cloneElement,
- isValidElement: ReactElement.isValidElement,
-
- // Classic
-
- PropTypes: ReactPropTypes,
- createClass: ReactClass.createClass,
- createFactory: createFactory,
- createMixin: function (mixin) {
- // Currently a noop. Will be used to validate and trace mixins.
- return mixin;
- },
-
- // This looks DOM specific but these are actually isomorphic helpers
- // since they are just generating DOM strings.
- DOM: ReactDOMFactories,
-
- version: ReactVersion,
-
- // Deprecated hook for JSX spread, don't use this for anything.
- __spread: __spread
-};
-
-module.exports = React;
-}).call(this,require('_process'))
-
-},{"./ReactChildren":50,"./ReactClass":51,"./ReactComponent":52,"./ReactDOMFactories":66,"./ReactElement":82,"./ReactElementValidator":83,"./ReactPropTypes":105,"./ReactVersion":113,"./onlyChild":154,"_process":15,"fbjs/lib/warning":188,"object-assign":14}],48:[function(require,module,exports){
-/**
- * Copyright 2013-present, 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 ReactBrowserEventEmitter
- */
-
-'use strict';
-
-var _assign = require('object-assign');
-
-var EventConstants = require('./EventConstants');
var EventPluginRegistry = require('./EventPluginRegistry');
var ReactEventEmitterMixin = require('./ReactEventEmitterMixin');
var ViewportMetrics = require('./ViewportMetrics');
@@ -15337,42 +16522,41 @@ var ReactBrowserEventEmitter = _assign({}, ReactEventEmitterMixin, {
var isListening = getListeningForDocument(mountAt);
var dependencies = EventPluginRegistry.registrationNameDependencies[registrationName];
- var topLevelTypes = EventConstants.topLevelTypes;
for (var i = 0; i < dependencies.length; i++) {
var dependency = dependencies[i];
if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
- if (dependency === topLevelTypes.topWheel) {
+ if (dependency === 'topWheel') {
if (isEventSupported('wheel')) {
- ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'wheel', mountAt);
+ ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent('topWheel', 'wheel', mountAt);
} else if (isEventSupported('mousewheel')) {
- ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'mousewheel', mountAt);
+ ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent('topWheel', 'mousewheel', mountAt);
} else {
// Firefox needs to capture a different mouse scroll event.
// @see http://www.quirksmode.org/dom/events/tests/scroll.html
- ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'DOMMouseScroll', mountAt);
+ ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent('topWheel', 'DOMMouseScroll', mountAt);
}
- } else if (dependency === topLevelTypes.topScroll) {
+ } else if (dependency === 'topScroll') {
if (isEventSupported('scroll', true)) {
- ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topScroll, 'scroll', mountAt);
+ ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent('topScroll', 'scroll', mountAt);
} else {
- ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topScroll, 'scroll', ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE);
+ ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent('topScroll', 'scroll', ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE);
}
- } else if (dependency === topLevelTypes.topFocus || dependency === topLevelTypes.topBlur) {
+ } else if (dependency === 'topFocus' || dependency === 'topBlur') {
if (isEventSupported('focus', true)) {
- ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topFocus, 'focus', mountAt);
- ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topBlur, 'blur', mountAt);
+ ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent('topFocus', 'focus', mountAt);
+ ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent('topBlur', 'blur', mountAt);
} else if (isEventSupported('focusin')) {
// IE has `focusin` and `focusout` events which bubble.
// @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
- ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topFocus, 'focusin', mountAt);
- ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topBlur, 'focusout', mountAt);
+ ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent('topFocus', 'focusin', mountAt);
+ ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent('topBlur', 'focusout', mountAt);
}
// to make sure blur and focus event listeners are only attached once
- isListening[topLevelTypes.topBlur] = true;
- isListening[topLevelTypes.topFocus] = true;
+ isListening.topBlur = true;
+ isListening.topFocus = true;
} else if (topEventMapping.hasOwnProperty(dependency)) {
ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(dependency, topEventMapping[dependency], mountAt);
}
@@ -15391,6 +16575,19 @@ var ReactBrowserEventEmitter = _assign({}, ReactEventEmitterMixin, {
},
/**
+ * Protect against document.createEvent() returning null
+ * Some popup blocker extensions appear to do this:
+ * https://github.com/facebook/react/issues/6887
+ */
+ supportsEventPageXY: function () {
+ if (!document.createEvent) {
+ return false;
+ }
+ var ev = document.createEvent('MouseEvent');
+ return ev != null && 'pageX' in ev;
+ },
+
+ /**
* Listens to window scroll and resize events. We cache scroll values so that
* application code can access them without triggering reflows.
*
@@ -15403,7 +16600,7 @@ var ReactBrowserEventEmitter = _assign({}, ReactEventEmitterMixin, {
*/
ensureScrollValueMonitoring: function () {
if (hasEventPageXY === undefined) {
- hasEventPageXY = document.createEvent && 'pageX' in document.createEvent('MouseEvent');
+ hasEventPageXY = ReactBrowserEventEmitter.supportsEventPageXY();
}
if (!hasEventPageXY && !isMonitoringScrollValue) {
var refresh = ViewportMetrics.refreshScrollValues;
@@ -15415,7 +16612,7 @@ var ReactBrowserEventEmitter = _assign({}, ReactEventEmitterMixin, {
});
module.exports = ReactBrowserEventEmitter;
-},{"./EventConstants":37,"./EventPluginRegistry":39,"./ReactEventEmitterMixin":86,"./ViewportMetrics":131,"./getVendorPrefixedEventName":150,"./isEventSupported":152,"object-assign":14}],49:[function(require,module,exports){
+},{"./EventPluginRegistry":60,"./ReactEventEmitterMixin":97,"./ViewportMetrics":139,"./getVendorPrefixedEventName":158,"./isEventSupported":160,"object-assign":170}],69:[function(require,module,exports){
(function (process){
/**
* Copyright 2014-present, Facebook, Inc.
@@ -15425,7 +16622,6 @@ module.exports = ReactBrowserEventEmitter;
* 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 ReactChildReconciler
*/
'use strict';
@@ -15438,12 +16634,27 @@ var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
var traverseAllChildren = require('./traverseAllChildren');
var warning = require('fbjs/lib/warning');
+var ReactComponentTreeHook;
+
+if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') {
+ // Temporary hack.
+ // Inline requires don't work well with Jest:
+ // https://github.com/facebook/react/issues/7240
+ // Remove the inline requires when we don't need them anymore:
+ // https://github.com/facebook/react/pull/7178
+ ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
+}
+
function instantiateChild(childInstances, child, name, selfDebugID) {
// We found a component instance.
var keyUnique = childInstances[name] === undefined;
if (process.env.NODE_ENV !== 'production') {
- var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
- process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeDevtool.getStackAddendumByID(selfDebugID)) : void 0;
+ if (!ReactComponentTreeHook) {
+ ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
+ }
+ if (!keyUnique) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeHook.getStackAddendumByID(selfDebugID)) : void 0;
+ }
}
if (child != null && keyUnique) {
childInstances[name] = instantiateReactComponent(child, true);
@@ -15464,7 +16675,7 @@ var ReactChildReconciler = {
* @return {?object} A set of child instances.
* @internal
*/
- instantiateChildren: function (nestedChildNodes, transaction, context, selfDebugID // __DEV__ only
+ instantiateChildren: function (nestedChildNodes, transaction, context, selfDebugID // 0 in production and for roots
) {
if (nestedChildNodes == null) {
return null;
@@ -15491,7 +16702,8 @@ var ReactChildReconciler = {
* @return {?object} A new set of child instances.
* @internal
*/
- updateChildren: function (prevChildren, nextChildren, removedNodes, transaction, context) {
+ updateChildren: function (prevChildren, nextChildren, mountImages, removedNodes, transaction, hostParent, hostContainerInfo, context, selfDebugID // 0 in production and for roots
+ ) {
// We currently don't have a way to track moves here but if we use iterators
// instead of for..in we can zip the iterators and check if an item has
// moved.
@@ -15520,6 +16732,10 @@ var ReactChildReconciler = {
// The child must be instantiated before it's mounted.
var nextChildInstance = instantiateReactComponent(nextElement, true);
nextChildren[name] = nextChildInstance;
+ // Creating mount image now ensures refs are resolved in right order
+ // (see https://github.com/facebook/react/pull/7101 for explanation).
+ var nextChildMountImage = ReactReconciler.mountComponent(nextChildInstance, transaction, hostParent, hostContainerInfo, context, selfDebugID);
+ mountImages.push(nextChildMountImage);
}
}
// Unmount children that are no longer present.
@@ -15553,1050 +16769,7 @@ var ReactChildReconciler = {
module.exports = ReactChildReconciler;
}).call(this,require('_process'))
-},{"./KeyEscapeUtils":44,"./ReactComponentTreeDevtool":55,"./ReactReconciler":107,"./instantiateReactComponent":151,"./shouldUpdateReactComponent":160,"./traverseAllChildren":161,"_process":15,"fbjs/lib/warning":188}],50:[function(require,module,exports){
-/**
- * Copyright 2013-present, 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 ReactChildren
- */
-
-'use strict';
-
-var PooledClass = require('./PooledClass');
-var ReactElement = require('./ReactElement');
-
-var emptyFunction = require('fbjs/lib/emptyFunction');
-var traverseAllChildren = require('./traverseAllChildren');
-
-var twoArgumentPooler = PooledClass.twoArgumentPooler;
-var fourArgumentPooler = PooledClass.fourArgumentPooler;
-
-var userProvidedKeyEscapeRegex = /\/+/g;
-function escapeUserProvidedKey(text) {
- return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
-}
-
-/**
- * PooledClass representing the bookkeeping associated with performing a child
- * traversal. Allows avoiding binding callbacks.
- *
- * @constructor ForEachBookKeeping
- * @param {!function} forEachFunction Function to perform traversal with.
- * @param {?*} forEachContext Context to perform context with.
- */
-function ForEachBookKeeping(forEachFunction, forEachContext) {
- this.func = forEachFunction;
- this.context = forEachContext;
- this.count = 0;
-}
-ForEachBookKeeping.prototype.destructor = function () {
- this.func = null;
- this.context = null;
- this.count = 0;
-};
-PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
-
-function forEachSingleChild(bookKeeping, child, name) {
- var func = bookKeeping.func;
- var context = bookKeeping.context;
-
- func.call(context, child, bookKeeping.count++);
-}
-
-/**
- * Iterates through children that are typically specified as `props.children`.
- *
- * See https://facebook.github.io/react/docs/top-level-api.html#react.children.foreach
- *
- * The provided forEachFunc(child, index) will be called for each
- * leaf child.
- *
- * @param {?*} children Children tree container.
- * @param {function(*, int)} forEachFunc
- * @param {*} forEachContext Context for forEachContext.
- */
-function forEachChildren(children, forEachFunc, forEachContext) {
- if (children == null) {
- return children;
- }
- var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
- traverseAllChildren(children, forEachSingleChild, traverseContext);
- ForEachBookKeeping.release(traverseContext);
-}
-
-/**
- * PooledClass representing the bookkeeping associated with performing a child
- * mapping. Allows avoiding binding callbacks.
- *
- * @constructor MapBookKeeping
- * @param {!*} mapResult Object containing the ordered map of results.
- * @param {!function} mapFunction Function to perform mapping with.
- * @param {?*} mapContext Context to perform mapping with.
- */
-function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
- this.result = mapResult;
- this.keyPrefix = keyPrefix;
- this.func = mapFunction;
- this.context = mapContext;
- this.count = 0;
-}
-MapBookKeeping.prototype.destructor = function () {
- this.result = null;
- this.keyPrefix = null;
- this.func = null;
- this.context = null;
- this.count = 0;
-};
-PooledClass.addPoolingTo(MapBookKeeping, fourArgumentPooler);
-
-function mapSingleChildIntoContext(bookKeeping, child, childKey) {
- var result = bookKeeping.result;
- var keyPrefix = bookKeeping.keyPrefix;
- var func = bookKeeping.func;
- var context = bookKeeping.context;
-
-
- var mappedChild = func.call(context, child, bookKeeping.count++);
- if (Array.isArray(mappedChild)) {
- mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
- } else if (mappedChild != null) {
- if (ReactElement.isValidElement(mappedChild)) {
- mappedChild = ReactElement.cloneAndReplaceKey(mappedChild,
- // Keep both the (mapped) and old keys if they differ, just as
- // traverseAllChildren used to do for objects as children
- keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
- }
- result.push(mappedChild);
- }
-}
-
-function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
- var escapedPrefix = '';
- if (prefix != null) {
- escapedPrefix = escapeUserProvidedKey(prefix) + '/';
- }
- var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
- traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
- MapBookKeeping.release(traverseContext);
-}
-
-/**
- * Maps children that are typically specified as `props.children`.
- *
- * See https://facebook.github.io/react/docs/top-level-api.html#react.children.map
- *
- * The provided mapFunction(child, key, index) will be called for each
- * leaf child.
- *
- * @param {?*} children Children tree container.
- * @param {function(*, int)} func The map function.
- * @param {*} context Context for mapFunction.
- * @return {object} Object containing the ordered map of results.
- */
-function mapChildren(children, func, context) {
- if (children == null) {
- return children;
- }
- var result = [];
- mapIntoWithKeyPrefixInternal(children, result, null, func, context);
- return result;
-}
-
-function forEachSingleChildDummy(traverseContext, child, name) {
- return null;
-}
-
-/**
- * Count the number of children that are typically specified as
- * `props.children`.
- *
- * See https://facebook.github.io/react/docs/top-level-api.html#react.children.count
- *
- * @param {?*} children Children tree container.
- * @return {number} The number of children.
- */
-function countChildren(children, context) {
- return traverseAllChildren(children, forEachSingleChildDummy, null);
-}
-
-/**
- * Flatten a children object (typically specified as `props.children`) and
- * return an array with appropriately re-keyed children.
- *
- * See https://facebook.github.io/react/docs/top-level-api.html#react.children.toarray
- */
-function toArray(children) {
- var result = [];
- mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
- return result;
-}
-
-var ReactChildren = {
- forEach: forEachChildren,
- map: mapChildren,
- mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
- count: countChildren,
- toArray: toArray
-};
-
-module.exports = ReactChildren;
-},{"./PooledClass":46,"./ReactElement":82,"./traverseAllChildren":161,"fbjs/lib/emptyFunction":170}],51:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2013-present, 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 ReactClass
- */
-
-'use strict';
-
-var _prodInvariant = require('./reactProdInvariant'),
- _assign = require('object-assign');
-
-var ReactComponent = require('./ReactComponent');
-var ReactElement = require('./ReactElement');
-var ReactPropTypeLocations = require('./ReactPropTypeLocations');
-var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
-var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
-
-var emptyObject = require('fbjs/lib/emptyObject');
-var invariant = require('fbjs/lib/invariant');
-var keyMirror = require('fbjs/lib/keyMirror');
-var keyOf = require('fbjs/lib/keyOf');
-var warning = require('fbjs/lib/warning');
-
-var MIXINS_KEY = keyOf({ mixins: null });
-
-/**
- * Policies that describe methods in `ReactClassInterface`.
- */
-var SpecPolicy = keyMirror({
- /**
- * These methods may be defined only once by the class specification or mixin.
- */
- DEFINE_ONCE: null,
- /**
- * These methods may be defined by both the class specification and mixins.
- * Subsequent definitions will be chained. These methods must return void.
- */
- DEFINE_MANY: null,
- /**
- * These methods are overriding the base class.
- */
- OVERRIDE_BASE: null,
- /**
- * These methods are similar to DEFINE_MANY, except we assume they return
- * objects. We try to merge the keys of the return values of all the mixed in
- * functions. If there is a key conflict we throw.
- */
- DEFINE_MANY_MERGED: null
-});
-
-var injectedMixins = [];
-
-/**
- * Composite components are higher-level components that compose other composite
- * or host components.
- *
- * To create a new type of `ReactClass`, pass a specification of
- * your new class to `React.createClass`. The only requirement of your class
- * specification is that you implement a `render` method.
- *
- * var MyComponent = React.createClass({
- * render: function() {
- * return <div>Hello World</div>;
- * }
- * });
- *
- * The class specification supports a specific protocol of methods that have
- * special meaning (e.g. `render`). See `ReactClassInterface` for
- * more the comprehensive protocol. Any other properties and methods in the
- * class specification will be available on the prototype.
- *
- * @interface ReactClassInterface
- * @internal
- */
-var ReactClassInterface = {
-
- /**
- * An array of Mixin objects to include when defining your component.
- *
- * @type {array}
- * @optional
- */
- mixins: SpecPolicy.DEFINE_MANY,
-
- /**
- * An object containing properties and methods that should be defined on
- * the component's constructor instead of its prototype (static methods).
- *
- * @type {object}
- * @optional
- */
- statics: SpecPolicy.DEFINE_MANY,
-
- /**
- * Definition of prop types for this component.
- *
- * @type {object}
- * @optional
- */
- propTypes: SpecPolicy.DEFINE_MANY,
-
- /**
- * Definition of context types for this component.
- *
- * @type {object}
- * @optional
- */
- contextTypes: SpecPolicy.DEFINE_MANY,
-
- /**
- * Definition of context types this component sets for its children.
- *
- * @type {object}
- * @optional
- */
- childContextTypes: SpecPolicy.DEFINE_MANY,
-
- // ==== Definition methods ====
-
- /**
- * Invoked when the component is mounted. Values in the mapping will be set on
- * `this.props` if that prop is not specified (i.e. using an `in` check).
- *
- * This method is invoked before `getInitialState` and therefore cannot rely
- * on `this.state` or use `this.setState`.
- *
- * @return {object}
- * @optional
- */
- getDefaultProps: SpecPolicy.DEFINE_MANY_MERGED,
-
- /**
- * Invoked once before the component is mounted. The return value will be used
- * as the initial value of `this.state`.
- *
- * getInitialState: function() {
- * return {
- * isOn: false,
- * fooBaz: new BazFoo()
- * }
- * }
- *
- * @return {object}
- * @optional
- */
- getInitialState: SpecPolicy.DEFINE_MANY_MERGED,
-
- /**
- * @return {object}
- * @optional
- */
- getChildContext: SpecPolicy.DEFINE_MANY_MERGED,
-
- /**
- * Uses props from `this.props` and state from `this.state` to render the
- * structure of the component.
- *
- * No guarantees are made about when or how often this method is invoked, so
- * it must not have side effects.
- *
- * render: function() {
- * var name = this.props.name;
- * return <div>Hello, {name}!</div>;
- * }
- *
- * @return {ReactComponent}
- * @nosideeffects
- * @required
- */
- render: SpecPolicy.DEFINE_ONCE,
-
- // ==== Delegate methods ====
-
- /**
- * Invoked when the component is initially created and about to be mounted.
- * This may have side effects, but any external subscriptions or data created
- * by this method must be cleaned up in `componentWillUnmount`.
- *
- * @optional
- */
- componentWillMount: SpecPolicy.DEFINE_MANY,
-
- /**
- * Invoked when the component has been mounted and has a DOM representation.
- * However, there is no guarantee that the DOM node is in the document.
- *
- * Use this as an opportunity to operate on the DOM when the component has
- * been mounted (initialized and rendered) for the first time.
- *
- * @param {DOMElement} rootNode DOM element representing the component.
- * @optional
- */
- componentDidMount: SpecPolicy.DEFINE_MANY,
-
- /**
- * Invoked before the component receives new props.
- *
- * Use this as an opportunity to react to a prop transition by updating the
- * state using `this.setState`. Current props are accessed via `this.props`.
- *
- * componentWillReceiveProps: function(nextProps, nextContext) {
- * this.setState({
- * likesIncreasing: nextProps.likeCount > this.props.likeCount
- * });
- * }
- *
- * NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
- * transition may cause a state change, but the opposite is not true. If you
- * need it, you are probably looking for `componentWillUpdate`.
- *
- * @param {object} nextProps
- * @optional
- */
- componentWillReceiveProps: SpecPolicy.DEFINE_MANY,
-
- /**
- * Invoked while deciding if the component should be updated as a result of
- * receiving new props, state and/or context.
- *
- * Use this as an opportunity to `return false` when you're certain that the
- * transition to the new props/state/context will not require a component
- * update.
- *
- * shouldComponentUpdate: function(nextProps, nextState, nextContext) {
- * return !equal(nextProps, this.props) ||
- * !equal(nextState, this.state) ||
- * !equal(nextContext, this.context);
- * }
- *
- * @param {object} nextProps
- * @param {?object} nextState
- * @param {?object} nextContext
- * @return {boolean} True if the component should update.
- * @optional
- */
- shouldComponentUpdate: SpecPolicy.DEFINE_ONCE,
-
- /**
- * Invoked when the component is about to update due to a transition from
- * `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
- * and `nextContext`.
- *
- * Use this as an opportunity to perform preparation before an update occurs.
- *
- * NOTE: You **cannot** use `this.setState()` in this method.
- *
- * @param {object} nextProps
- * @param {?object} nextState
- * @param {?object} nextContext
- * @param {ReactReconcileTransaction} transaction
- * @optional
- */
- componentWillUpdate: SpecPolicy.DEFINE_MANY,
-
- /**
- * Invoked when the component's DOM representation has been updated.
- *
- * Use this as an opportunity to operate on the DOM when the component has
- * been updated.
- *
- * @param {object} prevProps
- * @param {?object} prevState
- * @param {?object} prevContext
- * @param {DOMElement} rootNode DOM element representing the component.
- * @optional
- */
- componentDidUpdate: SpecPolicy.DEFINE_MANY,
-
- /**
- * Invoked when the component is about to be removed from its parent and have
- * its DOM representation destroyed.
- *
- * Use this as an opportunity to deallocate any external resources.
- *
- * NOTE: There is no `componentDidUnmount` since your component will have been
- * destroyed by that point.
- *
- * @optional
- */
- componentWillUnmount: SpecPolicy.DEFINE_MANY,
-
- // ==== Advanced methods ====
-
- /**
- * Updates the component's currently mounted DOM representation.
- *
- * By default, this implements React's rendering and reconciliation algorithm.
- * Sophisticated clients may wish to override this.
- *
- * @param {ReactReconcileTransaction} transaction
- * @internal
- * @overridable
- */
- updateComponent: SpecPolicy.OVERRIDE_BASE
-
-};
-
-/**
- * Mapping from class specification keys to special processing functions.
- *
- * Although these are declared like instance properties in the specification
- * when defining classes using `React.createClass`, they are actually static
- * and are accessible on the constructor instead of the prototype. Despite
- * being static, they must be defined outside of the "statics" key under
- * which all other static methods are defined.
- */
-var RESERVED_SPEC_KEYS = {
- displayName: function (Constructor, displayName) {
- Constructor.displayName = displayName;
- },
- mixins: function (Constructor, mixins) {
- if (mixins) {
- for (var i = 0; i < mixins.length; i++) {
- mixSpecIntoComponent(Constructor, mixins[i]);
- }
- }
- },
- childContextTypes: function (Constructor, childContextTypes) {
- if (process.env.NODE_ENV !== 'production') {
- validateTypeDef(Constructor, childContextTypes, ReactPropTypeLocations.childContext);
- }
- Constructor.childContextTypes = _assign({}, Constructor.childContextTypes, childContextTypes);
- },
- contextTypes: function (Constructor, contextTypes) {
- if (process.env.NODE_ENV !== 'production') {
- validateTypeDef(Constructor, contextTypes, ReactPropTypeLocations.context);
- }
- Constructor.contextTypes = _assign({}, Constructor.contextTypes, contextTypes);
- },
- /**
- * Special case getDefaultProps which should move into statics but requires
- * automatic merging.
- */
- getDefaultProps: function (Constructor, getDefaultProps) {
- if (Constructor.getDefaultProps) {
- Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps);
- } else {
- Constructor.getDefaultProps = getDefaultProps;
- }
- },
- propTypes: function (Constructor, propTypes) {
- if (process.env.NODE_ENV !== 'production') {
- validateTypeDef(Constructor, propTypes, ReactPropTypeLocations.prop);
- }
- Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes);
- },
- statics: function (Constructor, statics) {
- mixStaticSpecIntoComponent(Constructor, statics);
- },
- autobind: function () {} };
-
-// noop
-function validateTypeDef(Constructor, typeDef, location) {
- for (var propName in typeDef) {
- if (typeDef.hasOwnProperty(propName)) {
- // use a warning instead of an invariant so components
- // don't show up in prod but only in __DEV__
- process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : void 0;
- }
- }
-}
-
-function validateMethodOverride(isAlreadyDefined, name) {
- var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
-
- // Disallow overriding of base class methods unless explicitly allowed.
- if (ReactClassMixin.hasOwnProperty(name)) {
- !(specPolicy === SpecPolicy.OVERRIDE_BASE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.', name) : _prodInvariant('73', name) : void 0;
- }
-
- // Disallow defining methods more than once unless explicitly allowed.
- if (isAlreadyDefined) {
- !(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : _prodInvariant('74', name) : void 0;
- }
-}
-
-/**
- * Mixin helper which handles policy validation and reserved
- * specification keys when building React classes.
- */
-function mixSpecIntoComponent(Constructor, spec) {
- if (!spec) {
- return;
- }
-
- !(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to use a component class or function as a mixin. Instead, just use a regular object.') : _prodInvariant('75') : void 0;
- !!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to use a component as a mixin. Instead, just use a regular object.') : _prodInvariant('76') : void 0;
-
- var proto = Constructor.prototype;
- var autoBindPairs = proto.__reactAutoBindPairs;
-
- // 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) {
- if (!spec.hasOwnProperty(name)) {
- continue;
- }
-
- if (name === MIXINS_KEY) {
- // We have already handled mixins in a special case above.
- continue;
- }
-
- var property = spec[name];
- var isAlreadyDefined = proto.hasOwnProperty(name);
- validateMethodOverride(isAlreadyDefined, name);
-
- if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
- RESERVED_SPEC_KEYS[name](Constructor, property);
- } else {
- // Setup methods on prototype:
- // The following member methods should not be automatically bound:
- // 1. Expected ReactClass methods (in the "interface").
- // 2. Overridden methods (that were mixed in).
- var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
- var isFunction = typeof property === 'function';
- var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;
-
- if (shouldAutoBind) {
- autoBindPairs.push(name, property);
- proto[name] = property;
- } else {
- if (isAlreadyDefined) {
- var specPolicy = ReactClassInterface[name];
-
- // These cases should already be caught by validateMethodOverride.
- !(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.', specPolicy, name) : _prodInvariant('77', specPolicy, name) : void 0;
-
- // For methods which are defined more than once, call the existing
- // methods before calling the new property, merging if appropriate.
- if (specPolicy === SpecPolicy.DEFINE_MANY_MERGED) {
- proto[name] = createMergedResultFunction(proto[name], property);
- } else if (specPolicy === SpecPolicy.DEFINE_MANY) {
- proto[name] = createChainedFunction(proto[name], property);
- }
- } else {
- proto[name] = property;
- if (process.env.NODE_ENV !== 'production') {
- // Add verbose displayName to the function, which helps when looking
- // at profiling tools.
- if (typeof property === 'function' && spec.displayName) {
- proto[name].displayName = spec.displayName + '_' + name;
- }
- }
- }
- }
- }
- }
-}
-
-function mixStaticSpecIntoComponent(Constructor, statics) {
- if (!statics) {
- return;
- }
- for (var name in statics) {
- var property = statics[name];
- if (!statics.hasOwnProperty(name)) {
- continue;
- }
-
- var isReserved = name in RESERVED_SPEC_KEYS;
- !!isReserved ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: 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) : _prodInvariant('78', name) : void 0;
-
- var isInherited = name in Constructor;
- !!isInherited ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : _prodInvariant('79', name) : void 0;
- Constructor[name] = property;
- }
-}
-
-/**
- * Merge two objects, but throw if both contain the same key.
- *
- * @param {object} one The first object, which is mutated.
- * @param {object} two The second object
- * @return {object} one after it has been mutated to contain everything in two.
- */
-function mergeIntoWithNoDuplicateKeys(one, two) {
- !(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : _prodInvariant('80') : void 0;
-
- for (var key in two) {
- if (two.hasOwnProperty(key)) {
- !(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): 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) : _prodInvariant('81', key) : void 0;
- one[key] = two[key];
- }
- }
- return one;
-}
-
-/**
- * Creates a function that invokes two functions and merges their return values.
- *
- * @param {function} one Function to invoke first.
- * @param {function} two Function to invoke second.
- * @return {function} Function that invokes the two argument functions.
- * @private
- */
-function createMergedResultFunction(one, two) {
- return function mergedResult() {
- var a = one.apply(this, arguments);
- var b = two.apply(this, arguments);
- if (a == null) {
- return b;
- } else if (b == null) {
- return a;
- }
- var c = {};
- mergeIntoWithNoDuplicateKeys(c, a);
- mergeIntoWithNoDuplicateKeys(c, b);
- return c;
- };
-}
-
-/**
- * Creates a function that invokes two functions and ignores their return vales.
- *
- * @param {function} one Function to invoke first.
- * @param {function} two Function to invoke second.
- * @return {function} Function that invokes the two argument functions.
- * @private
- */
-function createChainedFunction(one, two) {
- return function chainedFunction() {
- one.apply(this, arguments);
- two.apply(this, arguments);
- };
-}
-
-/**
- * Binds a method to the component.
- *
- * @param {object} component Component whose method is going to be bound.
- * @param {function} method Method to be bound.
- * @return {function} The bound method.
- */
-function bindAutoBindMethod(component, method) {
- var boundMethod = method.bind(component);
- if (process.env.NODE_ENV !== 'production') {
- boundMethod.__reactBoundContext = component;
- boundMethod.__reactBoundMethod = method;
- boundMethod.__reactBoundArguments = null;
- var componentName = component.constructor.displayName;
- var _bind = boundMethod.bind;
- boundMethod.bind = function (newThis) {
- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- args[_key - 1] = arguments[_key];
- }
-
- // 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.
- if (newThis !== component && newThis !== null) {
- process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : void 0;
- } else if (!args.length) {
- process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : void 0;
- return boundMethod;
- }
- var reboundMethod = _bind.apply(boundMethod, arguments);
- reboundMethod.__reactBoundContext = component;
- reboundMethod.__reactBoundMethod = method;
- reboundMethod.__reactBoundArguments = args;
- return reboundMethod;
- };
- }
- return boundMethod;
-}
-
-/**
- * Binds all auto-bound methods in a component.
- *
- * @param {object} component Component whose method is going to be bound.
- */
-function bindAutoBindMethods(component) {
- var pairs = component.__reactAutoBindPairs;
- for (var i = 0; i < pairs.length; i += 2) {
- var autoBindKey = pairs[i];
- var method = pairs[i + 1];
- component[autoBindKey] = bindAutoBindMethod(component, method);
- }
-}
-
-/**
- * Add more to the ReactClass base class. These are all legacy features and
- * therefore not already part of the modern ReactComponent.
- */
-var ReactClassMixin = {
-
- /**
- * TODO: This will be deprecated because state should always keep a consistent
- * type signature and the only use case for this, is to avoid that.
- */
- replaceState: function (newState, callback) {
- this.updater.enqueueReplaceState(this, newState);
- if (callback) {
- this.updater.enqueueCallback(this, callback, 'replaceState');
- }
- },
-
- /**
- * Checks whether or not this composite component is mounted.
- * @return {boolean} True if mounted, false otherwise.
- * @protected
- * @final
- */
- isMounted: function () {
- return this.updater.isMounted(this);
- }
-};
-
-var ReactClassComponent = function () {};
-_assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);
-
-/**
- * Module for creating composite components.
- *
- * @class ReactClass
- */
-var ReactClass = {
-
- /**
- * Creates a composite component class given a class specification.
- * See https://facebook.github.io/react/docs/top-level-api.html#react.createclass
- *
- * @param {object} spec Class specification (which must define `render`).
- * @return {function} Component constructor function.
- * @public
- */
- createClass: function (spec) {
- var Constructor = function (props, context, updater) {
- // This constructor gets overridden by mocks. The argument is used
- // by mocks to assert on what gets mounted.
-
- if (process.env.NODE_ENV !== 'production') {
- process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : void 0;
- }
-
- // Wire up auto-binding
- if (this.__reactAutoBindPairs.length) {
- bindAutoBindMethods(this);
- }
-
- this.props = props;
- this.context = context;
- this.refs = emptyObject;
- this.updater = updater || ReactNoopUpdateQueue;
-
- this.state = null;
-
- // ReactClasses doesn't have constructors. Instead, they use the
- // getInitialState and componentWillMount methods for initialization.
-
- var initialState = this.getInitialState ? this.getInitialState() : null;
- if (process.env.NODE_ENV !== 'production') {
- // We allow auto-mocks to proceed as if they're returning null.
- if (initialState === undefined && this.getInitialState._isMockFunction) {
- // This is probably bad practice. Consider warning here and
- // deprecating this convenience.
- initialState = null;
- }
- }
- !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : _prodInvariant('82', Constructor.displayName || 'ReactCompositeComponent') : void 0;
-
- this.state = initialState;
- };
- Constructor.prototype = new ReactClassComponent();
- Constructor.prototype.constructor = Constructor;
- Constructor.prototype.__reactAutoBindPairs = [];
-
- injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
-
- mixSpecIntoComponent(Constructor, spec);
-
- // Initialize the defaultProps property after all mixins have been merged.
- if (Constructor.getDefaultProps) {
- Constructor.defaultProps = Constructor.getDefaultProps();
- }
-
- if (process.env.NODE_ENV !== 'production') {
- // This is a tag to indicate that the use of these method names is ok,
- // since it's used with createClass. If it's not, then it's likely a
- // mistake so we'll warn you to use the static property, property
- // initializer or constructor respectively.
- if (Constructor.getDefaultProps) {
- Constructor.getDefaultProps.isReactClassApproved = {};
- }
- if (Constructor.prototype.getInitialState) {
- Constructor.prototype.getInitialState.isReactClassApproved = {};
- }
- }
-
- !Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : _prodInvariant('83') : void 0;
-
- if (process.env.NODE_ENV !== 'production') {
- process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : void 0;
- process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : void 0;
- }
-
- // Reduce time spent doing lookups by setting these on the prototype.
- for (var methodName in ReactClassInterface) {
- if (!Constructor.prototype[methodName]) {
- Constructor.prototype[methodName] = null;
- }
- }
-
- return Constructor;
- },
-
- injection: {
- injectMixin: function (mixin) {
- injectedMixins.push(mixin);
- }
- }
-
-};
-
-module.exports = ReactClass;
-}).call(this,require('_process'))
-
-},{"./ReactComponent":52,"./ReactElement":82,"./ReactNoopUpdateQueue":101,"./ReactPropTypeLocationNames":103,"./ReactPropTypeLocations":104,"./reactProdInvariant":156,"_process":15,"fbjs/lib/emptyObject":171,"fbjs/lib/invariant":178,"fbjs/lib/keyMirror":181,"fbjs/lib/keyOf":182,"fbjs/lib/warning":188,"object-assign":14}],52:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2013-present, 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 ReactComponent
- */
-
-'use strict';
-
-var _prodInvariant = require('./reactProdInvariant');
-
-var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
-
-var canDefineProperty = require('./canDefineProperty');
-var emptyObject = require('fbjs/lib/emptyObject');
-var invariant = require('fbjs/lib/invariant');
-var warning = require('fbjs/lib/warning');
-
-/**
- * Base class helpers for the updating state of a component.
- */
-function ReactComponent(props, context, updater) {
- this.props = props;
- this.context = context;
- this.refs = emptyObject;
- // We initialize the default updater but the real one gets injected by the
- // renderer.
- this.updater = updater || ReactNoopUpdateQueue;
-}
-
-ReactComponent.prototype.isReactComponent = {};
-
-/**
- * Sets a subset of the state. Always use this to mutate
- * state. You should treat `this.state` as immutable.
- *
- * There is no guarantee that `this.state` will be immediately updated, so
- * accessing `this.state` after calling this method may return the old value.
- *
- * There is no guarantee that calls to `setState` will run synchronously,
- * as they may eventually be batched together. You can provide an optional
- * callback that will be executed when the call to setState is actually
- * completed.
- *
- * When a function is provided to setState, it will be called at some point in
- * the future (not synchronously). It will be called with the up to date
- * component arguments (state, props, context). These values can be different
- * from this.* because your function may be called after receiveProps but before
- * shouldComponentUpdate, and this new state, props, and context will not yet be
- * assigned to this.
- *
- * @param {object|function} partialState Next partial state or function to
- * produce next partial state to be merged with current state.
- * @param {?function} callback Called after state is updated.
- * @final
- * @protected
- */
-ReactComponent.prototype.setState = function (partialState, callback) {
- !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : _prodInvariant('85') : void 0;
- this.updater.enqueueSetState(this, partialState);
- if (callback) {
- this.updater.enqueueCallback(this, callback, 'setState');
- }
-};
-
-/**
- * Forces an update. This should only be invoked when it is known with
- * certainty that we are **not** in a DOM transaction.
- *
- * You may want to call this when you know that some deeper aspect of the
- * component's state has changed but `setState` was not called.
- *
- * This will not invoke `shouldComponentUpdate`, but it will invoke
- * `componentWillUpdate` and `componentDidUpdate`.
- *
- * @param {?function} callback Called after update is complete.
- * @final
- * @protected
- */
-ReactComponent.prototype.forceUpdate = function (callback) {
- this.updater.enqueueForceUpdate(this);
- if (callback) {
- this.updater.enqueueCallback(this, callback, 'forceUpdate');
- }
-};
-
-/**
- * Deprecated APIs. These APIs used to exist on classic React classes but since
- * we would like to deprecate them, we're not going to move them over to this
- * modern base class. Instead, we define a getter that warns if it's accessed.
- */
-if (process.env.NODE_ENV !== 'production') {
- var deprecatedAPIs = {
- isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
- replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
- };
- var defineDeprecationWarning = function (methodName, info) {
- if (canDefineProperty) {
- Object.defineProperty(ReactComponent.prototype, methodName, {
- get: function () {
- process.env.NODE_ENV !== 'production' ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) : void 0;
- return undefined;
- }
- });
- }
- };
- for (var fnName in deprecatedAPIs) {
- if (deprecatedAPIs.hasOwnProperty(fnName)) {
- defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
- }
- }
-}
-
-module.exports = ReactComponent;
-}).call(this,require('_process'))
-
-},{"./ReactNoopUpdateQueue":101,"./canDefineProperty":134,"./reactProdInvariant":156,"_process":15,"fbjs/lib/emptyObject":171,"fbjs/lib/invariant":178,"fbjs/lib/warning":188}],53:[function(require,module,exports){
+},{"./KeyEscapeUtils":65,"./ReactReconciler":115,"./instantiateReactComponent":159,"./shouldUpdateReactComponent":167,"./traverseAllChildren":168,"_process":43,"fbjs/lib/warning":25,"react/lib/ReactComponentTreeHook":191}],70:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -16605,7 +16778,6 @@ module.exports = ReactComponent;
* 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
*/
'use strict';
@@ -16622,21 +16794,12 @@ var ReactComponentBrowserEnvironment = {
processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
- replaceNodeWithMarkup: DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup,
-
- /**
- * If a particular environment requires that some resources be cleaned up,
- * specify this in the injected Mixin. In the DOM, we would likely want to
- * purge any cached node ID lookups.
- *
- * @private
- */
- unmountIDFromEnvironment: function (rootNodeID) {}
+ replaceNodeWithMarkup: DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup
};
module.exports = ReactComponentBrowserEnvironment;
-},{"./DOMChildrenOperations":28,"./ReactDOMIDOperations":68}],54:[function(require,module,exports){
+},{"./DOMChildrenOperations":51,"./ReactDOMIDOperations":80}],71:[function(require,module,exports){
(function (process){
/**
* Copyright 2014-present, Facebook, Inc.
@@ -16646,7 +16809,7 @@ module.exports = ReactComponentBrowserEnvironment;
* 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 ReactComponentEnvironment
+ *
*/
'use strict';
@@ -16660,13 +16823,6 @@ var injected = false;
var ReactComponentEnvironment = {
/**
- * Optionally injectable environment dependent cleanup hook. (server vs.
- * browser etc). Example: A browser system caches DOM nodes based on component
- * ID and must remove that cache entry when this instance is unmounted.
- */
- unmountIDFromEnvironment: null,
-
- /**
* Optionally injectable hook for swapping out mount images in the middle of
* the tree.
*/
@@ -16681,7 +16837,6 @@ var ReactComponentEnvironment = {
injection: {
injectEnvironment: function (environment) {
!!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : _prodInvariant('104') : void 0;
- ReactComponentEnvironment.unmountIDFromEnvironment = environment.unmountIDFromEnvironment;
ReactComponentEnvironment.replaceNodeWithMarkup = environment.replaceNodeWithMarkup;
ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
injected = true;
@@ -16693,229 +16848,7 @@ var ReactComponentEnvironment = {
module.exports = ReactComponentEnvironment;
}).call(this,require('_process'))
-},{"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],55:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2016-present, 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 ReactComponentTreeDevtool
- */
-
-'use strict';
-
-var _prodInvariant = require('./reactProdInvariant');
-
-var ReactCurrentOwner = require('./ReactCurrentOwner');
-
-var invariant = require('fbjs/lib/invariant');
-var warning = require('fbjs/lib/warning');
-
-var tree = {};
-var unmountedIDs = {};
-var rootIDs = {};
-
-function updateTree(id, update) {
- if (!tree[id]) {
- tree[id] = {
- element: null,
- parentID: null,
- ownerID: null,
- text: null,
- childIDs: [],
- displayName: 'Unknown',
- isMounted: false,
- updateCount: 0
- };
- }
- update(tree[id]);
-}
-
-function purgeDeep(id) {
- var item = tree[id];
- if (item) {
- var childIDs = item.childIDs;
-
- delete tree[id];
- childIDs.forEach(purgeDeep);
- }
-}
-
-function describeComponentFrame(name, source, ownerName) {
- return '\n in ' + name + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
-}
-
-function describeID(id) {
- var name = ReactComponentTreeDevtool.getDisplayName(id);
- var element = ReactComponentTreeDevtool.getElement(id);
- var ownerID = ReactComponentTreeDevtool.getOwnerID(id);
- var ownerName;
- if (ownerID) {
- ownerName = ReactComponentTreeDevtool.getDisplayName(ownerID);
- }
- process.env.NODE_ENV !== 'production' ? warning(element, 'ReactComponentTreeDevtool: Missing React element for debugID %s when ' + 'building stack', id) : void 0;
- return describeComponentFrame(name, element && element._source, ownerName);
-}
-
-var ReactComponentTreeDevtool = {
- onSetDisplayName: function (id, displayName) {
- updateTree(id, function (item) {
- return item.displayName = displayName;
- });
- },
- onSetChildren: function (id, nextChildIDs) {
- updateTree(id, function (item) {
- item.childIDs = nextChildIDs;
-
- nextChildIDs.forEach(function (nextChildID) {
- var nextChild = tree[nextChildID];
- !nextChild ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected devtool events to fire for the child before its parent includes it in onSetChildren().') : _prodInvariant('68') : void 0;
- !(nextChild.displayName != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onSetDisplayName() to fire for the child before its parent includes it in onSetChildren().') : _prodInvariant('69') : void 0;
- !(nextChild.childIDs != null || nextChild.text != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onSetChildren() or onSetText() to fire for the child before its parent includes it in onSetChildren().') : _prodInvariant('70') : void 0;
- !nextChild.isMounted ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onMountComponent() to fire for the child before its parent includes it in onSetChildren().') : _prodInvariant('71') : void 0;
- if (nextChild.parentID == null) {
- nextChild.parentID = id;
- // TODO: This shouldn't be necessary but mounting a new root during in
- // componentWillMount currently causes not-yet-mounted components to
- // be purged from our tree data so their parent ID is missing.
- }
- !(nextChild.parentID === id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onSetParent() and onSetChildren() to be consistent (%s has parents %s and %s).', nextChildID, nextChild.parentID, id) : _prodInvariant('72', nextChildID, nextChild.parentID, id) : void 0;
- });
- });
- },
- onSetOwner: function (id, ownerID) {
- updateTree(id, function (item) {
- return item.ownerID = ownerID;
- });
- },
- onSetParent: function (id, parentID) {
- updateTree(id, function (item) {
- return item.parentID = parentID;
- });
- },
- onSetText: function (id, text) {
- updateTree(id, function (item) {
- return item.text = text;
- });
- },
- onBeforeMountComponent: function (id, element) {
- updateTree(id, function (item) {
- return item.element = element;
- });
- },
- onBeforeUpdateComponent: function (id, element) {
- updateTree(id, function (item) {
- return item.element = element;
- });
- },
- onMountComponent: function (id) {
- updateTree(id, function (item) {
- return item.isMounted = true;
- });
- },
- onMountRootComponent: function (id) {
- rootIDs[id] = true;
- },
- onUpdateComponent: function (id) {
- updateTree(id, function (item) {
- return item.updateCount++;
- });
- },
- onUnmountComponent: function (id) {
- updateTree(id, function (item) {
- return item.isMounted = false;
- });
- unmountedIDs[id] = true;
- delete rootIDs[id];
- },
- purgeUnmountedComponents: function () {
- if (ReactComponentTreeDevtool._preventPurging) {
- // Should only be used for testing.
- return;
- }
-
- for (var id in unmountedIDs) {
- purgeDeep(id);
- }
- unmountedIDs = {};
- },
- isMounted: function (id) {
- var item = tree[id];
- return item ? item.isMounted : false;
- },
- getCurrentStackAddendum: function (topElement) {
- var info = '';
- if (topElement) {
- var type = topElement.type;
- var name = typeof type === 'function' ? type.displayName || type.name : type;
- var owner = topElement._owner;
- info += describeComponentFrame(name || 'Unknown', topElement._source, owner && owner.getName());
- }
-
- var currentOwner = ReactCurrentOwner.current;
- var id = currentOwner && currentOwner._debugID;
-
- info += ReactComponentTreeDevtool.getStackAddendumByID(id);
- return info;
- },
- getStackAddendumByID: function (id) {
- var info = '';
- while (id) {
- info += describeID(id);
- id = ReactComponentTreeDevtool.getParentID(id);
- }
- return info;
- },
- getChildIDs: function (id) {
- var item = tree[id];
- return item ? item.childIDs : [];
- },
- getDisplayName: function (id) {
- var item = tree[id];
- return item ? item.displayName : 'Unknown';
- },
- getElement: function (id) {
- var item = tree[id];
- return item ? item.element : null;
- },
- getOwnerID: function (id) {
- var item = tree[id];
- return item ? item.ownerID : null;
- },
- getParentID: function (id) {
- var item = tree[id];
- return item ? item.parentID : null;
- },
- getSource: function (id) {
- var item = tree[id];
- var element = item ? item.element : null;
- var source = element != null ? element._source : null;
- return source;
- },
- getText: function (id) {
- var item = tree[id];
- return item ? item.text : null;
- },
- getUpdateCount: function (id) {
- var item = tree[id];
- return item ? item.updateCount : 0;
- },
- getRootIDs: function () {
- return Object.keys(rootIDs);
- },
- getRegisteredIDs: function () {
- return Object.keys(tree);
- }
-};
-
-module.exports = ReactComponentTreeDevtool;
-}).call(this,require('_process'))
-
-},{"./ReactCurrentOwner":57,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"fbjs/lib/warning":188}],56:[function(require,module,exports){
+},{"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],72:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -16925,7 +16858,6 @@ module.exports = ReactComponentTreeDevtool;
* 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
*/
'use strict';
@@ -16933,23 +16865,31 @@ module.exports = ReactComponentTreeDevtool;
var _prodInvariant = require('./reactProdInvariant'),
_assign = require('object-assign');
+var React = require('react/lib/React');
var ReactComponentEnvironment = require('./ReactComponentEnvironment');
-var ReactCurrentOwner = require('./ReactCurrentOwner');
-var ReactElement = require('./ReactElement');
+var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
var ReactErrorUtils = require('./ReactErrorUtils');
var ReactInstanceMap = require('./ReactInstanceMap');
var ReactInstrumentation = require('./ReactInstrumentation');
var ReactNodeTypes = require('./ReactNodeTypes');
-var ReactPropTypeLocations = require('./ReactPropTypeLocations');
var ReactReconciler = require('./ReactReconciler');
-var checkReactTypeSpec = require('./checkReactTypeSpec');
+if (process.env.NODE_ENV !== 'production') {
+ var checkReactTypeSpec = require('./checkReactTypeSpec');
+}
var emptyObject = require('fbjs/lib/emptyObject');
var invariant = require('fbjs/lib/invariant');
+var shallowEqual = require('fbjs/lib/shallowEqual');
var shouldUpdateReactComponent = require('./shouldUpdateReactComponent');
var warning = require('fbjs/lib/warning');
+var CompositeTypes = {
+ ImpureClass: 0,
+ PureClass: 1,
+ StatelessFunctional: 2
+};
+
function StatelessComponent(Component) {}
StatelessComponent.prototype.render = function () {
var Component = ReactInstanceMap.get(this)._currentElement.type;
@@ -16960,35 +16900,34 @@ StatelessComponent.prototype.render = function () {
function warnIfInvalidElement(Component, element) {
if (process.env.NODE_ENV !== 'production') {
- process.env.NODE_ENV !== 'production' ? warning(element === null || element === false || ReactElement.isValidElement(element), '%s(...): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component') : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(element === null || element === false || React.isValidElement(element), '%s(...): A valid React element (or null) must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component') : void 0;
process.env.NODE_ENV !== 'production' ? warning(!Component.childContextTypes, '%s(...): childContextTypes cannot be defined on a functional component.', Component.displayName || Component.name || 'Component') : void 0;
}
}
-function invokeComponentDidMountWithTimer() {
- var publicInstance = this._instance;
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginLifeCycleTimer(this._debugID, 'componentDidMount');
- }
- publicInstance.componentDidMount();
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndLifeCycleTimer(this._debugID, 'componentDidMount');
- }
+function shouldConstruct(Component) {
+ return !!(Component.prototype && Component.prototype.isReactComponent);
}
-function invokeComponentDidUpdateWithTimer(prevProps, prevState, prevContext) {
- var publicInstance = this._instance;
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginLifeCycleTimer(this._debugID, 'componentDidUpdate');
- }
- publicInstance.componentDidUpdate(prevProps, prevState, prevContext);
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndLifeCycleTimer(this._debugID, 'componentDidUpdate');
- }
+function isPureComponent(Component) {
+ return !!(Component.prototype && Component.prototype.isPureReactComponent);
}
-function shouldConstruct(Component) {
- return Component.prototype && Component.prototype.isReactComponent;
+// Separated into a function to contain deoptimizations caused by try/finally.
+function measureLifeCyclePerf(fn, debugID, timerType) {
+ if (debugID === 0) {
+ // Top-level wrappers (see ReactMount) and empty components (see
+ // ReactDOMEmptyComponent) are invisible to hooks and devtools.
+ // Both are implementation details that should go away in the future.
+ return fn();
+ }
+
+ ReactInstrumentation.debugTool.onBeginLifeCycleTimer(debugID, timerType);
+ try {
+ return fn();
+ } finally {
+ ReactInstrumentation.debugTool.onEndLifeCycleTimer(debugID, timerType);
+ }
}
/**
@@ -17029,7 +16968,7 @@ var nextMountID = 1;
/**
* @lends {ReactCompositeComponent.prototype}
*/
-var ReactCompositeComponentMixin = {
+var ReactCompositeComponent = {
/**
* Base constructor for all composite component.
@@ -17040,7 +16979,8 @@ var ReactCompositeComponentMixin = {
*/
construct: function (element) {
this._currentElement = element;
- this._rootNodeID = null;
+ this._rootNodeID = 0;
+ this._compositeType = null;
this._instance = null;
this._hostParent = null;
this._hostContainerInfo = null;
@@ -17081,6 +17021,8 @@ var ReactCompositeComponentMixin = {
* @internal
*/
mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
+ var _this = this;
+
this._context = context;
this._mountOrder = nextMountID++;
this._hostParent = hostParent;
@@ -17094,15 +17036,23 @@ var ReactCompositeComponentMixin = {
var updateQueue = transaction.getUpdateQueue();
// Initialize the public class
- var inst = this._constructComponent(publicProps, publicContext, updateQueue);
+ var doConstruct = shouldConstruct(Component);
+ var inst = this._constructComponent(doConstruct, publicProps, publicContext, updateQueue);
var renderedElement;
// Support functional components
- if (!shouldConstruct(Component) && (inst == null || inst.render == null)) {
+ if (!doConstruct && (inst == null || inst.render == null)) {
renderedElement = inst;
warnIfInvalidElement(Component, renderedElement);
- !(inst === null || inst === false || ReactElement.isValidElement(inst)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component') : _prodInvariant('105', Component.displayName || Component.name || 'Component') : void 0;
+ !(inst === null || inst === false || React.isValidElement(inst)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s(...): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.', Component.displayName || Component.name || 'Component') : _prodInvariant('105', Component.displayName || Component.name || 'Component') : void 0;
inst = new StatelessComponent(Component);
+ this._compositeType = CompositeTypes.StatelessFunctional;
+ } else {
+ if (isPureComponent(Component)) {
+ this._compositeType = CompositeTypes.PureClass;
+ } else {
+ this._compositeType = CompositeTypes.ImpureClass;
+ }
}
if (process.env.NODE_ENV !== 'production') {
@@ -17134,7 +17084,7 @@ var ReactCompositeComponentMixin = {
// Since plain JS classes are defined without any special initialization
// logic, we can not catch common errors early. Therefore, we have to
// catch them here, at initialization time, instead.
- process.env.NODE_ENV !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved || inst.state, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : void 0;
process.env.NODE_ENV !== 'production' ? warning(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component') : void 0;
process.env.NODE_ENV !== 'production' ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : void 0;
process.env.NODE_ENV !== 'production' ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : void 0;
@@ -17162,7 +17112,11 @@ var ReactCompositeComponentMixin = {
if (inst.componentDidMount) {
if (process.env.NODE_ENV !== 'production') {
- transaction.getReactMountReady().enqueue(invokeComponentDidMountWithTimer, this);
+ transaction.getReactMountReady().enqueue(function () {
+ measureLifeCyclePerf(function () {
+ return inst.componentDidMount();
+ }, _this._debugID, 'componentDidMount');
+ });
} else {
transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
}
@@ -17171,50 +17125,41 @@ var ReactCompositeComponentMixin = {
return markup;
},
- _constructComponent: function (publicProps, publicContext, updateQueue) {
+ _constructComponent: function (doConstruct, publicProps, publicContext, updateQueue) {
if (process.env.NODE_ENV !== 'production') {
ReactCurrentOwner.current = this;
try {
- return this._constructComponentWithoutOwner(publicProps, publicContext, updateQueue);
+ return this._constructComponentWithoutOwner(doConstruct, publicProps, publicContext, updateQueue);
} finally {
ReactCurrentOwner.current = null;
}
} else {
- return this._constructComponentWithoutOwner(publicProps, publicContext, updateQueue);
+ return this._constructComponentWithoutOwner(doConstruct, publicProps, publicContext, updateQueue);
}
},
- _constructComponentWithoutOwner: function (publicProps, publicContext, updateQueue) {
+ _constructComponentWithoutOwner: function (doConstruct, publicProps, publicContext, updateQueue) {
var Component = this._currentElement.type;
- var instanceOrElement;
- if (shouldConstruct(Component)) {
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginLifeCycleTimer(this._debugID, 'ctor');
- }
- }
- instanceOrElement = new Component(publicProps, publicContext, updateQueue);
+
+ if (doConstruct) {
if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndLifeCycleTimer(this._debugID, 'ctor');
- }
+ return measureLifeCyclePerf(function () {
+ return new Component(publicProps, publicContext, updateQueue);
+ }, this._debugID, 'ctor');
+ } else {
+ return new Component(publicProps, publicContext, updateQueue);
}
+ }
+
+ // This can still be an instance in case of factory components
+ // but we'll count this as time spent rendering as the more common case.
+ if (process.env.NODE_ENV !== 'production') {
+ return measureLifeCyclePerf(function () {
+ return Component(publicProps, publicContext, updateQueue);
+ }, this._debugID, 'render');
} else {
- // This can still be an instance in case of factory components
- // but we'll count this as time spent rendering as the more common case.
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginLifeCycleTimer(this._debugID, 'render');
- }
- }
- instanceOrElement = Component(publicProps, publicContext, updateQueue);
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndLifeCycleTimer(this._debugID, 'render');
- }
- }
+ return Component(publicProps, publicContext, updateQueue);
}
- return instanceOrElement;
},
performInitialMountWithErrorHandling: function (renderedElement, hostParent, hostContainerInfo, transaction, context) {
@@ -17223,11 +17168,6 @@ var ReactCompositeComponentMixin = {
try {
markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
} catch (e) {
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onError();
- }
- }
// Roll back to checkpoint, handle error (which may add items to the transaction), and take a new checkpoint
transaction.rollback(checkpoint);
this._instance.unstable_handleError(e);
@@ -17248,17 +17188,19 @@ var ReactCompositeComponentMixin = {
performInitialMount: function (renderedElement, hostParent, hostContainerInfo, transaction, context) {
var inst = this._instance;
+
+ var debugID = 0;
+ if (process.env.NODE_ENV !== 'production') {
+ debugID = this._debugID;
+ }
+
if (inst.componentWillMount) {
if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginLifeCycleTimer(this._debugID, 'componentWillMount');
- }
- }
- inst.componentWillMount();
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndLifeCycleTimer(this._debugID, 'componentWillMount');
- }
+ measureLifeCyclePerf(function () {
+ return inst.componentWillMount();
+ }, debugID, 'componentWillMount');
+ } else {
+ inst.componentWillMount();
}
// When mounting, calls to `setState` by `componentWillMount` will set
// `this._pendingStateQueue` without triggering a re-render.
@@ -17277,17 +17219,13 @@ var ReactCompositeComponentMixin = {
var child = this._instantiateReactComponent(renderedElement, nodeType !== ReactNodeTypes.EMPTY /* shouldHaveDebugID */
);
this._renderedComponent = child;
- if (process.env.NODE_ENV !== 'production') {
- if (child._debugID !== 0 && this._debugID !== 0) {
- ReactInstrumentation.debugTool.onSetParent(child._debugID, this._debugID);
- }
- }
- var markup = ReactReconciler.mountComponent(child, transaction, hostParent, hostContainerInfo, this._processChildContext(context));
+ var markup = ReactReconciler.mountComponent(child, transaction, hostParent, hostContainerInfo, this._processChildContext(context), debugID);
if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onSetChildren(this._debugID, child._debugID !== 0 ? [child._debugID] : []);
+ if (debugID !== 0) {
+ var childDebugIDs = child._debugID !== 0 ? [child._debugID] : [];
+ ReactInstrumentation.debugTool.onSetChildren(debugID, childDebugIDs);
}
}
@@ -17308,24 +17246,22 @@ var ReactCompositeComponentMixin = {
if (!this._renderedComponent) {
return;
}
+
var inst = this._instance;
if (inst.componentWillUnmount && !inst._calledComponentWillUnmount) {
inst._calledComponentWillUnmount = true;
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginLifeCycleTimer(this._debugID, 'componentWillUnmount');
- }
- }
+
if (safely) {
var name = this.getName() + '.componentWillUnmount()';
ReactErrorUtils.invokeGuardedCallback(name, inst.componentWillUnmount.bind(inst));
} else {
- inst.componentWillUnmount();
- }
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndLifeCycleTimer(this._debugID, 'componentWillUnmount');
+ if (process.env.NODE_ENV !== 'production') {
+ measureLifeCyclePerf(function () {
+ return inst.componentWillUnmount();
+ }, this._debugID, 'componentWillUnmount');
+ } else {
+ inst.componentWillUnmount();
}
}
}
@@ -17349,7 +17285,7 @@ var ReactCompositeComponentMixin = {
// These fields do not really need to be reset since this object is no
// longer accessible.
this._context = null;
- this._rootNodeID = null;
+ this._rootNodeID = 0;
this._topLevelWrapper = null;
// Delete the reference from the instance to this internal representation
@@ -17398,7 +17334,7 @@ var ReactCompositeComponentMixin = {
if (process.env.NODE_ENV !== 'production') {
var Component = this._currentElement.type;
if (Component.contextTypes) {
- this._checkContextTypes(Component.contextTypes, maskedContext, ReactPropTypeLocations.context);
+ this._checkContextTypes(Component.contextTypes, maskedContext, 'context');
}
}
return maskedContext;
@@ -17412,17 +17348,25 @@ var ReactCompositeComponentMixin = {
_processChildContext: function (currentContext) {
var Component = this._currentElement.type;
var inst = this._instance;
- if (process.env.NODE_ENV !== 'production') {
- ReactInstrumentation.debugTool.onBeginProcessingChildContext();
- }
- var childContext = inst.getChildContext && inst.getChildContext();
- if (process.env.NODE_ENV !== 'production') {
- ReactInstrumentation.debugTool.onEndProcessingChildContext();
+ var childContext;
+
+ if (inst.getChildContext) {
+ if (process.env.NODE_ENV !== 'production') {
+ ReactInstrumentation.debugTool.onBeginProcessingChildContext();
+ try {
+ childContext = inst.getChildContext();
+ } finally {
+ ReactInstrumentation.debugTool.onEndProcessingChildContext();
+ }
+ } else {
+ childContext = inst.getChildContext();
+ }
}
+
if (childContext) {
!(typeof Component.childContextTypes === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().', this.getName() || 'ReactCompositeComponent') : _prodInvariant('107', this.getName() || 'ReactCompositeComponent') : void 0;
if (process.env.NODE_ENV !== 'production') {
- this._checkContextTypes(Component.childContextTypes, childContext, ReactPropTypeLocations.childContext);
+ this._checkContextTypes(Component.childContextTypes, childContext, 'childContext');
}
for (var name in childContext) {
!(name in Component.childContextTypes) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : _prodInvariant('108', this.getName() || 'ReactCompositeComponent', name) : void 0;
@@ -17441,7 +17385,9 @@ var ReactCompositeComponentMixin = {
* @private
*/
_checkContextTypes: function (typeSpecs, values, location) {
- checkReactTypeSpec(typeSpecs, values, location, this.getName(), null, this._debugID);
+ if (process.env.NODE_ENV !== 'production') {
+ checkReactTypeSpec(typeSpecs, values, location, this.getName(), null, this._debugID);
+ }
},
receiveComponent: function (nextElement, transaction, nextContext) {
@@ -17491,7 +17437,6 @@ var ReactCompositeComponentMixin = {
var willReceive = false;
var nextContext;
- var nextProps;
// Determine if the context has changed or not
if (this._context === nextUnmaskedContext) {
@@ -17501,7 +17446,8 @@ var ReactCompositeComponentMixin = {
willReceive = true;
}
- nextProps = nextParentElement.props;
+ var prevProps = prevParentElement.props;
+ var nextProps = nextParentElement.props;
// Not a simple state update but a props update
if (prevParentElement !== nextParentElement) {
@@ -17513,31 +17459,29 @@ var ReactCompositeComponentMixin = {
// immediately reconciled instead of waiting for the next batch.
if (willReceive && inst.componentWillReceiveProps) {
if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginLifeCycleTimer(this._debugID, 'componentWillReceiveProps');
- }
- }
- inst.componentWillReceiveProps(nextProps, nextContext);
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndLifeCycleTimer(this._debugID, 'componentWillReceiveProps');
- }
+ measureLifeCyclePerf(function () {
+ return inst.componentWillReceiveProps(nextProps, nextContext);
+ }, this._debugID, 'componentWillReceiveProps');
+ } else {
+ inst.componentWillReceiveProps(nextProps, nextContext);
}
}
var nextState = this._processPendingState(nextProps, nextContext);
var shouldUpdate = true;
- if (!this._pendingForceUpdate && inst.shouldComponentUpdate) {
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginLifeCycleTimer(this._debugID, 'shouldComponentUpdate');
+ if (!this._pendingForceUpdate) {
+ if (inst.shouldComponentUpdate) {
+ if (process.env.NODE_ENV !== 'production') {
+ shouldUpdate = measureLifeCyclePerf(function () {
+ return inst.shouldComponentUpdate(nextProps, nextState, nextContext);
+ }, this._debugID, 'shouldComponentUpdate');
+ } else {
+ shouldUpdate = inst.shouldComponentUpdate(nextProps, nextState, nextContext);
}
- }
- shouldUpdate = inst.shouldComponentUpdate(nextProps, nextState, nextContext);
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndLifeCycleTimer(this._debugID, 'shouldComponentUpdate');
+ } else {
+ if (this._compositeType === CompositeTypes.PureClass) {
+ shouldUpdate = !shallowEqual(prevProps, nextProps) || !shallowEqual(inst.state, nextState);
}
}
}
@@ -17599,6 +17543,8 @@ var ReactCompositeComponentMixin = {
* @private
*/
_performComponentUpdate: function (nextElement, nextProps, nextState, nextContext, transaction, unmaskedContext) {
+ var _this2 = this;
+
var inst = this._instance;
var hasComponentDidUpdate = Boolean(inst.componentDidUpdate);
@@ -17613,15 +17559,11 @@ var ReactCompositeComponentMixin = {
if (inst.componentWillUpdate) {
if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginLifeCycleTimer(this._debugID, 'componentWillUpdate');
- }
- }
- inst.componentWillUpdate(nextProps, nextState, nextContext);
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndLifeCycleTimer(this._debugID, 'componentWillUpdate');
- }
+ measureLifeCyclePerf(function () {
+ return inst.componentWillUpdate(nextProps, nextState, nextContext);
+ }, this._debugID, 'componentWillUpdate');
+ } else {
+ inst.componentWillUpdate(nextProps, nextState, nextContext);
}
}
@@ -17635,7 +17577,9 @@ var ReactCompositeComponentMixin = {
if (hasComponentDidUpdate) {
if (process.env.NODE_ENV !== 'production') {
- transaction.getReactMountReady().enqueue(invokeComponentDidUpdateWithTimer.bind(this, prevProps, prevState, prevContext), this);
+ transaction.getReactMountReady().enqueue(function () {
+ measureLifeCyclePerf(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), _this2._debugID, 'componentDidUpdate');
+ });
} else {
transaction.getReactMountReady().enqueue(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), inst);
}
@@ -17652,6 +17596,12 @@ var ReactCompositeComponentMixin = {
var prevComponentInstance = this._renderedComponent;
var prevRenderedElement = prevComponentInstance._currentElement;
var nextRenderedElement = this._renderValidatedComponent();
+
+ var debugID = 0;
+ if (process.env.NODE_ENV !== 'production') {
+ debugID = this._debugID;
+ }
+
if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
ReactReconciler.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context));
} else {
@@ -17663,17 +17613,13 @@ var ReactCompositeComponentMixin = {
var child = this._instantiateReactComponent(nextRenderedElement, nodeType !== ReactNodeTypes.EMPTY /* shouldHaveDebugID */
);
this._renderedComponent = child;
- if (process.env.NODE_ENV !== 'production') {
- if (child._debugID !== 0 && this._debugID !== 0) {
- ReactInstrumentation.debugTool.onSetParent(child._debugID, this._debugID);
- }
- }
- var nextMarkup = ReactReconciler.mountComponent(child, transaction, this._hostParent, this._hostContainerInfo, this._processChildContext(context));
+ var nextMarkup = ReactReconciler.mountComponent(child, transaction, this._hostParent, this._hostContainerInfo, this._processChildContext(context), debugID);
if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onSetChildren(this._debugID, child._debugID !== 0 ? [child._debugID] : []);
+ if (debugID !== 0) {
+ var childDebugIDs = child._debugID !== 0 ? [child._debugID] : [];
+ ReactInstrumentation.debugTool.onSetChildren(debugID, childDebugIDs);
}
}
@@ -17695,47 +17641,48 @@ var ReactCompositeComponentMixin = {
*/
_renderValidatedComponentWithoutOwnerOrContext: function () {
var inst = this._instance;
+ var renderedElement;
if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginLifeCycleTimer(this._debugID, 'render');
- }
- }
- var renderedComponent = inst.render();
- if (process.env.NODE_ENV !== 'production') {
- if (this._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndLifeCycleTimer(this._debugID, 'render');
- }
+ renderedElement = measureLifeCyclePerf(function () {
+ return inst.render();
+ }, this._debugID, 'render');
+ } else {
+ renderedElement = inst.render();
}
if (process.env.NODE_ENV !== 'production') {
// We allow auto-mocks to proceed as if they're returning null.
- if (renderedComponent === undefined && inst.render._isMockFunction) {
+ if (renderedElement === undefined && inst.render._isMockFunction) {
// This is probably bad practice. Consider warning here and
// deprecating this convenience.
- renderedComponent = null;
+ renderedElement = null;
}
}
- return renderedComponent;
+ return renderedElement;
},
/**
* @private
*/
_renderValidatedComponent: function () {
- var renderedComponent;
- ReactCurrentOwner.current = this;
- try {
- renderedComponent = this._renderValidatedComponentWithoutOwnerOrContext();
- } finally {
- ReactCurrentOwner.current = null;
+ var renderedElement;
+ if (process.env.NODE_ENV !== 'production' || this._compositeType !== CompositeTypes.StatelessFunctional) {
+ ReactCurrentOwner.current = this;
+ try {
+ renderedElement = this._renderValidatedComponentWithoutOwnerOrContext();
+ } finally {
+ ReactCurrentOwner.current = null;
+ }
+ } else {
+ renderedElement = this._renderValidatedComponentWithoutOwnerOrContext();
}
!(
// TODO: An `isValidNode` function would probably be more appropriate
- renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : _prodInvariant('109', this.getName() || 'ReactCompositeComponent') : void 0;
+ renderedElement === null || renderedElement === false || React.isValidElement(renderedElement)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid React element (or null) must be returned. You may have returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : _prodInvariant('109', this.getName() || 'ReactCompositeComponent') : void 0;
- return renderedComponent;
+ return renderedElement;
},
/**
@@ -17752,7 +17699,7 @@ var ReactCompositeComponentMixin = {
var publicComponentInstance = component.getPublicInstance();
if (process.env.NODE_ENV !== 'production') {
var componentName = component && component.getName ? component.getName() : 'a component';
- process.env.NODE_ENV !== 'production' ? warning(publicComponentInstance != null, 'Stateless function components cannot be given refs ' + '(See ref "%s" in %s created by %s). ' + 'Attempts to access this ref will fail.', ref, componentName, this.getName()) : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(publicComponentInstance != null || component._compositeType !== CompositeTypes.StatelessFunctional, 'Stateless function components cannot be given refs ' + '(See ref "%s" in %s created by %s). ' + 'Attempts to access this ref will fail.', ref, componentName, this.getName()) : void 0;
}
var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs;
refs[ref] = publicComponentInstance;
@@ -17792,7 +17739,7 @@ var ReactCompositeComponentMixin = {
*/
getPublicInstance: function () {
var inst = this._instance;
- if (inst instanceof StatelessComponent) {
+ if (this._compositeType === CompositeTypes.StatelessFunctional) {
return null;
}
return inst;
@@ -17803,48 +17750,10 @@ var ReactCompositeComponentMixin = {
};
-var ReactCompositeComponent = {
-
- Mixin: ReactCompositeComponentMixin
-
-};
-
module.exports = ReactCompositeComponent;
}).call(this,require('_process'))
-},{"./ReactComponentEnvironment":54,"./ReactCurrentOwner":57,"./ReactElement":82,"./ReactErrorUtils":85,"./ReactInstanceMap":93,"./ReactInstrumentation":94,"./ReactNodeTypes":100,"./ReactPropTypeLocations":104,"./ReactReconciler":107,"./checkReactTypeSpec":135,"./reactProdInvariant":156,"./shouldUpdateReactComponent":160,"_process":15,"fbjs/lib/emptyObject":171,"fbjs/lib/invariant":178,"fbjs/lib/warning":188,"object-assign":14}],57:[function(require,module,exports){
-/**
- * Copyright 2013-present, 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 ReactCurrentOwner
- */
-
-'use strict';
-
-/**
- * Keeps track of the current owner.
- *
- * The current owner is the component who should own any components that are
- * currently being constructed.
- */
-
-var ReactCurrentOwner = {
-
- /**
- * @internal
- * @type {ReactComponent}
- */
- current: null
-
-};
-
-module.exports = ReactCurrentOwner;
-},{}],58:[function(require,module,exports){
+},{"./ReactComponentEnvironment":71,"./ReactErrorUtils":96,"./ReactInstanceMap":104,"./ReactInstrumentation":105,"./ReactNodeTypes":110,"./ReactReconciler":115,"./checkReactTypeSpec":142,"./reactProdInvariant":163,"./shouldUpdateReactComponent":167,"_process":43,"fbjs/lib/emptyObject":11,"fbjs/lib/invariant":18,"fbjs/lib/shallowEqual":24,"fbjs/lib/warning":25,"object-assign":170,"react/lib/React":187,"react/lib/ReactCurrentOwner":192}],73:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -17854,7 +17763,6 @@ module.exports = ReactCurrentOwner;
* 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
*/
/* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/
@@ -17875,7 +17783,7 @@ var warning = require('fbjs/lib/warning');
ReactDefaultInjection.inject();
-var React = {
+var ReactDOM = {
findDOMNode: findDOMNode,
render: ReactMount.render,
unmountComponentAtNode: ReactMount.unmountComponentAtNode,
@@ -17888,7 +17796,6 @@ var React = {
// Inject the runtime into a devtools global hook regardless of browser.
// Allows for debugging when the hook is injected on the page.
-/* eslint-enable camelcase */
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
ComponentTree: {
@@ -17935,7 +17842,7 @@ if (process.env.NODE_ENV !== 'production') {
var expectedFeatures = [
// shims
- Array.isArray, Array.prototype.every, Array.prototype.forEach, Array.prototype.indexOf, Array.prototype.map, Date.now, Function.prototype.bind, Object.keys, String.prototype.split, String.prototype.trim];
+ Array.isArray, Array.prototype.every, Array.prototype.forEach, Array.prototype.indexOf, Array.prototype.map, Date.now, Function.prototype.bind, Object.keys, String.prototype.trim];
for (var i = 0; i < expectedFeatures.length; i++) {
if (!expectedFeatures[i]) {
@@ -17946,35 +17853,21 @@ if (process.env.NODE_ENV !== 'production') {
}
}
-module.exports = React;
-}).call(this,require('_process'))
-
-},{"./ReactDOMComponentTree":62,"./ReactDefaultInjection":81,"./ReactMount":97,"./ReactReconciler":107,"./ReactUpdates":112,"./ReactVersion":113,"./findDOMNode":139,"./getHostComponentFromComposite":146,"./renderSubtreeIntoContainer":157,"_process":15,"fbjs/lib/ExecutionEnvironment":164,"fbjs/lib/warning":188}],59:[function(require,module,exports){
-/**
- * Copyright 2013-present, 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 ReactDOMButton
- */
-
-'use strict';
+if (process.env.NODE_ENV !== 'production') {
+ var ReactInstrumentation = require('./ReactInstrumentation');
+ var ReactDOMUnknownPropertyHook = require('./ReactDOMUnknownPropertyHook');
+ var ReactDOMNullInputValuePropHook = require('./ReactDOMNullInputValuePropHook');
+ var ReactDOMInvalidARIAHook = require('./ReactDOMInvalidARIAHook');
-var DisabledInputUtils = require('./DisabledInputUtils');
+ ReactInstrumentation.debugTool.addHook(ReactDOMUnknownPropertyHook);
+ ReactInstrumentation.debugTool.addHook(ReactDOMNullInputValuePropHook);
+ ReactInstrumentation.debugTool.addHook(ReactDOMInvalidARIAHook);
+}
-/**
- * Implements a <button> host component that does not receive mouse events
- * when `disabled` is set.
- */
-var ReactDOMButton = {
- getHostProps: DisabledInputUtils.getHostProps
-};
+module.exports = ReactDOM;
+}).call(this,require('_process'))
-module.exports = ReactDOMButton;
-},{"./DisabledInputUtils":35}],60:[function(require,module,exports){
+},{"./ReactDOMComponentTree":76,"./ReactDOMInvalidARIAHook":82,"./ReactDOMNullInputValuePropHook":83,"./ReactDOMUnknownPropertyHook":90,"./ReactDefaultInjection":93,"./ReactInstrumentation":105,"./ReactMount":108,"./ReactReconciler":115,"./ReactUpdates":120,"./ReactVersion":121,"./findDOMNode":146,"./getHostComponentFromComposite":153,"./renderSubtreeIntoContainer":164,"_process":43,"fbjs/lib/ExecutionEnvironment":4,"fbjs/lib/warning":25}],74:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -17984,7 +17877,6 @@ module.exports = ReactDOMButton;
* 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
*/
/* global hasOwnProperty:true */
@@ -18000,12 +17892,9 @@ var DOMLazyTree = require('./DOMLazyTree');
var DOMNamespaces = require('./DOMNamespaces');
var DOMProperty = require('./DOMProperty');
var DOMPropertyOperations = require('./DOMPropertyOperations');
-var EventConstants = require('./EventConstants');
var EventPluginHub = require('./EventPluginHub');
var EventPluginRegistry = require('./EventPluginRegistry');
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
-var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
-var ReactDOMButton = require('./ReactDOMButton');
var ReactDOMComponentFlags = require('./ReactDOMComponentFlags');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
var ReactDOMInput = require('./ReactDOMInput');
@@ -18020,7 +17909,6 @@ var emptyFunction = require('fbjs/lib/emptyFunction');
var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
var invariant = require('fbjs/lib/invariant');
var isEventSupported = require('./isEventSupported');
-var keyOf = require('fbjs/lib/keyOf');
var shallowEqual = require('fbjs/lib/shallowEqual');
var validateDOMNesting = require('./validateDOMNesting');
var warning = require('fbjs/lib/warning');
@@ -18034,8 +17922,8 @@ var registrationNameModules = EventPluginRegistry.registrationNameModules;
// For quickly matching children type, to test if can be treated as content.
var CONTENT_TYPES = { 'string': true, 'number': true };
-var STYLE = keyOf({ style: null });
-var HTML = keyOf({ __html: null });
+var STYLE = 'style';
+var HTML = '__html';
var RESERVED_PROPS = {
children: null,
dangerouslySetInnerHTML: null,
@@ -18174,12 +18062,13 @@ function optionPostMount() {
ReactDOMOption.postMountWrapper(inst);
}
-var setContentChildForInstrumentation = emptyFunction;
+var setAndValidateContentChildDev = emptyFunction;
if (process.env.NODE_ENV !== 'production') {
- setContentChildForInstrumentation = function (content) {
+ setAndValidateContentChildDev = function (content) {
var hasExistingContent = this._contentDebugID != null;
var debugID = this._debugID;
- var contentDebugID = debugID + '#text';
+ // This ID represents the inlined child that has no backing instance:
+ var contentDebugID = -debugID;
if (content == null) {
if (hasExistingContent) {
@@ -18189,18 +18078,13 @@ if (process.env.NODE_ENV !== 'production') {
return;
}
+ validateDOMNesting(null, String(content), this, this._ancestorInfo);
this._contentDebugID = contentDebugID;
- var text = '' + content;
-
- ReactInstrumentation.debugTool.onSetDisplayName(contentDebugID, '#text');
- ReactInstrumentation.debugTool.onSetParent(contentDebugID, debugID);
- ReactInstrumentation.debugTool.onSetText(contentDebugID, text);
-
if (hasExistingContent) {
ReactInstrumentation.debugTool.onBeforeUpdateComponent(contentDebugID, content);
ReactInstrumentation.debugTool.onUpdateComponent(contentDebugID);
} else {
- ReactInstrumentation.debugTool.onBeforeMountComponent(contentDebugID, content);
+ ReactInstrumentation.debugTool.onBeforeMountComponent(contentDebugID, content, debugID);
ReactInstrumentation.debugTool.onMountComponent(contentDebugID);
ReactInstrumentation.debugTool.onSetChildren(debugID, [contentDebugID]);
}
@@ -18246,7 +18130,7 @@ function trapBubbledEventsLocal() {
switch (inst._tag) {
case 'iframe':
case 'object':
- inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)];
+ inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent('topLoad', 'load', node)];
break;
case 'video':
case 'audio':
@@ -18255,23 +18139,23 @@ function trapBubbledEventsLocal() {
// Create listener for each media event
for (var event in mediaEvents) {
if (mediaEvents.hasOwnProperty(event)) {
- inst._wrapperState.listeners.push(ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes[event], mediaEvents[event], node));
+ inst._wrapperState.listeners.push(ReactBrowserEventEmitter.trapBubbledEvent(event, mediaEvents[event], node));
}
}
break;
case 'source':
- inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error', node)];
+ inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent('topError', 'error', node)];
break;
case 'img':
- inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)];
+ inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent('topError', 'error', node), ReactBrowserEventEmitter.trapBubbledEvent('topLoad', 'load', node)];
break;
case 'form':
- inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit', node)];
+ inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent('topReset', 'reset', node), ReactBrowserEventEmitter.trapBubbledEvent('topSubmit', 'submit', node)];
break;
case 'input':
case 'select':
case 'textarea':
- inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topInvalid, 'invalid', node)];
+ inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent('topInvalid', 'invalid', node)];
break;
}
}
@@ -18301,7 +18185,6 @@ var omittedCloseTags = {
'wbr': true
};
-// NOTE: menuitem's close tag should be omitted, but that causes problems.
var newlineEatingTags = {
'listing': true,
'pre': true,
@@ -18361,15 +18244,15 @@ function ReactDOMComponent(element) {
this._previousStyleCopy = null;
this._hostNode = null;
this._hostParent = null;
- this._rootNodeID = null;
- this._domID = null;
+ this._rootNodeID = 0;
+ this._domID = 0;
this._hostContainerInfo = null;
this._wrapperState = null;
this._topLevelWrapper = null;
this._flags = 0;
if (process.env.NODE_ENV !== 'production') {
this._ancestorInfo = null;
- setContentChildForInstrumentation.call(this, null);
+ setAndValidateContentChildDev.call(this, null);
}
}
@@ -18383,7 +18266,7 @@ ReactDOMComponent.Mixin = {
*
* @internal
* @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
- * @param {?ReactDOMComponent} the containing DOM component instance
+ * @param {?ReactDOMComponent} the parent component instance
* @param {?object} info about the host container
* @param {object} context
* @return {string} The computed markup.
@@ -18410,9 +18293,6 @@ ReactDOMComponent.Mixin = {
};
transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
break;
- case 'button':
- props = ReactDOMButton.getHostProps(this, props, hostParent);
- break;
case 'input':
ReactDOMInput.mountWrapper(this, props, hostParent);
props = ReactDOMInput.getHostProps(this, props);
@@ -18469,7 +18349,7 @@ ReactDOMComponent.Mixin = {
if (parentInfo) {
// parentInfo should always be present except for the top-level
// component when server rendering
- validateDOMNesting(this._tag, this, parentInfo);
+ validateDOMNesting(this._tag, null, this, parentInfo);
}
this._ancestorInfo = validateDOMNesting.updatedAncestorInfo(parentInfo, this._tag, this);
}
@@ -18638,7 +18518,7 @@ ReactDOMComponent.Mixin = {
// TODO: Validate that text is allowed as a child of this node
ret = escapeTextContentForBrowser(contentToUse);
if (process.env.NODE_ENV !== 'production') {
- setContentChildForInstrumentation.call(this, contentToUse);
+ setAndValidateContentChildDev.call(this, contentToUse);
}
} else if (childrenToUse != null) {
var mountImages = this.mountChildren(childrenToUse, transaction, context);
@@ -18672,12 +18552,18 @@ ReactDOMComponent.Mixin = {
} else {
var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null;
var childrenToUse = contentToUse != null ? null : props.children;
+ // TODO: Validate that text is allowed as a child of this node
if (contentToUse != null) {
- // TODO: Validate that text is allowed as a child of this node
- if (process.env.NODE_ENV !== 'production') {
- setContentChildForInstrumentation.call(this, contentToUse);
+ // Avoid setting textContent when the text is empty. In IE11 setting
+ // textContent on a text area will cause the placeholder to not
+ // show within the textarea until it has been focused and blurred again.
+ // https://github.com/facebook/react/issues/6731#issuecomment-254874553
+ if (contentToUse !== '') {
+ if (process.env.NODE_ENV !== 'production') {
+ setAndValidateContentChildDev.call(this, contentToUse);
+ }
+ DOMLazyTree.queueText(lazyTree, contentToUse);
}
- DOMLazyTree.queueText(lazyTree, contentToUse);
} else if (childrenToUse != null) {
var mountImages = this.mountChildren(childrenToUse, transaction, context);
for (var i = 0; i < mountImages.length; i++) {
@@ -18716,12 +18602,7 @@ ReactDOMComponent.Mixin = {
var nextProps = this._currentElement.props;
switch (this._tag) {
- case 'button':
- lastProps = ReactDOMButton.getHostProps(this, lastProps);
- nextProps = ReactDOMButton.getHostProps(this, nextProps);
- break;
case 'input':
- ReactDOMInput.updateWrapper(this);
lastProps = ReactDOMInput.getHostProps(this, lastProps);
nextProps = ReactDOMInput.getHostProps(this, nextProps);
break;
@@ -18734,7 +18615,6 @@ ReactDOMComponent.Mixin = {
nextProps = ReactDOMSelect.getHostProps(this, nextProps);
break;
case 'textarea':
- ReactDOMTextarea.updateWrapper(this);
lastProps = ReactDOMTextarea.getHostProps(this, lastProps);
nextProps = ReactDOMTextarea.getHostProps(this, nextProps);
break;
@@ -18744,10 +18624,21 @@ ReactDOMComponent.Mixin = {
this._updateDOMProperties(lastProps, nextProps, transaction);
this._updateDOMChildren(lastProps, nextProps, transaction, context);
- if (this._tag === 'select') {
- // <select> value update needs to occur after <option> children
- // reconciliation
- transaction.getReactMountReady().enqueue(postUpdateSelectWrapper, this);
+ switch (this._tag) {
+ case 'input':
+ // Update the wrapper around inputs *after* updating props. This has to
+ // happen after `_updateDOMProperties`. Otherwise HTML5 input validations
+ // raise warnings and prevent the new value from being assigned.
+ ReactDOMInput.updateWrapper(this);
+ break;
+ case 'textarea':
+ ReactDOMTextarea.updateWrapper(this);
+ break;
+ case 'select':
+ // <select> value update needs to occur after <option> children
+ // reconciliation
+ transaction.getReactMountReady().enqueue(postUpdateSelectWrapper, this);
+ break;
}
},
@@ -18898,7 +18789,7 @@ ReactDOMComponent.Mixin = {
if (lastContent !== nextContent) {
this.updateTextContent('' + nextContent);
if (process.env.NODE_ENV !== 'production') {
- setContentChildForInstrumentation.call(this, nextContent);
+ setAndValidateContentChildDev.call(this, nextContent);
}
}
} else if (nextHtml != null) {
@@ -18910,7 +18801,7 @@ ReactDOMComponent.Mixin = {
}
} else if (nextChildren != null) {
if (process.env.NODE_ENV !== 'production') {
- setContentChildForInstrumentation.call(this, null);
+ setAndValidateContentChildDev.call(this, null);
}
this.updateChildren(nextChildren, transaction, context);
@@ -18960,13 +18851,12 @@ ReactDOMComponent.Mixin = {
this.unmountChildren(safely);
ReactDOMComponentTree.uncacheNode(this);
EventPluginHub.deleteAllListeners(this);
- ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
- this._rootNodeID = null;
- this._domID = null;
+ this._rootNodeID = 0;
+ this._domID = 0;
this._wrapperState = null;
if (process.env.NODE_ENV !== 'production') {
- setContentChildForInstrumentation.call(this, null);
+ setAndValidateContentChildDev.call(this, null);
}
},
@@ -18981,7 +18871,7 @@ _assign(ReactDOMComponent.prototype, ReactDOMComponent.Mixin, ReactMultiChild.Mi
module.exports = ReactDOMComponent;
}).call(this,require('_process'))
-},{"./AutoFocusUtils":22,"./CSSPropertyOperations":25,"./DOMLazyTree":29,"./DOMNamespaces":30,"./DOMProperty":31,"./DOMPropertyOperations":32,"./EventConstants":37,"./EventPluginHub":38,"./EventPluginRegistry":39,"./ReactBrowserEventEmitter":48,"./ReactComponentBrowserEnvironment":53,"./ReactDOMButton":59,"./ReactDOMComponentFlags":61,"./ReactDOMComponentTree":62,"./ReactDOMInput":69,"./ReactDOMOption":72,"./ReactDOMSelect":73,"./ReactDOMTextarea":76,"./ReactInstrumentation":94,"./ReactMultiChild":98,"./ReactServerRenderingTransaction":109,"./escapeTextContentForBrowser":138,"./isEventSupported":152,"./reactProdInvariant":156,"./validateDOMNesting":162,"_process":15,"fbjs/lib/emptyFunction":170,"fbjs/lib/invariant":178,"fbjs/lib/keyOf":182,"fbjs/lib/shallowEqual":187,"fbjs/lib/warning":188,"object-assign":14}],61:[function(require,module,exports){
+},{"./AutoFocusUtils":45,"./CSSPropertyOperations":48,"./DOMLazyTree":52,"./DOMNamespaces":53,"./DOMProperty":54,"./DOMPropertyOperations":55,"./EventPluginHub":59,"./EventPluginRegistry":60,"./ReactBrowserEventEmitter":68,"./ReactDOMComponentFlags":75,"./ReactDOMComponentTree":76,"./ReactDOMInput":81,"./ReactDOMOption":84,"./ReactDOMSelect":85,"./ReactDOMTextarea":88,"./ReactInstrumentation":105,"./ReactMultiChild":109,"./ReactServerRenderingTransaction":117,"./escapeTextContentForBrowser":145,"./isEventSupported":160,"./reactProdInvariant":163,"./validateDOMNesting":169,"_process":43,"fbjs/lib/emptyFunction":10,"fbjs/lib/invariant":18,"fbjs/lib/shallowEqual":24,"fbjs/lib/warning":25,"object-assign":170}],75:[function(require,module,exports){
/**
* Copyright 2015-present, Facebook, Inc.
* All rights reserved.
@@ -18990,7 +18880,6 @@ module.exports = ReactDOMComponent;
* 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 ReactDOMComponentFlags
*/
'use strict';
@@ -19000,7 +18889,7 @@ var ReactDOMComponentFlags = {
};
module.exports = ReactDOMComponentFlags;
-},{}],62:[function(require,module,exports){
+},{}],76:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -19010,7 +18899,6 @@ module.exports = ReactDOMComponentFlags;
* 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 ReactDOMComponentTree
*/
'use strict';
@@ -19028,6 +18916,13 @@ var Flags = ReactDOMComponentFlags;
var internalInstanceKey = '__reactInternalInstance$' + Math.random().toString(36).slice(2);
/**
+ * Check if a given node should be cached.
+ */
+function shouldPrecacheNode(node, nodeID) {
+ return node.nodeType === 1 && node.getAttribute(ATTR_NAME) === String(nodeID) || node.nodeType === 8 && node.nodeValue === ' react-text: ' + nodeID + ' ' || node.nodeType === 8 && node.nodeValue === ' react-empty: ' + nodeID + ' ';
+}
+
+/**
* Drill down (through composites and empty components) until we get a host or
* host text component.
*
@@ -19086,13 +18981,13 @@ function precacheChildNodes(inst, node) {
}
var childInst = children[name];
var childID = getRenderedHostOrTextFromComponent(childInst)._domID;
- if (childID == null) {
+ if (childID === 0) {
// We're currently unmounting this child in ReactMultiChild; skip it.
continue;
}
// We assume the child nodes are in the same order as the child instances.
for (; childNode !== null; childNode = childNode.nextSibling) {
- if (childNode.nodeType === 1 && childNode.getAttribute(ATTR_NAME) === String(childID) || childNode.nodeType === 8 && childNode.nodeValue === ' react-text: ' + childID + ' ' || childNode.nodeType === 8 && childNode.nodeValue === ' react-empty: ' + childID + ' ') {
+ if (shouldPrecacheNode(childNode, childID)) {
precacheNode(childInst, childNode);
continue outer;
}
@@ -19192,7 +19087,7 @@ var ReactDOMComponentTree = {
module.exports = ReactDOMComponentTree;
}).call(this,require('_process'))
-},{"./DOMProperty":31,"./ReactDOMComponentFlags":61,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],63:[function(require,module,exports){
+},{"./DOMProperty":54,"./ReactDOMComponentFlags":75,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],77:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -19202,7 +19097,6 @@ module.exports = ReactDOMComponentTree;
* 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 ReactDOMContainerInfo
*/
'use strict';
@@ -19229,78 +19123,7 @@ function ReactDOMContainerInfo(topLevelWrapper, node) {
module.exports = ReactDOMContainerInfo;
}).call(this,require('_process'))
-},{"./validateDOMNesting":162,"_process":15}],64:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2013-present, 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 ReactDOMDebugTool
- */
-
-'use strict';
-
-var ReactDOMNullInputValuePropDevtool = require('./ReactDOMNullInputValuePropDevtool');
-var ReactDOMUnknownPropertyDevtool = require('./ReactDOMUnknownPropertyDevtool');
-var ReactDebugTool = require('./ReactDebugTool');
-
-var warning = require('fbjs/lib/warning');
-
-var eventHandlers = [];
-var handlerDoesThrowForEvent = {};
-
-function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
- eventHandlers.forEach(function (handler) {
- try {
- if (handler[handlerFunctionName]) {
- handler[handlerFunctionName](arg1, arg2, arg3, arg4, arg5);
- }
- } catch (e) {
- process.env.NODE_ENV !== 'production' ? warning(handlerDoesThrowForEvent[handlerFunctionName], 'exception thrown by devtool while handling %s: %s', handlerFunctionName, e + '\n' + e.stack) : void 0;
- handlerDoesThrowForEvent[handlerFunctionName] = true;
- }
- });
-}
-
-var ReactDOMDebugTool = {
- addDevtool: function (devtool) {
- ReactDebugTool.addDevtool(devtool);
- eventHandlers.push(devtool);
- },
- removeDevtool: function (devtool) {
- ReactDebugTool.removeDevtool(devtool);
- for (var i = 0; i < eventHandlers.length; i++) {
- if (eventHandlers[i] === devtool) {
- eventHandlers.splice(i, 1);
- i--;
- }
- }
- },
- onCreateMarkupForProperty: function (name, value) {
- emitEvent('onCreateMarkupForProperty', name, value);
- },
- onSetValueForProperty: function (node, name, value) {
- emitEvent('onSetValueForProperty', node, name, value);
- },
- onDeleteValueForProperty: function (node, name) {
- emitEvent('onDeleteValueForProperty', node, name);
- },
- onTestEvent: function () {
- emitEvent('onTestEvent');
- }
-};
-
-ReactDOMDebugTool.addDevtool(ReactDOMUnknownPropertyDevtool);
-ReactDOMDebugTool.addDevtool(ReactDOMNullInputValuePropDevtool);
-
-module.exports = ReactDOMDebugTool;
-}).call(this,require('_process'))
-
-},{"./ReactDOMNullInputValuePropDevtool":71,"./ReactDOMUnknownPropertyDevtool":78,"./ReactDebugTool":79,"_process":15,"fbjs/lib/warning":188}],65:[function(require,module,exports){
+},{"./validateDOMNesting":169,"_process":43}],78:[function(require,module,exports){
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
@@ -19309,7 +19132,6 @@ module.exports = ReactDOMDebugTool;
* 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 ReactDOMEmptyComponent
*/
'use strict';
@@ -19326,7 +19148,7 @@ var ReactDOMEmptyComponent = function (instantiate) {
this._hostNode = null;
this._hostParent = null;
this._hostContainerInfo = null;
- this._domID = null;
+ this._domID = 0;
};
_assign(ReactDOMEmptyComponent.prototype, {
mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
@@ -19361,8 +19183,7 @@ _assign(ReactDOMEmptyComponent.prototype, {
});
module.exports = ReactDOMEmptyComponent;
-},{"./DOMLazyTree":29,"./ReactDOMComponentTree":62,"object-assign":14}],66:[function(require,module,exports){
-(function (process){
+},{"./DOMLazyTree":52,"./ReactDOMComponentTree":76,"object-assign":170}],79:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -19371,196 +19192,17 @@ module.exports = ReactDOMEmptyComponent;
* 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 ReactDOMFactories
- */
-
-'use strict';
-
-var ReactElement = require('./ReactElement');
-
-var mapObject = require('fbjs/lib/mapObject');
-
-/**
- * Create a factory that creates HTML tag elements.
- *
- * @param {string} tag Tag name (e.g. `div`).
- * @private
- */
-function createDOMFactory(tag) {
- if (process.env.NODE_ENV !== 'production') {
- var ReactElementValidator = require('./ReactElementValidator');
- return ReactElementValidator.createFactory(tag);
- }
- return ReactElement.createFactory(tag);
-}
-
-/**
- * Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
- * This is also accessible via `React.DOM`.
- *
- * @public
- */
-var ReactDOMFactories = mapObject({
- 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',
- hgroup: 'hgroup',
- 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: 'circle',
- clipPath: 'clipPath',
- defs: 'defs',
- ellipse: 'ellipse',
- g: 'g',
- image: 'image',
- 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 = ReactDOMFactories;
-}).call(this,require('_process'))
-
-},{"./ReactElement":82,"./ReactElementValidator":83,"_process":15,"fbjs/lib/mapObject":183}],67:[function(require,module,exports){
-/**
- * Copyright 2013-present, 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 ReactDOMFeatureFlags
*/
'use strict';
var ReactDOMFeatureFlags = {
- useCreateElement: true
+ useCreateElement: true,
+ useFiber: false
};
module.exports = ReactDOMFeatureFlags;
-},{}],68:[function(require,module,exports){
+},{}],80:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -19569,7 +19211,6 @@ module.exports = ReactDOMFeatureFlags;
* 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
*/
'use strict';
@@ -19595,7 +19236,7 @@ var ReactDOMIDOperations = {
};
module.exports = ReactDOMIDOperations;
-},{"./DOMChildrenOperations":28,"./ReactDOMComponentTree":62}],69:[function(require,module,exports){
+},{"./DOMChildrenOperations":51,"./ReactDOMComponentTree":76}],81:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -19605,7 +19246,6 @@ module.exports = ReactDOMIDOperations;
* 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
*/
'use strict';
@@ -19613,7 +19253,6 @@ module.exports = ReactDOMIDOperations;
var _prodInvariant = require('./reactProdInvariant'),
_assign = require('object-assign');
-var DisabledInputUtils = require('./DisabledInputUtils');
var DOMPropertyOperations = require('./DOMPropertyOperations');
var LinkedValueUtils = require('./LinkedValueUtils');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
@@ -19638,7 +19277,7 @@ function forceUpdateIfMounted() {
function isControlled(props) {
var usesChecked = props.type === 'checkbox' || props.type === 'radio';
- return usesChecked ? props.checked !== undefined : props.value !== undefined;
+ return usesChecked ? props.checked != null : props.value != null;
}
/**
@@ -19665,8 +19304,15 @@ var ReactDOMInput = {
var hostProps = _assign({
// Make sure we set .type before any other properties (setting .value
// before .type means .value is lost in IE11 and below)
- type: undefined
- }, DisabledInputUtils.getHostProps(inst, props), {
+ type: undefined,
+ // Make sure we set .step before .value (setting .value before .step
+ // means .value is rounded on mount, based upon step precision)
+ step: undefined,
+ // Make sure we set .min & .max before .value (to ensure proper order
+ // in corner cases such as min or max deriving from value, e.g. Issue #7170)
+ min: undefined,
+ max: undefined
+ }, props, {
defaultChecked: undefined,
defaultValue: undefined,
value: value != null ? value : inst._wrapperState.initialValue,
@@ -19751,7 +19397,17 @@ var ReactDOMInput = {
}
} else {
if (props.value == null && props.defaultValue != null) {
- node.defaultValue = '' + props.defaultValue;
+ // In Chrome, assigning defaultValue to certain input types triggers input validation.
+ // For number inputs, the display value loses trailing decimal points. For email inputs,
+ // Chrome raises "The specified value <x> is not a valid email address".
+ //
+ // Here we check to see if the defaultValue has actually changed, avoiding these problems
+ // when the user is inputting text
+ //
+ // https://github.com/facebook/react/issues/7253
+ if (node.defaultValue !== '' + props.defaultValue) {
+ node.defaultValue = '' + props.defaultValue;
+ }
}
if (props.checked == null && props.defaultChecked != null) {
node.defaultChecked = !!props.defaultChecked;
@@ -19771,8 +19427,26 @@ var ReactDOMInput = {
// are not resetable nodes so this operation doesn't matter and actually
// removes browser-default values (eg "Submit Query") when no value is
// provided.
- if (props.type !== 'submit' && props.type !== 'reset') {
- node.value = node.value;
+
+ switch (props.type) {
+ case 'submit':
+ case 'reset':
+ break;
+ case 'color':
+ case 'date':
+ case 'datetime':
+ case 'datetime-local':
+ case 'month':
+ case 'time':
+ case 'week':
+ // This fixes the no-show issue on iOS Safari and Android Chrome:
+ // https://github.com/facebook/react/issues/7233
+ node.value = '';
+ node.value = node.defaultValue;
+ break;
+ default:
+ node.value = node.value;
+ break;
}
// Normally, we'd just do `node.checked = node.checked` upon initial mount, less this bug
@@ -19843,7 +19517,7 @@ function _handleChange(event) {
module.exports = ReactDOMInput;
}).call(this,require('_process'))
-},{"./DOMPropertyOperations":32,"./DisabledInputUtils":35,"./LinkedValueUtils":45,"./ReactDOMComponentTree":62,"./ReactUpdates":112,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"fbjs/lib/warning":188,"object-assign":14}],70:[function(require,module,exports){
+},{"./DOMPropertyOperations":55,"./LinkedValueUtils":66,"./ReactDOMComponentTree":76,"./ReactUpdates":120,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25,"object-assign":170}],82:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -19853,22 +19527,93 @@ module.exports = ReactDOMInput;
* 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 ReactDOMInstrumentation
*/
'use strict';
-var debugTool = null;
+var DOMProperty = require('./DOMProperty');
+var ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
-if (process.env.NODE_ENV !== 'production') {
- var ReactDOMDebugTool = require('./ReactDOMDebugTool');
- debugTool = ReactDOMDebugTool;
+var warning = require('fbjs/lib/warning');
+
+var warnedProperties = {};
+var rARIA = new RegExp('^(aria)-[' + DOMProperty.ATTRIBUTE_NAME_CHAR + ']*$');
+
+function validateProperty(tagName, name, debugID) {
+ if (warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
+ return true;
+ }
+
+ if (rARIA.test(name)) {
+ var lowerCasedName = name.toLowerCase();
+ var standardName = DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
+
+ // If this is an aria-* attribute, but is not listed in the known DOM
+ // DOM properties, then it is an invalid aria-* attribute.
+ if (standardName == null) {
+ warnedProperties[name] = true;
+ return false;
+ }
+ // aria-* attributes should be lowercase; suggest the lowercase version.
+ if (name !== standardName) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Unknown ARIA attribute %s. Did you mean %s?%s', name, standardName, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
+ warnedProperties[name] = true;
+ return true;
+ }
+ }
+
+ return true;
}
-module.exports = { debugTool: debugTool };
+function warnInvalidARIAProps(debugID, element) {
+ var invalidProps = [];
+
+ for (var key in element.props) {
+ var isValid = validateProperty(element.type, key, debugID);
+ if (!isValid) {
+ invalidProps.push(key);
+ }
+ }
+
+ var unknownPropString = invalidProps.map(function (prop) {
+ return '`' + prop + '`';
+ }).join(', ');
+
+ if (invalidProps.length === 1) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid aria prop %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, element.type, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
+ } else if (invalidProps.length > 1) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid aria props %s on <%s> tag. ' + 'For details, see https://fb.me/invalid-aria-prop%s', unknownPropString, element.type, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
+ }
+}
+
+function handleElement(debugID, element) {
+ if (element == null || typeof element.type !== 'string') {
+ return;
+ }
+ if (element.type.indexOf('-') >= 0 || element.props.is) {
+ return;
+ }
+
+ warnInvalidARIAProps(debugID, element);
+}
+
+var ReactDOMInvalidARIAHook = {
+ onBeforeMountComponent: function (debugID, element) {
+ if (process.env.NODE_ENV !== 'production') {
+ handleElement(debugID, element);
+ }
+ },
+ onBeforeUpdateComponent: function (debugID, element) {
+ if (process.env.NODE_ENV !== 'production') {
+ handleElement(debugID, element);
+ }
+ }
+};
+
+module.exports = ReactDOMInvalidARIAHook;
}).call(this,require('_process'))
-},{"./ReactDOMDebugTool":64,"_process":15}],71:[function(require,module,exports){
+},{"./DOMProperty":54,"_process":43,"fbjs/lib/warning":25,"react/lib/ReactComponentTreeHook":191}],83:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -19878,12 +19623,11 @@ module.exports = { debugTool: debugTool };
* 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 ReactDOMNullInputValuePropDevtool
*/
'use strict';
-var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
+var ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
var warning = require('fbjs/lib/warning');
@@ -19897,13 +19641,13 @@ function handleElement(debugID, element) {
return;
}
if (element.props != null && element.props.value === null && !didWarnValueNull) {
- process.env.NODE_ENV !== 'production' ? warning(false, '`value` prop on `%s` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.%s', element.type, ReactComponentTreeDevtool.getStackAddendumByID(debugID)) : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(false, '`value` prop on `%s` should not be null. ' + 'Consider using the empty string to clear the component or `undefined` ' + 'for uncontrolled components.%s', element.type, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
didWarnValueNull = true;
}
}
-var ReactDOMUnknownPropertyDevtool = {
+var ReactDOMNullInputValuePropHook = {
onBeforeMountComponent: function (debugID, element) {
handleElement(debugID, element);
},
@@ -19912,10 +19656,10 @@ var ReactDOMUnknownPropertyDevtool = {
}
};
-module.exports = ReactDOMUnknownPropertyDevtool;
+module.exports = ReactDOMNullInputValuePropHook;
}).call(this,require('_process'))
-},{"./ReactComponentTreeDevtool":55,"_process":15,"fbjs/lib/warning":188}],72:[function(require,module,exports){
+},{"_process":43,"fbjs/lib/warning":25,"react/lib/ReactComponentTreeHook":191}],84:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -19925,14 +19669,13 @@ module.exports = ReactDOMUnknownPropertyDevtool;
* 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
*/
'use strict';
var _assign = require('object-assign');
-var ReactChildren = require('./ReactChildren');
+var React = require('react/lib/React');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
var ReactDOMSelect = require('./ReactDOMSelect');
@@ -19944,7 +19687,7 @@ function flattenChildren(children) {
// Flatten children and warn if they aren't strings or numbers;
// invalid types are ignored.
- ReactChildren.forEach(children, function (child) {
+ React.Children.forEach(children, function (child) {
if (child == null) {
return;
}
@@ -20042,7 +19785,7 @@ var ReactDOMOption = {
module.exports = ReactDOMOption;
}).call(this,require('_process'))
-},{"./ReactChildren":50,"./ReactDOMComponentTree":62,"./ReactDOMSelect":73,"_process":15,"fbjs/lib/warning":188,"object-assign":14}],73:[function(require,module,exports){
+},{"./ReactDOMComponentTree":76,"./ReactDOMSelect":85,"_process":43,"fbjs/lib/warning":25,"object-assign":170,"react/lib/React":187}],85:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -20052,14 +19795,12 @@ module.exports = ReactDOMOption;
* 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
*/
'use strict';
var _assign = require('object-assign');
-var DisabledInputUtils = require('./DisabledInputUtils');
var LinkedValueUtils = require('./LinkedValueUtils');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
var ReactUpdates = require('./ReactUpdates');
@@ -20112,10 +19853,11 @@ function checkSelectPropTypes(inst, props) {
if (props[propName] == null) {
continue;
}
- if (props.multiple) {
- process.env.NODE_ENV !== 'production' ? warning(Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum(owner)) : void 0;
- } else {
- process.env.NODE_ENV !== 'production' ? warning(!Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum(owner)) : void 0;
+ var isArray = Array.isArray(props[propName]);
+ if (props.multiple && !isArray) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum(owner)) : void 0;
+ } else if (!props.multiple && isArray) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum(owner)) : void 0;
}
}
}
@@ -20174,7 +19916,7 @@ function updateOptions(inst, multiple, propValue) {
*/
var ReactDOMSelect = {
getHostProps: function (inst, props) {
- return _assign({}, DisabledInputUtils.getHostProps(inst, props), {
+ return _assign({}, props, {
onChange: inst._wrapperState.onChange,
value: undefined
});
@@ -20246,7 +19988,7 @@ function _handleChange(event) {
module.exports = ReactDOMSelect;
}).call(this,require('_process'))
-},{"./DisabledInputUtils":35,"./LinkedValueUtils":45,"./ReactDOMComponentTree":62,"./ReactUpdates":112,"_process":15,"fbjs/lib/warning":188,"object-assign":14}],74:[function(require,module,exports){
+},{"./LinkedValueUtils":66,"./ReactDOMComponentTree":76,"./ReactUpdates":120,"_process":43,"fbjs/lib/warning":25,"object-assign":170}],86:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -20255,7 +19997,6 @@ module.exports = ReactDOMSelect;
* 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
*/
'use strict';
@@ -20459,7 +20200,7 @@ var ReactDOMSelection = {
};
module.exports = ReactDOMSelection;
-},{"./getNodeForCharacterOffset":148,"./getTextContentAccessor":149,"fbjs/lib/ExecutionEnvironment":164}],75:[function(require,module,exports){
+},{"./getNodeForCharacterOffset":156,"./getTextContentAccessor":157,"fbjs/lib/ExecutionEnvironment":4}],87:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -20469,7 +20210,6 @@ module.exports = ReactDOMSelection;
* 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 ReactDOMTextComponent
*/
'use strict';
@@ -20480,7 +20220,6 @@ var _prodInvariant = require('./reactProdInvariant'),
var DOMChildrenOperations = require('./DOMChildrenOperations');
var DOMLazyTree = require('./DOMLazyTree');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
-var ReactInstrumentation = require('./ReactInstrumentation');
var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
var invariant = require('fbjs/lib/invariant');
@@ -20510,7 +20249,7 @@ var ReactDOMTextComponent = function (text) {
this._hostParent = null;
// Properties
- this._domID = null;
+ this._domID = 0;
this._mountIndex = 0;
this._closingComment = null;
this._commentNodes = null;
@@ -20528,8 +20267,6 @@ _assign(ReactDOMTextComponent.prototype, {
*/
mountComponent: function (transaction, hostParent, hostContainerInfo, context) {
if (process.env.NODE_ENV !== 'production') {
- ReactInstrumentation.debugTool.onSetText(this._debugID, this._stringText);
-
var parentInfo;
if (hostParent != null) {
parentInfo = hostParent._ancestorInfo;
@@ -20539,7 +20276,7 @@ _assign(ReactDOMTextComponent.prototype, {
if (parentInfo) {
// parentInfo should always be present except for the top-level
// component when server rendering
- validateDOMNesting('#text', this, parentInfo);
+ validateDOMNesting(null, this._stringText, this, parentInfo);
}
}
@@ -20593,10 +20330,6 @@ _assign(ReactDOMTextComponent.prototype, {
this._stringText = nextStringText;
var commentNodes = this.getHostNode();
DOMChildrenOperations.replaceDelimitedText(commentNodes[0], commentNodes[1], nextStringText);
-
- if (process.env.NODE_ENV !== 'production') {
- ReactInstrumentation.debugTool.onSetText(this._debugID, nextStringText);
- }
}
}
},
@@ -20634,7 +20367,7 @@ _assign(ReactDOMTextComponent.prototype, {
module.exports = ReactDOMTextComponent;
}).call(this,require('_process'))
-},{"./DOMChildrenOperations":28,"./DOMLazyTree":29,"./ReactDOMComponentTree":62,"./ReactInstrumentation":94,"./escapeTextContentForBrowser":138,"./reactProdInvariant":156,"./validateDOMNesting":162,"_process":15,"fbjs/lib/invariant":178,"object-assign":14}],76:[function(require,module,exports){
+},{"./DOMChildrenOperations":51,"./DOMLazyTree":52,"./ReactDOMComponentTree":76,"./escapeTextContentForBrowser":145,"./reactProdInvariant":163,"./validateDOMNesting":169,"_process":43,"fbjs/lib/invariant":18,"object-assign":170}],88:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -20644,7 +20377,6 @@ module.exports = ReactDOMTextComponent;
* 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
*/
'use strict';
@@ -20652,7 +20384,6 @@ module.exports = ReactDOMTextComponent;
var _prodInvariant = require('./reactProdInvariant'),
_assign = require('object-assign');
-var DisabledInputUtils = require('./DisabledInputUtils');
var LinkedValueUtils = require('./LinkedValueUtils');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
var ReactUpdates = require('./ReactUpdates');
@@ -20694,7 +20425,7 @@ var ReactDOMTextarea = {
// to only set the value if/when the value differs from the node value (which would
// completely solve this IE9 bug), but Sebastian+Ben seemed to like this solution.
// The value can be a boolean or object so that's why it's forced to be a string.
- var hostProps = _assign({}, DisabledInputUtils.getHostProps(inst, props), {
+ var hostProps = _assign({}, props, {
value: undefined,
defaultValue: undefined,
children: '' + inst._wrapperState.initialValue,
@@ -20777,9 +20508,15 @@ var ReactDOMTextarea = {
// This is in postMount because we need access to the DOM node, which is not
// available until after the component has mounted.
var node = ReactDOMComponentTree.getNodeFromInstance(inst);
+ var textContent = node.textContent;
- // Warning: node.value may be the empty string at this point (IE11) if placeholder is set.
- node.value = node.textContent; // Detach value from defaultValue
+ // Only set node.value if textContent is equal to the expected
+ // initial value. In IE10/IE11 there is a bug where the placeholder attribute
+ // will populate textContent as well.
+ // https://developer.microsoft.com/microsoft-edge/platform/issues/101525/
+ if (textContent === inst._wrapperState.initialValue) {
+ node.value = textContent;
+ }
}
};
@@ -20793,7 +20530,7 @@ function _handleChange(event) {
module.exports = ReactDOMTextarea;
}).call(this,require('_process'))
-},{"./DisabledInputUtils":35,"./LinkedValueUtils":45,"./ReactDOMComponentTree":62,"./ReactUpdates":112,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"fbjs/lib/warning":188,"object-assign":14}],77:[function(require,module,exports){
+},{"./LinkedValueUtils":66,"./ReactDOMComponentTree":76,"./ReactUpdates":120,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25,"object-assign":170}],89:[function(require,module,exports){
(function (process){
/**
* Copyright 2015-present, Facebook, Inc.
@@ -20803,7 +20540,6 @@ module.exports = ReactDOMTextarea;
* 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 ReactDOMTreeTraversal
*/
'use strict';
@@ -20889,10 +20625,10 @@ function traverseTwoPhase(inst, fn, arg) {
}
var i;
for (i = path.length; i-- > 0;) {
- fn(path[i], false, arg);
+ fn(path[i], 'captured', arg);
}
for (i = 0; i < path.length; i++) {
- fn(path[i], true, arg);
+ fn(path[i], 'bubbled', arg);
}
}
@@ -20917,10 +20653,10 @@ function traverseEnterLeave(from, to, fn, argFrom, argTo) {
}
var i;
for (i = 0; i < pathFrom.length; i++) {
- fn(pathFrom[i], true, argFrom);
+ fn(pathFrom[i], 'bubbled', argFrom);
}
for (i = pathTo.length; i-- > 0;) {
- fn(pathTo[i], false, argTo);
+ fn(pathTo[i], 'captured', argTo);
}
}
@@ -20933,7 +20669,7 @@ module.exports = {
};
}).call(this,require('_process'))
-},{"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],78:[function(require,module,exports){
+},{"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],90:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -20943,14 +20679,13 @@ module.exports = {
* 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 ReactDOMUnknownPropertyDevtool
*/
'use strict';
var DOMProperty = require('./DOMProperty');
var EventPluginRegistry = require('./EventPluginRegistry');
-var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
+var ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
var warning = require('fbjs/lib/warning');
@@ -20992,10 +20727,10 @@ if (process.env.NODE_ENV !== 'production') {
var registrationName = EventPluginRegistry.possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? EventPluginRegistry.possibleRegistrationNames[lowerCasedName] : null;
if (standardName != null) {
- process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?%s', name, standardName, ReactComponentTreeDevtool.getStackAddendumByID(debugID)) : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Unknown DOM property %s. Did you mean %s?%s', name, standardName, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
return true;
} else if (registrationName != null) {
- process.env.NODE_ENV !== 'production' ? warning(registrationName == null, 'Unknown event handler property %s. Did you mean `%s`?%s', name, registrationName, ReactComponentTreeDevtool.getStackAddendumByID(debugID)) : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Unknown event handler property %s. Did you mean `%s`?%s', name, registrationName, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
return true;
} else {
// We were unable to guess which prop the user intended.
@@ -21021,9 +20756,9 @@ var warnUnknownProperties = function (debugID, element) {
}).join(', ');
if (unknownProps.length === 1) {
- process.env.NODE_ENV !== 'production' ? warning(false, 'Unknown prop %s on <%s> tag. Remove this prop from the element. ' + 'For details, see https://fb.me/react-unknown-prop%s', unknownPropString, element.type, ReactComponentTreeDevtool.getStackAddendumByID(debugID)) : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Unknown prop %s on <%s> tag. Remove this prop from the element. ' + 'For details, see https://fb.me/react-unknown-prop%s', unknownPropString, element.type, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
} else if (unknownProps.length > 1) {
- process.env.NODE_ENV !== 'production' ? warning(false, 'Unknown props %s on <%s> tag. Remove these props from the element. ' + 'For details, see https://fb.me/react-unknown-prop%s', unknownPropString, element.type, ReactComponentTreeDevtool.getStackAddendumByID(debugID)) : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Unknown props %s on <%s> tag. Remove these props from the element. ' + 'For details, see https://fb.me/react-unknown-prop%s', unknownPropString, element.type, ReactComponentTreeHook.getStackAddendumByID(debugID)) : void 0;
}
};
@@ -21037,7 +20772,7 @@ function handleElement(debugID, element) {
warnUnknownProperties(debugID, element);
}
-var ReactDOMUnknownPropertyDevtool = {
+var ReactDOMUnknownPropertyHook = {
onBeforeMountComponent: function (debugID, element) {
handleElement(debugID, element);
},
@@ -21046,10 +20781,10 @@ var ReactDOMUnknownPropertyDevtool = {
}
};
-module.exports = ReactDOMUnknownPropertyDevtool;
+module.exports = ReactDOMUnknownPropertyHook;
}).call(this,require('_process'))
-},{"./DOMProperty":31,"./EventPluginRegistry":39,"./ReactComponentTreeDevtool":55,"_process":15,"fbjs/lib/warning":188}],79:[function(require,module,exports){
+},{"./DOMProperty":54,"./EventPluginRegistry":60,"_process":43,"fbjs/lib/warning":25,"react/lib/ReactComponentTreeHook":191}],91:[function(require,module,exports){
(function (process){
/**
* Copyright 2016-present, Facebook, Inc.
@@ -21059,62 +20794,70 @@ module.exports = ReactDOMUnknownPropertyDevtool;
* 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 ReactDebugTool
+ *
*/
'use strict';
-var ReactInvalidSetStateWarningDevTool = require('./ReactInvalidSetStateWarningDevTool');
-var ReactHostOperationHistoryDevtool = require('./ReactHostOperationHistoryDevtool');
-var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
+var ReactInvalidSetStateWarningHook = require('./ReactInvalidSetStateWarningHook');
+var ReactHostOperationHistoryHook = require('./ReactHostOperationHistoryHook');
+var ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
var performanceNow = require('fbjs/lib/performanceNow');
var warning = require('fbjs/lib/warning');
-var eventHandlers = [];
-var handlerDoesThrowForEvent = {};
+var hooks = [];
+var didHookThrowForEvent = {};
-function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
- eventHandlers.forEach(function (handler) {
- try {
- if (handler[handlerFunctionName]) {
- handler[handlerFunctionName](arg1, arg2, arg3, arg4, arg5);
- }
- } catch (e) {
- process.env.NODE_ENV !== 'production' ? warning(handlerDoesThrowForEvent[handlerFunctionName], 'exception thrown by devtool while handling %s: %s', handlerFunctionName, e + '\n' + e.stack) : void 0;
- handlerDoesThrowForEvent[handlerFunctionName] = true;
+function callHook(event, fn, context, arg1, arg2, arg3, arg4, arg5) {
+ try {
+ fn.call(context, arg1, arg2, arg3, arg4, arg5);
+ } catch (e) {
+ process.env.NODE_ENV !== 'production' ? warning(didHookThrowForEvent[event], 'Exception thrown by hook while handling %s: %s', event, e + '\n' + e.stack) : void 0;
+ didHookThrowForEvent[event] = true;
+ }
+}
+
+function emitEvent(event, arg1, arg2, arg3, arg4, arg5) {
+ for (var i = 0; i < hooks.length; i++) {
+ var hook = hooks[i];
+ var fn = hook[event];
+ if (fn) {
+ callHook(event, fn, hook, arg1, arg2, arg3, arg4, arg5);
}
- });
+ }
}
var isProfiling = false;
var flushHistory = [];
var lifeCycleTimerStack = [];
var currentFlushNesting = 0;
-var currentFlushMeasurements = null;
-var currentFlushStartTime = null;
+var currentFlushMeasurements = [];
+var currentFlushStartTime = 0;
var currentTimerDebugID = null;
-var currentTimerStartTime = null;
-var currentTimerNestedFlushDuration = null;
+var currentTimerStartTime = 0;
+var currentTimerNestedFlushDuration = 0;
var currentTimerType = null;
+var lifeCycleTimerHasWarned = false;
+
function clearHistory() {
- ReactComponentTreeDevtool.purgeUnmountedComponents();
- ReactHostOperationHistoryDevtool.clearHistory();
+ ReactComponentTreeHook.purgeUnmountedComponents();
+ ReactHostOperationHistoryHook.clearHistory();
}
function getTreeSnapshot(registeredIDs) {
return registeredIDs.reduce(function (tree, id) {
- var ownerID = ReactComponentTreeDevtool.getOwnerID(id);
- var parentID = ReactComponentTreeDevtool.getParentID(id);
+ var ownerID = ReactComponentTreeHook.getOwnerID(id);
+ var parentID = ReactComponentTreeHook.getParentID(id);
tree[id] = {
- displayName: ReactComponentTreeDevtool.getDisplayName(id),
- text: ReactComponentTreeDevtool.getText(id),
- updateCount: ReactComponentTreeDevtool.getUpdateCount(id),
- childIDs: ReactComponentTreeDevtool.getChildIDs(id),
+ displayName: ReactComponentTreeHook.getDisplayName(id),
+ text: ReactComponentTreeHook.getText(id),
+ updateCount: ReactComponentTreeHook.getUpdateCount(id),
+ childIDs: ReactComponentTreeHook.getChildIDs(id),
// Text nodes don't have owners but this is close enough.
- ownerID: ownerID || ReactComponentTreeDevtool.getOwnerID(parentID),
+ ownerID: ownerID || parentID && ReactComponentTreeHook.getOwnerID(parentID) || 0,
parentID: parentID
};
return tree;
@@ -21123,18 +20866,18 @@ function getTreeSnapshot(registeredIDs) {
function resetMeasurements() {
var previousStartTime = currentFlushStartTime;
- var previousMeasurements = currentFlushMeasurements || [];
- var previousOperations = ReactHostOperationHistoryDevtool.getHistory();
+ var previousMeasurements = currentFlushMeasurements;
+ var previousOperations = ReactHostOperationHistoryHook.getHistory();
if (currentFlushNesting === 0) {
- currentFlushStartTime = null;
- currentFlushMeasurements = null;
+ currentFlushStartTime = 0;
+ currentFlushMeasurements = [];
clearHistory();
return;
}
if (previousMeasurements.length || previousOperations.length) {
- var registeredIDs = ReactComponentTreeDevtool.getRegisteredIDs();
+ var registeredIDs = ReactComponentTreeHook.getRegisteredIDs();
flushHistory.push({
duration: performanceNow() - previousStartTime,
measurements: previousMeasurements || [],
@@ -21149,14 +20892,24 @@ function resetMeasurements() {
}
function checkDebugID(debugID) {
- process.env.NODE_ENV !== 'production' ? warning(debugID, 'ReactDebugTool: debugID may not be empty.') : void 0;
+ var allowRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
+
+ if (allowRoot && debugID === 0) {
+ return;
+ }
+ if (!debugID) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDebugTool: debugID may not be empty.') : void 0;
+ }
}
function beginLifeCycleTimer(debugID, timerType) {
if (currentFlushNesting === 0) {
return;
}
- process.env.NODE_ENV !== 'production' ? warning(!currentTimerType, 'There is an internal error in the React performance measurement code. ' + 'Did not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
+ if (currentTimerType && !lifeCycleTimerHasWarned) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'There is an internal error in the React performance measurement code. ' + 'Did not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
+ lifeCycleTimerHasWarned = true;
+ }
currentTimerStartTime = performanceNow();
currentTimerNestedFlushDuration = 0;
currentTimerDebugID = debugID;
@@ -21167,7 +20920,10 @@ function endLifeCycleTimer(debugID, timerType) {
if (currentFlushNesting === 0) {
return;
}
- process.env.NODE_ENV !== 'production' ? warning(currentTimerType === timerType, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
+ if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
+ lifeCycleTimerHasWarned = true;
+ }
if (isProfiling) {
currentFlushMeasurements.push({
timerType: timerType,
@@ -21175,8 +20931,8 @@ function endLifeCycleTimer(debugID, timerType) {
duration: performanceNow() - currentTimerStartTime - currentTimerNestedFlushDuration
});
}
- currentTimerStartTime = null;
- currentTimerNestedFlushDuration = null;
+ currentTimerStartTime = 0;
+ currentTimerNestedFlushDuration = 0;
currentTimerDebugID = null;
currentTimerType = null;
}
@@ -21189,19 +20945,18 @@ function pauseCurrentLifeCycleTimer() {
timerType: currentTimerType
};
lifeCycleTimerStack.push(currentTimer);
- currentTimerStartTime = null;
- currentTimerNestedFlushDuration = null;
+ currentTimerStartTime = 0;
+ currentTimerNestedFlushDuration = 0;
currentTimerDebugID = null;
currentTimerType = null;
}
function resumeCurrentLifeCycleTimer() {
- var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop();
-
- var startTime = _lifeCycleTimerStack$.startTime;
- var nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime;
- var debugID = _lifeCycleTimerStack$.debugID;
- var timerType = _lifeCycleTimerStack$.timerType;
+ var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop(),
+ startTime = _lifeCycleTimerStack$.startTime,
+ nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime,
+ debugID = _lifeCycleTimerStack$.debugID,
+ timerType = _lifeCycleTimerStack$.timerType;
var nestedFlushDuration = performanceNow() - nestedFlushStartTime;
currentTimerStartTime = startTime;
@@ -21210,14 +20965,68 @@ function resumeCurrentLifeCycleTimer() {
currentTimerType = timerType;
}
+var lastMarkTimeStamp = 0;
+var canUsePerformanceMeasure =
+// $FlowFixMe https://github.com/facebook/flow/issues/2345
+typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
+
+function shouldMark(debugID) {
+ if (!isProfiling || !canUsePerformanceMeasure) {
+ return false;
+ }
+ var element = ReactComponentTreeHook.getElement(debugID);
+ if (element == null || typeof element !== 'object') {
+ return false;
+ }
+ var isHostElement = typeof element.type === 'string';
+ if (isHostElement) {
+ return false;
+ }
+ return true;
+}
+
+function markBegin(debugID, markType) {
+ if (!shouldMark(debugID)) {
+ return;
+ }
+
+ var markName = debugID + '::' + markType;
+ lastMarkTimeStamp = performanceNow();
+ performance.mark(markName);
+}
+
+function markEnd(debugID, markType) {
+ if (!shouldMark(debugID)) {
+ return;
+ }
+
+ var markName = debugID + '::' + markType;
+ var displayName = ReactComponentTreeHook.getDisplayName(debugID) || 'Unknown';
+
+ // Chrome has an issue of dropping markers recorded too fast:
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=640652
+ // To work around this, we will not report very small measurements.
+ // I determined the magic number by tweaking it back and forth.
+ // 0.05ms was enough to prevent the issue, but I set it to 0.1ms to be safe.
+ // When the bug is fixed, we can `measure()` unconditionally if we want to.
+ var timeStamp = performanceNow();
+ if (timeStamp - lastMarkTimeStamp > 0.1) {
+ var measurementName = displayName + ' [' + markType + ']';
+ performance.measure(measurementName, markName);
+ }
+
+ performance.clearMarks(markName);
+ performance.clearMeasures(measurementName);
+}
+
var ReactDebugTool = {
- addDevtool: function (devtool) {
- eventHandlers.push(devtool);
+ addHook: function (hook) {
+ hooks.push(hook);
},
- removeDevtool: function (devtool) {
- for (var i = 0; i < eventHandlers.length; i++) {
- if (eventHandlers[i] === devtool) {
- eventHandlers.splice(i, 1);
+ removeHook: function (hook) {
+ for (var i = 0; i < hooks.length; i++) {
+ if (hooks[i] === hook) {
+ hooks.splice(i, 1);
i--;
}
}
@@ -21233,7 +21042,7 @@ var ReactDebugTool = {
isProfiling = true;
flushHistory.length = 0;
resetMeasurements();
- ReactDebugTool.addDevtool(ReactHostOperationHistoryDevtool);
+ ReactDebugTool.addHook(ReactHostOperationHistoryHook);
},
endProfiling: function () {
if (!isProfiling) {
@@ -21242,7 +21051,7 @@ var ReactDebugTool = {
isProfiling = false;
resetMeasurements();
- ReactDebugTool.removeDevtool(ReactHostOperationHistoryDevtool);
+ ReactDebugTool.removeHook(ReactHostOperationHistoryHook);
},
getFlushHistory: function () {
return flushHistory;
@@ -21262,83 +21071,62 @@ var ReactDebugTool = {
onBeginLifeCycleTimer: function (debugID, timerType) {
checkDebugID(debugID);
emitEvent('onBeginLifeCycleTimer', debugID, timerType);
+ markBegin(debugID, timerType);
beginLifeCycleTimer(debugID, timerType);
},
onEndLifeCycleTimer: function (debugID, timerType) {
checkDebugID(debugID);
endLifeCycleTimer(debugID, timerType);
+ markEnd(debugID, timerType);
emitEvent('onEndLifeCycleTimer', debugID, timerType);
},
- onBeginReconcilerTimer: function (debugID, timerType) {
- checkDebugID(debugID);
- emitEvent('onBeginReconcilerTimer', debugID, timerType);
- },
- onEndReconcilerTimer: function (debugID, timerType) {
- checkDebugID(debugID);
- emitEvent('onEndReconcilerTimer', debugID, timerType);
- },
- onError: function (debugID) {
- if (currentTimerDebugID != null) {
- endLifeCycleTimer(currentTimerDebugID, currentTimerType);
- }
- emitEvent('onError', debugID);
- },
onBeginProcessingChildContext: function () {
emitEvent('onBeginProcessingChildContext');
},
onEndProcessingChildContext: function () {
emitEvent('onEndProcessingChildContext');
},
- onHostOperation: function (debugID, type, payload) {
- checkDebugID(debugID);
- emitEvent('onHostOperation', debugID, type, payload);
+ onHostOperation: function (operation) {
+ checkDebugID(operation.instanceID);
+ emitEvent('onHostOperation', operation);
},
onSetState: function () {
emitEvent('onSetState');
},
- onSetDisplayName: function (debugID, displayName) {
- checkDebugID(debugID);
- emitEvent('onSetDisplayName', debugID, displayName);
- },
onSetChildren: function (debugID, childDebugIDs) {
checkDebugID(debugID);
childDebugIDs.forEach(checkDebugID);
emitEvent('onSetChildren', debugID, childDebugIDs);
},
- onSetOwner: function (debugID, ownerDebugID) {
- checkDebugID(debugID);
- emitEvent('onSetOwner', debugID, ownerDebugID);
- },
- onSetParent: function (debugID, parentDebugID) {
+ onBeforeMountComponent: function (debugID, element, parentDebugID) {
checkDebugID(debugID);
- emitEvent('onSetParent', debugID, parentDebugID);
- },
- onSetText: function (debugID, text) {
- checkDebugID(debugID);
- emitEvent('onSetText', debugID, text);
- },
- onMountRootComponent: function (debugID) {
- checkDebugID(debugID);
- emitEvent('onMountRootComponent', debugID);
- },
- onBeforeMountComponent: function (debugID, element) {
- checkDebugID(debugID);
- emitEvent('onBeforeMountComponent', debugID, element);
+ checkDebugID(parentDebugID, true);
+ emitEvent('onBeforeMountComponent', debugID, element, parentDebugID);
+ markBegin(debugID, 'mount');
},
onMountComponent: function (debugID) {
checkDebugID(debugID);
+ markEnd(debugID, 'mount');
emitEvent('onMountComponent', debugID);
},
onBeforeUpdateComponent: function (debugID, element) {
checkDebugID(debugID);
emitEvent('onBeforeUpdateComponent', debugID, element);
+ markBegin(debugID, 'update');
},
onUpdateComponent: function (debugID) {
checkDebugID(debugID);
+ markEnd(debugID, 'update');
emitEvent('onUpdateComponent', debugID);
},
+ onBeforeUnmountComponent: function (debugID) {
+ checkDebugID(debugID);
+ emitEvent('onBeforeUnmountComponent', debugID);
+ markBegin(debugID, 'unmount');
+ },
onUnmountComponent: function (debugID) {
checkDebugID(debugID);
+ markEnd(debugID, 'unmount');
emitEvent('onUnmountComponent', debugID);
},
onTestEvent: function () {
@@ -21346,8 +21134,12 @@ var ReactDebugTool = {
}
};
-ReactDebugTool.addDevtool(ReactInvalidSetStateWarningDevTool);
-ReactDebugTool.addDevtool(ReactComponentTreeDevtool);
+// TODO remove these when RN/www gets updated
+ReactDebugTool.addDevtool = ReactDebugTool.addHook;
+ReactDebugTool.removeDevtool = ReactDebugTool.removeHook;
+
+ReactDebugTool.addHook(ReactInvalidSetStateWarningHook);
+ReactDebugTool.addHook(ReactComponentTreeHook);
var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
if (/[?&]react_perf\b/.test(url)) {
ReactDebugTool.beginProfiling();
@@ -21356,7 +21148,7 @@ if (/[?&]react_perf\b/.test(url)) {
module.exports = ReactDebugTool;
}).call(this,require('_process'))
-},{"./ReactComponentTreeDevtool":55,"./ReactHostOperationHistoryDevtool":90,"./ReactInvalidSetStateWarningDevTool":95,"_process":15,"fbjs/lib/ExecutionEnvironment":164,"fbjs/lib/performanceNow":186,"fbjs/lib/warning":188}],80:[function(require,module,exports){
+},{"./ReactHostOperationHistoryHook":101,"./ReactInvalidSetStateWarningHook":106,"_process":43,"fbjs/lib/ExecutionEnvironment":4,"fbjs/lib/performanceNow":23,"fbjs/lib/warning":25,"react/lib/ReactComponentTreeHook":191}],92:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -21365,7 +21157,6 @@ module.exports = ReactDebugTool;
* 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
*/
'use strict';
@@ -21395,7 +21186,7 @@ function ReactDefaultBatchingStrategyTransaction() {
this.reinitializeTransaction();
}
-_assign(ReactDefaultBatchingStrategyTransaction.prototype, Transaction.Mixin, {
+_assign(ReactDefaultBatchingStrategyTransaction.prototype, Transaction, {
getTransactionWrappers: function () {
return TRANSACTION_WRAPPERS;
}
@@ -21417,15 +21208,15 @@ var ReactDefaultBatchingStrategy = {
// The code is written this way to avoid extra allocations
if (alreadyBatchingUpdates) {
- callback(a, b, c, d, e);
+ return callback(a, b, c, d, e);
} else {
- transaction.perform(callback, null, a, b, c, d, e);
+ return transaction.perform(callback, null, a, b, c, d, e);
}
}
};
module.exports = ReactDefaultBatchingStrategy;
-},{"./ReactUpdates":112,"./Transaction":130,"fbjs/lib/emptyFunction":170,"object-assign":14}],81:[function(require,module,exports){
+},{"./ReactUpdates":120,"./Transaction":138,"fbjs/lib/emptyFunction":10,"object-assign":170}],93:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -21434,11 +21225,11 @@ module.exports = ReactDefaultBatchingStrategy;
* 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
*/
'use strict';
+var ARIADOMPropertyConfig = require('./ARIADOMPropertyConfig');
var BeforeInputEventPlugin = require('./BeforeInputEventPlugin');
var ChangeEventPlugin = require('./ChangeEventPlugin');
var DefaultEventPluginOrder = require('./DefaultEventPluginOrder');
@@ -21494,6 +21285,7 @@ function inject() {
ReactInjection.HostComponent.injectTextComponentClass(ReactDOMTextComponent);
+ ReactInjection.DOMProperty.injectDOMPropertyConfig(ARIADOMPropertyConfig);
ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
@@ -21510,8 +21302,7 @@ function inject() {
module.exports = {
inject: inject
};
-},{"./BeforeInputEventPlugin":23,"./ChangeEventPlugin":27,"./DefaultEventPluginOrder":34,"./EnterLeaveEventPlugin":36,"./HTMLDOMPropertyConfig":43,"./ReactComponentBrowserEnvironment":53,"./ReactDOMComponent":60,"./ReactDOMComponentTree":62,"./ReactDOMEmptyComponent":65,"./ReactDOMTextComponent":75,"./ReactDOMTreeTraversal":77,"./ReactDefaultBatchingStrategy":80,"./ReactEventListener":87,"./ReactInjection":91,"./ReactReconcileTransaction":106,"./SVGDOMPropertyConfig":114,"./SelectEventPlugin":115,"./SimpleEventPlugin":116}],82:[function(require,module,exports){
-(function (process){
+},{"./ARIADOMPropertyConfig":44,"./BeforeInputEventPlugin":46,"./ChangeEventPlugin":50,"./DefaultEventPluginOrder":57,"./EnterLeaveEventPlugin":58,"./HTMLDOMPropertyConfig":64,"./ReactComponentBrowserEnvironment":70,"./ReactDOMComponent":74,"./ReactDOMComponentTree":76,"./ReactDOMEmptyComponent":78,"./ReactDOMTextComponent":87,"./ReactDOMTreeTraversal":89,"./ReactDefaultBatchingStrategy":92,"./ReactEventListener":98,"./ReactInjection":102,"./ReactReconcileTransaction":114,"./SVGDOMPropertyConfig":122,"./SelectEventPlugin":123,"./SimpleEventPlugin":124}],94:[function(require,module,exports){
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
@@ -21520,583 +21311,18 @@ module.exports = {
* 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 ReactElement
+ *
*/
'use strict';
-var _assign = require('object-assign');
-
-var ReactCurrentOwner = require('./ReactCurrentOwner');
-
-var warning = require('fbjs/lib/warning');
-var canDefineProperty = require('./canDefineProperty');
-var hasOwnProperty = Object.prototype.hasOwnProperty;
-
// The Symbol used to tag the ReactElement type. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
-var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
-
-var RESERVED_PROPS = {
- key: true,
- ref: true,
- __self: true,
- __source: true
-};
-
-var specialPropKeyWarningShown, specialPropRefWarningShown;
-
-function hasValidRef(config) {
- if (process.env.NODE_ENV !== 'production') {
- if (hasOwnProperty.call(config, 'ref')) {
- var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
- if (getter && getter.isReactWarning) {
- return false;
- }
- }
- }
- return config.ref !== undefined;
-}
-function hasValidKey(config) {
- if (process.env.NODE_ENV !== 'production') {
- if (hasOwnProperty.call(config, 'key')) {
- var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
- if (getter && getter.isReactWarning) {
- return false;
- }
- }
- }
- return config.key !== undefined;
-}
-
-/**
- * Factory method to create a new React element. This no longer adheres to
- * the class pattern, so do not use new to call it. Also, no instanceof check
- * will work. Instead test $$typeof field against Symbol.for('react.element') to check
- * if something is a React Element.
- *
- * @param {*} type
- * @param {*} key
- * @param {string|object} ref
- * @param {*} self A *temporary* helper to detect places where `this` is
- * different from the `owner` when React.createElement is called, so that we
- * can warn. We want to get rid of owner and replace string `ref`s with arrow
- * functions, and as long as `this` and owner are the same, there will be no
- * change in behavior.
- * @param {*} source An annotation object (added by a transpiler or otherwise)
- * indicating filename, line number, and/or other information.
- * @param {*} owner
- * @param {*} props
- * @internal
- */
-var ReactElement = function (type, key, ref, self, source, owner, props) {
- var element = {
- // This tag allow us to uniquely identify this as a React Element
- $$typeof: REACT_ELEMENT_TYPE,
-
- // Built-in properties that belong on the element
- type: type,
- key: key,
- ref: ref,
- props: props,
-
- // Record the component responsible for creating this element.
- _owner: owner
- };
-
- if (process.env.NODE_ENV !== 'production') {
- // The validation flag is currently mutative. We put it 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.
- element._store = {};
-
- // To make comparing ReactElements easier for testing purposes, we make
- // the validation flag non-enumerable (where possible, which should
- // include every environment we run tests in), so the test framework
- // ignores it.
- if (canDefineProperty) {
- Object.defineProperty(element._store, 'validated', {
- configurable: false,
- enumerable: false,
- writable: true,
- value: false
- });
- // self and source are DEV only properties.
- Object.defineProperty(element, '_self', {
- configurable: false,
- enumerable: false,
- writable: false,
- value: self
- });
- // Two elements created in two different places should be considered
- // equal for testing purposes and therefore we hide it from enumeration.
- Object.defineProperty(element, '_source', {
- configurable: false,
- enumerable: false,
- writable: false,
- value: source
- });
- } else {
- element._store.validated = false;
- element._self = self;
- element._source = source;
- }
- if (Object.freeze) {
- Object.freeze(element.props);
- Object.freeze(element);
- }
- }
-
- return element;
-};
-
-/**
- * Create and return a new ReactElement of the given type.
- * See https://facebook.github.io/react/docs/top-level-api.html#react.createelement
- */
-ReactElement.createElement = function (type, config, children) {
- var propName;
-
- // Reserved names are extracted
- var props = {};
-
- var key = null;
- var ref = null;
- var self = null;
- var source = null;
-
- if (config != null) {
- if (process.env.NODE_ENV !== 'production') {
- process.env.NODE_ENV !== 'production' ? warning(
- /* eslint-disable no-proto */
- config.__proto__ == null || config.__proto__ === Object.prototype,
- /* eslint-enable no-proto */
- 'React.createElement(...): Expected props argument to be a plain object. ' + 'Properties defined in its prototype chain will be ignored.') : void 0;
- }
-
- if (hasValidRef(config)) {
- ref = config.ref;
- }
- if (hasValidKey(config)) {
- key = '' + config.key;
- }
-
- self = config.__self === undefined ? null : config.__self;
- source = config.__source === undefined ? null : config.__source;
- // Remaining properties are added to a new props object
- for (propName in config) {
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
- props[propName] = config[propName];
- }
- }
- }
-
- // 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 && type.defaultProps) {
- var defaultProps = type.defaultProps;
- for (propName in defaultProps) {
- if (props[propName] === undefined) {
- props[propName] = defaultProps[propName];
- }
- }
- }
- if (process.env.NODE_ENV !== 'production') {
- var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
-
- // Create dummy `key` and `ref` property to `props` to warn users against its use
- var warnAboutAccessingKey = function () {
- if (!specialPropKeyWarningShown) {
- specialPropKeyWarningShown = true;
- process.env.NODE_ENV !== 'production' ? warning(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName) : void 0;
- }
- return undefined;
- };
- warnAboutAccessingKey.isReactWarning = true;
-
- var warnAboutAccessingRef = function () {
- if (!specialPropRefWarningShown) {
- specialPropRefWarningShown = true;
- process.env.NODE_ENV !== 'production' ? warning(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName) : void 0;
- }
- return undefined;
- };
- warnAboutAccessingRef.isReactWarning = true;
-
- if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
- if (!props.hasOwnProperty('key')) {
- Object.defineProperty(props, 'key', {
- get: warnAboutAccessingKey,
- configurable: true
- });
- }
- if (!props.hasOwnProperty('ref')) {
- Object.defineProperty(props, 'ref', {
- get: warnAboutAccessingRef,
- configurable: true
- });
- }
- }
- }
- return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
-};
-
-/**
- * Return a function that produces ReactElements of a given type.
- * See https://facebook.github.io/react/docs/top-level-api.html#react.createfactory
- */
-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 elements. E.g. `<Foo />.type === Foo`.
- // 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.
- // Legacy hook TODO: Warn if this is accessed
- factory.type = type;
- return factory;
-};
-
-ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
- var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
-
- return newElement;
-};
-
-/**
- * Clone and return a new ReactElement using element as the starting point.
- * See https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement
- */
-ReactElement.cloneElement = function (element, config, children) {
- var propName;
-
- // Original props are copied
- var props = _assign({}, element.props);
-
- // Reserved names are extracted
- var key = element.key;
- var ref = element.ref;
- // Self is preserved since the owner is preserved.
- var self = element._self;
- // Source is preserved since cloneElement is unlikely to be targeted by a
- // transpiler, and the original source is probably a better indicator of the
- // true owner.
- var source = element._source;
-
- // Owner will be preserved, unless ref is overridden
- var owner = element._owner;
-
- if (config != null) {
- if (process.env.NODE_ENV !== 'production') {
- process.env.NODE_ENV !== 'production' ? warning(
- /* eslint-disable no-proto */
- config.__proto__ == null || config.__proto__ === Object.prototype,
- /* eslint-enable no-proto */
- 'React.cloneElement(...): Expected props argument to be a plain object. ' + 'Properties defined in its prototype chain will be ignored.') : void 0;
- }
-
- if (hasValidRef(config)) {
- // Silently steal the ref from the parent.
- ref = config.ref;
- owner = ReactCurrentOwner.current;
- }
- if (hasValidKey(config)) {
- key = '' + config.key;
- }
-
- // Remaining properties override existing props
- var defaultProps;
- if (element.type && element.type.defaultProps) {
- defaultProps = element.type.defaultProps;
- }
- for (propName in config) {
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
- if (config[propName] === undefined && defaultProps !== undefined) {
- // Resolve default props
- props[propName] = defaultProps[propName];
- } else {
- props[propName] = config[propName];
- }
- }
- }
- }
-
- // 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;
- }
-
- return ReactElement(element.type, key, ref, self, source, owner, props);
-};
-
-/**
- * Verifies the object is a ReactElement.
- * See https://facebook.github.io/react/docs/top-level-api.html#react.isvalidelement
- * @param {?object} object
- * @return {boolean} True if `object` is a valid component.
- * @final
- */
-ReactElement.isValidElement = function (object) {
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
-};
-
-ReactElement.REACT_ELEMENT_TYPE = REACT_ELEMENT_TYPE;
-
-module.exports = ReactElement;
-}).call(this,require('_process'))
-
-},{"./ReactCurrentOwner":57,"./canDefineProperty":134,"_process":15,"fbjs/lib/warning":188,"object-assign":14}],83:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2014-present, 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 ReactElementValidator
- */
-
-/**
- * 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 ReactCurrentOwner = require('./ReactCurrentOwner');
-var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
-var ReactElement = require('./ReactElement');
-var ReactPropTypeLocations = require('./ReactPropTypeLocations');
-
-var checkReactTypeSpec = require('./checkReactTypeSpec');
-
-var canDefineProperty = require('./canDefineProperty');
-var getIteratorFn = require('./getIteratorFn');
-var warning = require('fbjs/lib/warning');
-
-function getDeclarationErrorAddendum() {
- if (ReactCurrentOwner.current) {
- var name = ReactCurrentOwner.current.getName();
- if (name) {
- return ' Check the render method of `' + name + '`.';
- }
- }
- return '';
-}
-
-/**
- * Warn if there's no key explicitly set on dynamic arrays of children or
- * object keys are not valid. This allows us to keep track of children between
- * updates.
- */
-var ownerHasKeyUseWarning = {};
-
-function getCurrentComponentErrorInfo(parentType) {
- var info = getDeclarationErrorAddendum();
-
- if (!info) {
- var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
- if (parentName) {
- info = ' Check the top-level render call using <' + parentName + '>.';
- }
- }
- return info;
-}
-
-/**
- * Warn if the element doesn't have an explicit key assigned to it.
- * This element is in an array. The array could grow and shrink or be
- * reordered. All children that haven't already been validated are required to
- * have a "key" property assigned to it. Error statuses are cached so a warning
- * will only be shown once.
- *
- * @internal
- * @param {ReactElement} element Element that requires a key.
- * @param {*} parentType element's parent's type.
- */
-function validateExplicitKey(element, parentType) {
- if (!element._store || element._store.validated || element.key != null) {
- return;
- }
- element._store.validated = true;
-
- var memoizer = ownerHasKeyUseWarning.uniqueKey || (ownerHasKeyUseWarning.uniqueKey = {});
-
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
- if (memoizer[currentComponentErrorInfo]) {
- return;
- }
- memoizer[currentComponentErrorInfo] = true;
-
- // Usually the current owner is the offender, but if it accepts children as a
- // property, it may be the creator of the child that's responsible for
- // assigning it a key.
- var childOwner = '';
- if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
- // Give the component that originally created this child.
- childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
- }
-
- process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, ReactComponentTreeDevtool.getCurrentStackAddendum(element)) : void 0;
-}
-
-/**
- * Ensure that every element either is passed in a static location, in an
- * array with an explicit keys property defined, or in an object literal
- * with valid key property.
- *
- * @internal
- * @param {ReactNode} node Statically passed child of any type.
- * @param {*} parentType node's parent's type.
- */
-function validateChildKeys(node, parentType) {
- if (typeof node !== 'object') {
- return;
- }
- if (Array.isArray(node)) {
- for (var i = 0; i < node.length; i++) {
- var child = node[i];
- if (ReactElement.isValidElement(child)) {
- validateExplicitKey(child, parentType);
- }
- }
- } else if (ReactElement.isValidElement(node)) {
- // This element was passed in a valid location.
- if (node._store) {
- node._store.validated = true;
- }
- } else if (node) {
- var iteratorFn = getIteratorFn(node);
- // Entry iterators provide implicit keys.
- if (iteratorFn) {
- if (iteratorFn !== node.entries) {
- var iterator = iteratorFn.call(node);
- var step;
- while (!(step = iterator.next()).done) {
- if (ReactElement.isValidElement(step.value)) {
- validateExplicitKey(step.value, parentType);
- }
- }
- }
- }
- }
-}
-
-/**
- * Given an element, validate that its props follow the propTypes definition,
- * provided by the type.
- *
- * @param {ReactElement} element
- */
-function validatePropTypes(element) {
- var componentClass = element.type;
- if (typeof componentClass !== 'function') {
- return;
- }
- var name = componentClass.displayName || componentClass.name;
- if (componentClass.propTypes) {
- checkReactTypeSpec(componentClass.propTypes, element.props, ReactPropTypeLocations.prop, name, element, null);
- }
- if (typeof componentClass.getDefaultProps === 'function') {
- process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
- }
-}
-
-var ReactElementValidator = {
-
- createElement: function (type, props, children) {
- var validType = typeof type === 'string' || typeof type === 'function';
- // We warn in this case but don't throw. We expect the element creation to
- // succeed and there will likely be errors in render.
- process.env.NODE_ENV !== 'production' ? warning(validType, 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : void 0;
-
- var element = ReactElement.createElement.apply(this, arguments);
-
- // 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;
- }
-
- // Skip key warning if the type isn't valid since our key validation logic
- // doesn't expect a non-string/function type and can throw confusing errors.
- // We don't want exception behavior to differ between dev and prod.
- // (Rendering will throw with a helpful message and as soon as the type is
- // fixed, the key warnings will appear.)
- if (validType) {
- for (var i = 2; i < arguments.length; i++) {
- validateChildKeys(arguments[i], type);
- }
- }
-
- validatePropTypes(element);
-
- return element;
- },
-
- createFactory: function (type) {
- var validatedFactory = ReactElementValidator.createElement.bind(null, type);
- // Legacy hook TODO: Warn if this is accessed
- validatedFactory.type = type;
-
- if (process.env.NODE_ENV !== 'production') {
- if (canDefineProperty) {
- Object.defineProperty(validatedFactory, 'type', {
- enumerable: false,
- get: function () {
- process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : void 0;
- Object.defineProperty(this, 'type', {
- value: type
- });
- return type;
- }
- });
- }
- }
-
- return validatedFactory;
- },
-
- cloneElement: function (element, props, children) {
- var newElement = ReactElement.cloneElement.apply(this, arguments);
- for (var i = 2; i < arguments.length; i++) {
- validateChildKeys(arguments[i], newElement.type);
- }
- validatePropTypes(newElement);
- return newElement;
- }
-
-};
-
-module.exports = ReactElementValidator;
-}).call(this,require('_process'))
+var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
-},{"./ReactComponentTreeDevtool":55,"./ReactCurrentOwner":57,"./ReactElement":82,"./ReactPropTypeLocations":104,"./canDefineProperty":134,"./checkReactTypeSpec":135,"./getIteratorFn":147,"_process":15,"fbjs/lib/warning":188}],84:[function(require,module,exports){
+module.exports = REACT_ELEMENT_TYPE;
+},{}],95:[function(require,module,exports){
/**
* Copyright 2014-present, Facebook, Inc.
* All rights reserved.
@@ -22105,7 +21331,6 @@ module.exports = ReactElementValidator;
* 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';
@@ -22127,7 +21352,7 @@ var ReactEmptyComponent = {
ReactEmptyComponent.injection = ReactEmptyComponentInjection;
module.exports = ReactEmptyComponent;
-},{}],85:[function(require,module,exports){
+},{}],96:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -22137,7 +21362,7 @@ module.exports = ReactEmptyComponent;
* 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
+ *
*/
'use strict';
@@ -22147,19 +21372,18 @@ var caughtError = null;
/**
* Call a function while guarding against errors that happens within it.
*
- * @param {?String} name of the guard to use for logging or debugging
+ * @param {String} name of the guard to use for logging or debugging
* @param {Function} func The function to invoke
* @param {*} a First argument
* @param {*} b Second argument
*/
-function invokeGuardedCallback(name, func, a, b) {
+function invokeGuardedCallback(name, func, a) {
try {
- return func(a, b);
+ func(a);
} catch (x) {
if (caughtError === null) {
caughtError = x;
}
- return undefined;
}
}
@@ -22192,11 +21416,12 @@ if (process.env.NODE_ENV !== 'production') {
*/
if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
var fakeNode = document.createElement('react');
- ReactErrorUtils.invokeGuardedCallback = function (name, func, a, b) {
- var boundFunc = func.bind(null, a, b);
+ ReactErrorUtils.invokeGuardedCallback = function (name, func, a) {
+ var boundFunc = func.bind(null, a);
var evtType = 'react-' + name;
fakeNode.addEventListener(evtType, boundFunc, false);
var evt = document.createEvent('Event');
+ // $FlowFixMe https://github.com/facebook/flow/issues/2336
evt.initEvent(evtType, false, false);
fakeNode.dispatchEvent(evt);
fakeNode.removeEventListener(evtType, boundFunc, false);
@@ -22207,7 +21432,7 @@ if (process.env.NODE_ENV !== 'production') {
module.exports = ReactErrorUtils;
}).call(this,require('_process'))
-},{"_process":15}],86:[function(require,module,exports){
+},{"_process":43}],97:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -22216,7 +21441,6 @@ module.exports = ReactErrorUtils;
* 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
*/
'use strict';
@@ -22241,7 +21465,7 @@ var ReactEventEmitterMixin = {
};
module.exports = ReactEventEmitterMixin;
-},{"./EventPluginHub":38}],87:[function(require,module,exports){
+},{"./EventPluginHub":59}],98:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -22250,7 +21474,6 @@ module.exports = ReactEventEmitterMixin;
* 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
*/
'use strict';
@@ -22346,13 +21569,12 @@ var ReactEventListener = {
*
* @param {string} topLevelType Record from `EventConstants`.
* @param {string} handlerBaseName Event name (e.g. "click").
- * @param {object} handle Element on which to attach listener.
+ * @param {object} element Element on which to attach listener.
* @return {?object} An object with a remove function which will forcefully
* remove the listener.
* @internal
*/
- trapBubbledEvent: function (topLevelType, handlerBaseName, handle) {
- var element = handle;
+ trapBubbledEvent: function (topLevelType, handlerBaseName, element) {
if (!element) {
return null;
}
@@ -22364,13 +21586,12 @@ var ReactEventListener = {
*
* @param {string} topLevelType Record from `EventConstants`.
* @param {string} handlerBaseName Event name (e.g. "click").
- * @param {object} handle Element on which to attach listener.
+ * @param {object} element Element on which to attach listener.
* @return {?object} An object with a remove function which will forcefully
* remove the listener.
* @internal
*/
- trapCapturedEvent: function (topLevelType, handlerBaseName, handle) {
- var element = handle;
+ trapCapturedEvent: function (topLevelType, handlerBaseName, element) {
if (!element) {
return null;
}
@@ -22399,7 +21620,7 @@ var ReactEventListener = {
};
module.exports = ReactEventListener;
-},{"./PooledClass":46,"./ReactDOMComponentTree":62,"./ReactUpdates":112,"./getEventTarget":145,"fbjs/lib/EventListener":163,"fbjs/lib/ExecutionEnvironment":164,"fbjs/lib/getUnboundedScrollPosition":175,"object-assign":14}],88:[function(require,module,exports){
+},{"./PooledClass":67,"./ReactDOMComponentTree":76,"./ReactUpdates":120,"./getEventTarget":152,"fbjs/lib/EventListener":3,"fbjs/lib/ExecutionEnvironment":4,"fbjs/lib/getUnboundedScrollPosition":15,"object-assign":170}],99:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -22408,7 +21629,6 @@ module.exports = ReactEventListener;
* 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 ReactFeatureFlags
*
*/
@@ -22422,7 +21642,7 @@ var ReactFeatureFlags = {
};
module.exports = ReactFeatureFlags;
-},{}],89:[function(require,module,exports){
+},{}],100:[function(require,module,exports){
(function (process){
/**
* Copyright 2014-present, Facebook, Inc.
@@ -22432,19 +21652,15 @@ module.exports = ReactFeatureFlags;
* 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 ReactHostComponent
*/
'use strict';
-var _prodInvariant = require('./reactProdInvariant'),
- _assign = require('object-assign');
+var _prodInvariant = require('./reactProdInvariant');
var invariant = require('fbjs/lib/invariant');
var genericComponentClass = null;
-// This registry keeps track of wrapper classes around host tags.
-var tagToComponentClass = {};
var textComponentClass = null;
var ReactHostComponentInjection = {
@@ -22457,11 +21673,6 @@ var ReactHostComponentInjection = {
// rendered as props.
injectTextComponentClass: function (componentClass) {
textComponentClass = 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);
}
};
@@ -22502,7 +21713,7 @@ var ReactHostComponent = {
module.exports = ReactHostComponent;
}).call(this,require('_process'))
-},{"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"object-assign":14}],90:[function(require,module,exports){
+},{"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],101:[function(require,module,exports){
/**
* Copyright 2016-present, Facebook, Inc.
* All rights reserved.
@@ -22511,23 +21722,19 @@ module.exports = ReactHostComponent;
* 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 ReactHostOperationHistoryDevtool
+ *
*/
'use strict';
var history = [];
-var ReactHostOperationHistoryDevtool = {
- onHostOperation: function (debugID, type, payload) {
- history.push({
- instanceID: debugID,
- type: type,
- payload: payload
- });
+var ReactHostOperationHistoryHook = {
+ onHostOperation: function (operation) {
+ history.push(operation);
},
clearHistory: function () {
- if (ReactHostOperationHistoryDevtool._preventClearing) {
+ if (ReactHostOperationHistoryHook._preventClearing) {
// Should only be used for tests.
return;
}
@@ -22539,8 +21746,8 @@ var ReactHostOperationHistoryDevtool = {
}
};
-module.exports = ReactHostOperationHistoryDevtool;
-},{}],91:[function(require,module,exports){
+module.exports = ReactHostOperationHistoryHook;
+},{}],102:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -22549,7 +21756,6 @@ module.exports = ReactHostOperationHistoryDevtool;
* 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
*/
'use strict';
@@ -22558,7 +21764,6 @@ var DOMProperty = require('./DOMProperty');
var EventPluginHub = require('./EventPluginHub');
var EventPluginUtils = require('./EventPluginUtils');
var ReactComponentEnvironment = require('./ReactComponentEnvironment');
-var ReactClass = require('./ReactClass');
var ReactEmptyComponent = require('./ReactEmptyComponent');
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
var ReactHostComponent = require('./ReactHostComponent');
@@ -22566,7 +21771,6 @@ var ReactUpdates = require('./ReactUpdates');
var ReactInjection = {
Component: ReactComponentEnvironment.injection,
- Class: ReactClass.injection,
DOMProperty: DOMProperty.injection,
EmptyComponent: ReactEmptyComponent.injection,
EventPluginHub: EventPluginHub.injection,
@@ -22577,7 +21781,7 @@ var ReactInjection = {
};
module.exports = ReactInjection;
-},{"./DOMProperty":31,"./EventPluginHub":38,"./EventPluginUtils":40,"./ReactBrowserEventEmitter":48,"./ReactClass":51,"./ReactComponentEnvironment":54,"./ReactEmptyComponent":84,"./ReactHostComponent":89,"./ReactUpdates":112}],92:[function(require,module,exports){
+},{"./DOMProperty":54,"./EventPluginHub":59,"./EventPluginUtils":61,"./ReactBrowserEventEmitter":68,"./ReactComponentEnvironment":71,"./ReactEmptyComponent":95,"./ReactHostComponent":100,"./ReactUpdates":120}],103:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -22586,7 +21790,6 @@ module.exports = ReactInjection;
* 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
*/
'use strict';
@@ -22702,7 +21905,7 @@ var ReactInputSelection = {
};
module.exports = ReactInputSelection;
-},{"./ReactDOMSelection":74,"fbjs/lib/containsNode":167,"fbjs/lib/focusNode":172,"fbjs/lib/getActiveElement":173}],93:[function(require,module,exports){
+},{"./ReactDOMSelection":86,"fbjs/lib/containsNode":7,"fbjs/lib/focusNode":12,"fbjs/lib/getActiveElement":13}],104:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -22711,7 +21914,6 @@ module.exports = ReactInputSelection;
* 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 ReactInstanceMap
*/
'use strict';
@@ -22751,7 +21953,7 @@ var ReactInstanceMap = {
};
module.exports = ReactInstanceMap;
-},{}],94:[function(require,module,exports){
+},{}],105:[function(require,module,exports){
(function (process){
/**
* Copyright 2016-present, Facebook, Inc.
@@ -22761,11 +21963,13 @@ module.exports = ReactInstanceMap;
* 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 ReactInstrumentation
+ *
*/
'use strict';
+// Trust the developer to only use ReactInstrumentation with a __DEV__ check
+
var debugTool = null;
if (process.env.NODE_ENV !== 'production') {
@@ -22776,7 +21980,7 @@ if (process.env.NODE_ENV !== 'production') {
module.exports = { debugTool: debugTool };
}).call(this,require('_process'))
-},{"./ReactDebugTool":79,"_process":15}],95:[function(require,module,exports){
+},{"./ReactDebugTool":91,"_process":43}],106:[function(require,module,exports){
(function (process){
/**
* Copyright 2016-present, Facebook, Inc.
@@ -22786,7 +21990,7 @@ module.exports = { debugTool: debugTool };
* 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 ReactInvalidSetStateWarningDevTool
+ *
*/
'use strict';
@@ -22801,7 +22005,7 @@ if (process.env.NODE_ENV !== 'production') {
};
}
-var ReactInvalidSetStateWarningDevTool = {
+var ReactInvalidSetStateWarningHook = {
onBeginProcessingChildContext: function () {
processingChildContext = true;
},
@@ -22813,10 +22017,10 @@ var ReactInvalidSetStateWarningDevTool = {
}
};
-module.exports = ReactInvalidSetStateWarningDevTool;
+module.exports = ReactInvalidSetStateWarningHook;
}).call(this,require('_process'))
-},{"_process":15,"fbjs/lib/warning":188}],96:[function(require,module,exports){
+},{"_process":43,"fbjs/lib/warning":25}],107:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -22825,7 +22029,6 @@ module.exports = ReactInvalidSetStateWarningDevTool;
* 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
*/
'use strict';
@@ -22867,7 +22070,7 @@ var ReactMarkupChecksum = {
};
module.exports = ReactMarkupChecksum;
-},{"./adler32":133}],97:[function(require,module,exports){
+},{"./adler32":141}],108:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -22877,7 +22080,6 @@ module.exports = ReactMarkupChecksum;
* 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
*/
'use strict';
@@ -22886,12 +22088,12 @@ var _prodInvariant = require('./reactProdInvariant');
var DOMLazyTree = require('./DOMLazyTree');
var DOMProperty = require('./DOMProperty');
+var React = require('react/lib/React');
var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
-var ReactCurrentOwner = require('./ReactCurrentOwner');
+var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
var ReactDOMContainerInfo = require('./ReactDOMContainerInfo');
var ReactDOMFeatureFlags = require('./ReactDOMFeatureFlags');
-var ReactElement = require('./ReactElement');
var ReactFeatureFlags = require('./ReactFeatureFlags');
var ReactInstanceMap = require('./ReactInstanceMap');
var ReactInstrumentation = require('./ReactInstrumentation');
@@ -22967,13 +22169,14 @@ function internalGetID(node) {
function mountComponentIntoNode(wrapperInstance, container, transaction, shouldReuseMarkup, context) {
var markerName;
if (ReactFeatureFlags.logTopLevelRenders) {
- var wrappedElement = wrapperInstance._currentElement.props;
+ var wrappedElement = wrapperInstance._currentElement.props.child;
var type = wrappedElement.type;
markerName = 'React mount: ' + (typeof type === 'string' ? type : type.displayName || type.name);
console.time(markerName);
}
- var markup = ReactReconciler.mountComponent(wrapperInstance, transaction, null, ReactDOMContainerInfo(wrapperInstance, container), context);
+ var markup = ReactReconciler.mountComponent(wrapperInstance, transaction, null, ReactDOMContainerInfo(wrapperInstance, container), context, 0 /* parentDebugID */
+ );
if (markerName) {
console.timeEnd(markerName);
@@ -23044,6 +22247,41 @@ function hasNonRootReactChild(container) {
}
}
+/**
+ * True if the supplied DOM node is a React DOM element and
+ * it has been rendered by another copy of React.
+ *
+ * @param {?DOMElement} node The candidate DOM node.
+ * @return {boolean} True if the DOM has been rendered by another copy of React
+ * @internal
+ */
+function nodeIsRenderedByOtherInstance(container) {
+ var rootEl = getReactRootElementInContainer(container);
+ return !!(rootEl && isReactNode(rootEl) && !ReactDOMComponentTree.getInstanceFromNode(rootEl));
+}
+
+/**
+ * True if the supplied DOM node is a valid node element.
+ *
+ * @param {?DOMElement} node The candidate DOM node.
+ * @return {boolean} True if the DOM is a valid DOM node.
+ * @internal
+ */
+function isValidContainer(node) {
+ return !!(node && (node.nodeType === ELEMENT_NODE_TYPE || node.nodeType === DOC_NODE_TYPE || node.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE));
+}
+
+/**
+ * True if the supplied DOM node is a valid React node element.
+ *
+ * @param {?DOMElement} node The candidate DOM node.
+ * @return {boolean} True if the DOM is a valid React DOM node.
+ * @internal
+ */
+function isReactNode(node) {
+ return isValidContainer(node) && (node.hasAttribute(ROOT_ATTR_NAME) || node.hasAttribute(ATTR_NAME));
+}
+
function getHostRootInstanceInContainer(container) {
var rootEl = getReactRootElementInContainer(container);
var prevHostInstance = rootEl && ReactDOMComponentTree.getInstanceFromNode(rootEl);
@@ -23069,9 +22307,9 @@ if (process.env.NODE_ENV !== 'production') {
TopLevelWrapper.displayName = 'TopLevelWrapper';
}
TopLevelWrapper.prototype.render = function () {
- // this.props is actually a ReactElement
- return this.props;
+ return this.props.child;
};
+TopLevelWrapper.isReactTopLevelWrapper = true;
/**
* Mounting is the process of initializing a React component by creating its
@@ -23131,7 +22369,7 @@ var ReactMount = {
},
/**
- * Render a new component into the DOM. Hooked by devtools!
+ * Render a new component into the DOM. Hooked by hooks!
*
* @param {ReactElement} nextElement element to render
* @param {DOMElement} container container to render into
@@ -23144,7 +22382,7 @@ var ReactMount = {
// verify that that's the case.
process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '_renderNewRootComponent(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from ' + 'render is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : void 0;
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : _prodInvariant('37') : void 0;
+ !isValidContainer(container) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : _prodInvariant('37') : void 0;
ReactBrowserEventEmitter.ensureScrollValueMonitoring();
var componentInstance = instantiateReactComponent(nextElement, false);
@@ -23158,11 +22396,6 @@ var ReactMount = {
var wrapperID = componentInstance._instance.rootID;
instancesByReactRootID[wrapperID] = componentInstance;
- if (process.env.NODE_ENV !== 'production') {
- // The instance here is TopLevelWrapper so we report mount for its child.
- ReactInstrumentation.debugTool.onMountRootComponent(componentInstance._renderedComponent._debugID);
- }
-
return componentInstance;
},
@@ -23186,13 +22419,13 @@ var ReactMount = {
_renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
ReactUpdateQueue.validateCallback(callback, 'ReactDOM.render');
- !ReactElement.isValidElement(nextElement) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOM.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing a string like \'div\', pass ' + 'React.createElement(\'div\') or <div />.' : typeof nextElement === 'function' ? ' Instead of passing a class like Foo, pass ' + 'React.createElement(Foo) or <Foo />.' :
+ !React.isValidElement(nextElement) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOM.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing a string like \'div\', pass ' + 'React.createElement(\'div\') or <div />.' : typeof nextElement === 'function' ? ' Instead of passing a class like Foo, pass ' + 'React.createElement(Foo) or <Foo />.' :
// Check if it quacks like an element
nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : _prodInvariant('39', typeof nextElement === 'string' ? ' Instead of passing a string like \'div\', pass ' + 'React.createElement(\'div\') or <div />.' : typeof nextElement === 'function' ? ' Instead of passing a class like Foo, pass ' + 'React.createElement(Foo) or <Foo />.' : nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : void 0;
process.env.NODE_ENV !== 'production' ? warning(!container || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : void 0;
- var nextWrappedElement = ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
+ var nextWrappedElement = React.createElement(TopLevelWrapper, { child: nextElement });
var nextContext;
if (parentComponent) {
@@ -23206,7 +22439,7 @@ var ReactMount = {
if (prevComponent) {
var prevWrappedElement = prevComponent._currentElement;
- var prevElement = prevWrappedElement.props;
+ var prevElement = prevWrappedElement.props.child;
if (shouldUpdateReactComponent(prevElement, nextElement)) {
var publicInst = prevComponent._renderedComponent.getPublicInstance();
var updatedCallback = callback && function () {
@@ -23278,7 +22511,11 @@ var ReactMount = {
// render but we still don't expect to be in a render call here.)
process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, 'unmountComponentAtNode(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from render ' + 'is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : void 0;
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : _prodInvariant('40') : void 0;
+ !isValidContainer(container) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : _prodInvariant('40') : void 0;
+
+ if (process.env.NODE_ENV !== 'production') {
+ process.env.NODE_ENV !== 'production' ? warning(!nodeIsRenderedByOtherInstance(container), 'unmountComponentAtNode(): The node you\'re attempting to unmount ' + 'was rendered by another copy of React.') : void 0;
+ }
var prevComponent = getTopLevelWrapperInContainer(container);
if (!prevComponent) {
@@ -23301,7 +22538,7 @@ var ReactMount = {
},
_mountImageIntoNode: function (markup, container, instance, shouldReuseMarkup, transaction) {
- !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : _prodInvariant('41') : void 0;
+ !isValidContainer(container) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : _prodInvariant('41') : void 0;
if (shouldReuseMarkup) {
var rootElement = getReactRootElementInContainer(container);
@@ -23361,7 +22598,11 @@ var ReactMount = {
if (process.env.NODE_ENV !== 'production') {
var hostNode = ReactDOMComponentTree.getInstanceFromNode(container.firstChild);
if (hostNode._debugID !== 0) {
- ReactInstrumentation.debugTool.onHostOperation(hostNode._debugID, 'mount', markup.toString());
+ ReactInstrumentation.debugTool.onHostOperation({
+ instanceID: hostNode._debugID,
+ type: 'mount',
+ payload: markup.toString()
+ });
}
}
}
@@ -23370,7 +22611,7 @@ var ReactMount = {
module.exports = ReactMount;
}).call(this,require('_process'))
-},{"./DOMLazyTree":29,"./DOMProperty":31,"./ReactBrowserEventEmitter":48,"./ReactCurrentOwner":57,"./ReactDOMComponentTree":62,"./ReactDOMContainerInfo":63,"./ReactDOMFeatureFlags":67,"./ReactElement":82,"./ReactFeatureFlags":88,"./ReactInstanceMap":93,"./ReactInstrumentation":94,"./ReactMarkupChecksum":96,"./ReactReconciler":107,"./ReactUpdateQueue":111,"./ReactUpdates":112,"./instantiateReactComponent":151,"./reactProdInvariant":156,"./setInnerHTML":158,"./shouldUpdateReactComponent":160,"_process":15,"fbjs/lib/emptyObject":171,"fbjs/lib/invariant":178,"fbjs/lib/warning":188}],98:[function(require,module,exports){
+},{"./DOMLazyTree":52,"./DOMProperty":54,"./ReactBrowserEventEmitter":68,"./ReactDOMComponentTree":76,"./ReactDOMContainerInfo":77,"./ReactDOMFeatureFlags":79,"./ReactFeatureFlags":99,"./ReactInstanceMap":104,"./ReactInstrumentation":105,"./ReactMarkupChecksum":107,"./ReactReconciler":115,"./ReactUpdateQueue":119,"./ReactUpdates":120,"./instantiateReactComponent":159,"./reactProdInvariant":163,"./setInnerHTML":165,"./shouldUpdateReactComponent":167,"_process":43,"fbjs/lib/emptyObject":11,"fbjs/lib/invariant":18,"fbjs/lib/warning":25,"react/lib/React":187,"react/lib/ReactCurrentOwner":192}],109:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -23380,7 +22621,6 @@ module.exports = ReactMount;
* 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
*/
'use strict';
@@ -23390,9 +22630,8 @@ var _prodInvariant = require('./reactProdInvariant');
var ReactComponentEnvironment = require('./ReactComponentEnvironment');
var ReactInstanceMap = require('./ReactInstanceMap');
var ReactInstrumentation = require('./ReactInstrumentation');
-var ReactMultiChildUpdateTypes = require('./ReactMultiChildUpdateTypes');
-var ReactCurrentOwner = require('./ReactCurrentOwner');
+var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
var ReactReconciler = require('./ReactReconciler');
var ReactChildReconciler = require('./ReactChildReconciler');
@@ -23410,7 +22649,7 @@ var invariant = require('fbjs/lib/invariant');
function makeInsertMarkup(markup, afterNode, toIndex) {
// NOTE: Null values reduce hidden classes.
return {
- type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
+ type: 'INSERT_MARKUP',
content: markup,
fromIndex: null,
fromNode: null,
@@ -23429,7 +22668,7 @@ function makeInsertMarkup(markup, afterNode, toIndex) {
function makeMove(child, afterNode, toIndex) {
// NOTE: Null values reduce hidden classes.
return {
- type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
+ type: 'MOVE_EXISTING',
content: null,
fromIndex: child._mountIndex,
fromNode: ReactReconciler.getHostNode(child),
@@ -23447,7 +22686,7 @@ function makeMove(child, afterNode, toIndex) {
function makeRemove(child, node) {
// NOTE: Null values reduce hidden classes.
return {
- type: ReactMultiChildUpdateTypes.REMOVE_NODE,
+ type: 'REMOVE_NODE',
content: null,
fromIndex: child._mountIndex,
fromNode: node,
@@ -23465,7 +22704,7 @@ function makeRemove(child, node) {
function makeSetMarkup(markup) {
// NOTE: Null values reduce hidden classes.
return {
- type: ReactMultiChildUpdateTypes.SET_MARKUP,
+ type: 'SET_MARKUP',
content: markup,
fromIndex: null,
fromNode: null,
@@ -23483,7 +22722,7 @@ function makeSetMarkup(markup) {
function makeTextContent(textContent) {
// NOTE: Null values reduce hidden classes.
return {
- type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
+ type: 'TEXT_CONTENT',
content: textContent,
fromIndex: null,
fromNode: null,
@@ -23513,7 +22752,6 @@ function processQueue(inst, updateQueue) {
ReactComponentEnvironment.processChildrenUpdates(inst, updateQueue);
}
-var setParentForInstrumentation = emptyFunction;
var setChildrenForInstrumentation = emptyFunction;
if (process.env.NODE_ENV !== 'production') {
var getDebugID = function (inst) {
@@ -23526,11 +22764,6 @@ if (process.env.NODE_ENV !== 'production') {
}
return inst._debugID;
};
- setParentForInstrumentation = function (child) {
- if (child._debugID !== 0) {
- ReactInstrumentation.debugTool.onSetParent(child._debugID, getDebugID(this));
- }
- };
setChildrenForInstrumentation = function (children) {
var debugID = getDebugID(this);
// TODO: React Native empty components are also multichild.
@@ -23562,10 +22795,11 @@ var ReactMultiChild = {
_reconcilerInstantiateChildren: function (nestedChildren, transaction, context) {
if (process.env.NODE_ENV !== 'production') {
+ var selfDebugID = getDebugID(this);
if (this._currentElement) {
try {
ReactCurrentOwner.current = this._currentElement._owner;
- return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context, this._debugID);
+ return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context, selfDebugID);
} finally {
ReactCurrentOwner.current = null;
}
@@ -23574,22 +22808,24 @@ var ReactMultiChild = {
return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
},
- _reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, removedNodes, transaction, context) {
+ _reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context) {
var nextChildren;
+ var selfDebugID = 0;
if (process.env.NODE_ENV !== 'production') {
+ selfDebugID = getDebugID(this);
if (this._currentElement) {
try {
ReactCurrentOwner.current = this._currentElement._owner;
- nextChildren = flattenChildren(nextNestedChildrenElements, this._debugID);
+ nextChildren = flattenChildren(nextNestedChildrenElements, selfDebugID);
} finally {
ReactCurrentOwner.current = null;
}
- ReactChildReconciler.updateChildren(prevChildren, nextChildren, removedNodes, transaction, context);
+ ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID);
return nextChildren;
}
}
- nextChildren = flattenChildren(nextNestedChildrenElements);
- ReactChildReconciler.updateChildren(prevChildren, nextChildren, removedNodes, transaction, context);
+ nextChildren = flattenChildren(nextNestedChildrenElements, selfDebugID);
+ ReactChildReconciler.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID);
return nextChildren;
},
@@ -23610,10 +22846,11 @@ var ReactMultiChild = {
for (var name in children) {
if (children.hasOwnProperty(name)) {
var child = children[name];
+ var selfDebugID = 0;
if (process.env.NODE_ENV !== 'production') {
- setParentForInstrumentation.call(this, child);
+ selfDebugID = getDebugID(this);
}
- var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._hostContainerInfo, context);
+ var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._hostContainerInfo, context, selfDebugID);
child._mountIndex = index++;
mountImages.push(mountImage);
}
@@ -23686,7 +22923,8 @@ var ReactMultiChild = {
_updateChildren: function (nextNestedChildrenElements, transaction, context) {
var prevChildren = this._renderedChildren;
var removedNodes = {};
- var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, removedNodes, transaction, context);
+ var mountImages = [];
+ var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context);
if (!nextChildren && !prevChildren) {
return;
}
@@ -23694,8 +22932,10 @@ var ReactMultiChild = {
var name;
// `nextIndex` will increment for each child in `nextChildren`, but
// `lastIndex` will be the last index visited in `prevChildren`.
- var lastIndex = 0;
var nextIndex = 0;
+ var lastIndex = 0;
+ // `nextMountIndex` will increment for each newly mounted child.
+ var nextMountIndex = 0;
var lastPlacedNode = null;
for (name in nextChildren) {
if (!nextChildren.hasOwnProperty(name)) {
@@ -23714,7 +22954,8 @@ var ReactMultiChild = {
// The `removedNodes` loop below will actually remove the child.
}
// The child must be instantiated before it's mounted.
- updates = enqueue(updates, this._mountChildAtIndex(nextChild, lastPlacedNode, nextIndex, transaction, context));
+ updates = enqueue(updates, this._mountChildAtIndex(nextChild, mountImages[nextMountIndex], lastPlacedNode, nextIndex, transaction, context));
+ nextMountIndex++;
}
nextIndex++;
lastPlacedNode = ReactReconciler.getHostNode(nextChild);
@@ -23797,8 +23038,7 @@ var ReactMultiChild = {
* @param {ReactReconcileTransaction} transaction
* @private
*/
- _mountChildAtIndex: function (child, afterNode, index, transaction, context) {
- var mountImage = ReactReconciler.mountComponent(child, transaction, this, this._hostContainerInfo, context);
+ _mountChildAtIndex: function (child, mountImage, afterNode, index, transaction, context) {
child._mountIndex = index;
return this.createChild(child, afterNode, mountImage);
},
@@ -23824,40 +23064,7 @@ var ReactMultiChild = {
module.exports = ReactMultiChild;
}).call(this,require('_process'))
-},{"./ReactChildReconciler":49,"./ReactComponentEnvironment":54,"./ReactCurrentOwner":57,"./ReactInstanceMap":93,"./ReactInstrumentation":94,"./ReactMultiChildUpdateTypes":99,"./ReactReconciler":107,"./flattenChildren":140,"./reactProdInvariant":156,"_process":15,"fbjs/lib/emptyFunction":170,"fbjs/lib/invariant":178}],99:[function(require,module,exports){
-/**
- * Copyright 2013-present, 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 ReactMultiChildUpdateTypes
- */
-
-'use strict';
-
-var keyMirror = require('fbjs/lib/keyMirror');
-
-/**
- * When a component's children are updated, a series of update configuration
- * objects are created in order to batch and serialize the required changes.
- *
- * Enumerates all the possible types of update configurations.
- *
- * @internal
- */
-var ReactMultiChildUpdateTypes = keyMirror({
- INSERT_MARKUP: null,
- MOVE_EXISTING: null,
- REMOVE_NODE: null,
- SET_MARKUP: null,
- TEXT_CONTENT: null
-});
-
-module.exports = ReactMultiChildUpdateTypes;
-},{"fbjs/lib/keyMirror":181}],100:[function(require,module,exports){
+},{"./ReactChildReconciler":69,"./ReactComponentEnvironment":71,"./ReactInstanceMap":104,"./ReactInstrumentation":105,"./ReactReconciler":115,"./flattenChildren":147,"./reactProdInvariant":163,"_process":43,"fbjs/lib/emptyFunction":10,"fbjs/lib/invariant":18,"react/lib/ReactCurrentOwner":192}],110:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -23867,7 +23074,6 @@ module.exports = ReactMultiChildUpdateTypes;
* 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 ReactNodeTypes
*
*/
@@ -23875,7 +23081,7 @@ module.exports = ReactMultiChildUpdateTypes;
var _prodInvariant = require('./reactProdInvariant');
-var ReactElement = require('./ReactElement');
+var React = require('react/lib/React');
var invariant = require('fbjs/lib/invariant');
@@ -23887,7 +23093,7 @@ var ReactNodeTypes = {
getType: function (node) {
if (node === null || node === false) {
return ReactNodeTypes.EMPTY;
- } else if (ReactElement.isValidElement(node)) {
+ } else if (React.isValidElement(node)) {
if (typeof node.type === 'function') {
return ReactNodeTypes.COMPOSITE;
} else {
@@ -23901,107 +23107,7 @@ var ReactNodeTypes = {
module.exports = ReactNodeTypes;
}).call(this,require('_process'))
-},{"./ReactElement":82,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],101:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2015-present, 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 ReactNoopUpdateQueue
- */
-
-'use strict';
-
-var warning = require('fbjs/lib/warning');
-
-function warnNoop(publicInstance, callerName) {
- if (process.env.NODE_ENV !== 'production') {
- var constructor = publicInstance.constructor;
- process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, constructor && (constructor.displayName || constructor.name) || 'ReactClass') : void 0;
- }
-}
-
-/**
- * This is the abstract API for an update queue.
- */
-var ReactNoopUpdateQueue = {
-
- /**
- * Checks whether or not this composite component is mounted.
- * @param {ReactClass} publicInstance The instance we want to test.
- * @return {boolean} True if mounted, false otherwise.
- * @protected
- * @final
- */
- isMounted: function (publicInstance) {
- return false;
- },
-
- /**
- * Enqueue a callback that will be executed after all the pending updates
- * have processed.
- *
- * @param {ReactClass} publicInstance The instance to use as `this` context.
- * @param {?function} callback Called after state is updated.
- * @internal
- */
- enqueueCallback: function (publicInstance, callback) {},
-
- /**
- * Forces an update. This should only be invoked when it is known with
- * certainty that we are **not** in a DOM transaction.
- *
- * You may want to call this when you know that some deeper aspect of the
- * component's state has changed but `setState` was not called.
- *
- * This will not invoke `shouldComponentUpdate`, but it will invoke
- * `componentWillUpdate` and `componentDidUpdate`.
- *
- * @param {ReactClass} publicInstance The instance that should rerender.
- * @internal
- */
- enqueueForceUpdate: function (publicInstance) {
- warnNoop(publicInstance, 'forceUpdate');
- },
-
- /**
- * Replaces all of the state. Always use this or `setState` to mutate state.
- * You should treat `this.state` as immutable.
- *
- * There is no guarantee that `this.state` will be immediately updated, so
- * accessing `this.state` after calling this method may return the old value.
- *
- * @param {ReactClass} publicInstance The instance that should rerender.
- * @param {object} completeState Next state.
- * @internal
- */
- enqueueReplaceState: function (publicInstance, completeState) {
- warnNoop(publicInstance, 'replaceState');
- },
-
- /**
- * Sets a subset of the state. This only exists because _pendingState is
- * internal. This provides a merging strategy that is not available to deep
- * properties which is confusing. TODO: Expose pendingState or don't use it
- * during the merge.
- *
- * @param {ReactClass} publicInstance The instance that should rerender.
- * @param {object} partialState Next partial state to be merged with state.
- * @internal
- */
- enqueueSetState: function (publicInstance, partialState) {
- warnNoop(publicInstance, 'setState');
- }
-};
-
-module.exports = ReactNoopUpdateQueue;
-}).call(this,require('_process'))
-
-},{"_process":15,"fbjs/lib/warning":188}],102:[function(require,module,exports){
+},{"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18,"react/lib/React":187}],111:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -24011,7 +23117,7 @@ module.exports = ReactNoopUpdateQueue;
* 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
+ *
*/
'use strict';
@@ -24021,6 +23127,15 @@ var _prodInvariant = require('./reactProdInvariant');
var invariant = require('fbjs/lib/invariant');
/**
+ * @param {?object} object
+ * @return {boolean} True if `object` is a valid owner.
+ * @final
+ */
+function isValidOwner(object) {
+ return !!(object && typeof object.attachRef === 'function' && typeof object.detachRef === 'function');
+}
+
+/**
* ReactOwners are capable of storing references to owned components.
*
* All components are capable of //being// referenced by owner components, but
@@ -24051,16 +23166,6 @@ var invariant = require('fbjs/lib/invariant');
* @class ReactOwner
*/
var ReactOwner = {
-
- /**
- * @param {?object} object
- * @return {boolean} True if `object` is a valid owner.
- * @final
- */
- isValidOwner: function (object) {
- return !!(object && typeof object.attachRef === 'function' && typeof object.detachRef === 'function');
- },
-
/**
* Adds a component by ref to an owner component.
*
@@ -24071,7 +23176,7 @@ var ReactOwner = {
* @internal
*/
addComponentAsRefTo: function (component, ref, owner) {
- !ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component\'s `render` method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).') : _prodInvariant('119') : void 0;
+ !isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component\'s `render` method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).') : _prodInvariant('119') : void 0;
owner.attachRef(ref, component);
},
@@ -24085,7 +23190,7 @@ var ReactOwner = {
* @internal
*/
removeComponentAsRefFrom: function (component, ref, owner) {
- !ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might be removing a ref to a component that was not created inside a component\'s `render` method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).') : _prodInvariant('120') : void 0;
+ !isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might be removing a ref to a component that was not created inside a component\'s `render` method, or you have multiple copies of React loaded (details: https://fb.me/react-refs-must-have-owner).') : _prodInvariant('120') : void 0;
var ownerPublicInstance = owner.getPublicInstance();
// Check that `component`'s owner is still alive and that `component` is still the current ref
// because we do not want to detach the ref if another component stole it.
@@ -24099,7 +23204,7 @@ var ReactOwner = {
module.exports = ReactOwner;
}).call(this,require('_process'))
-},{"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],103:[function(require,module,exports){
+},{"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],112:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -24109,7 +23214,7 @@ module.exports = ReactOwner;
* 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
+ *
*/
'use strict';
@@ -24127,7 +23232,7 @@ if (process.env.NODE_ENV !== 'production') {
module.exports = ReactPropTypeLocationNames;
}).call(this,require('_process'))
-},{"_process":15}],104:[function(require,module,exports){
+},{"_process":43}],113:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -24136,425 +23241,15 @@ module.exports = ReactPropTypeLocationNames;
* 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
- */
-
-'use strict';
-
-var keyMirror = require('fbjs/lib/keyMirror');
-
-var ReactPropTypeLocations = keyMirror({
- prop: null,
- context: null,
- childContext: null
-});
-
-module.exports = ReactPropTypeLocations;
-},{"fbjs/lib/keyMirror":181}],105:[function(require,module,exports){
-/**
- * Copyright 2013-present, 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 ReactPropTypes
+ *
*/
'use strict';
-var ReactElement = require('./ReactElement');
-var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
-
-var emptyFunction = require('fbjs/lib/emptyFunction');
-var getIteratorFn = require('./getIteratorFn');
-
-/**
- * Collection of methods that allow declaration and validation of props that are
- * supplied to React components. Example usage:
- *
- * var Props = require('ReactPropTypes');
- * var MyArticle = React.createClass({
- * propTypes: {
- * // An optional string prop named "description".
- * description: Props.string,
- *
- * // A required enum prop named "category".
- * category: Props.oneOf(['News','Photos']).isRequired,
- *
- * // A prop named "dialog" that requires an instance of Dialog.
- * dialog: Props.instanceOf(Dialog).isRequired
- * },
- * render: function() { ... }
- * });
- *
- * A more formal specification of how these methods are used:
- *
- * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
- * decl := ReactPropTypes.{type}(.isRequired)?
- *
- * Each and every declaration produces a function with the same signature. This
- * allows the creation of custom validation functions. For example:
- *
- * var MyLink = React.createClass({
- * propTypes: {
- * // An optional string or URI prop named "href".
- * href: function(props, propName, componentName) {
- * var propValue = props[propName];
- * if (propValue != null && typeof propValue !== 'string' &&
- * !(propValue instanceof URI)) {
- * return new Error(
- * 'Expected a string or an URI for ' + propName + ' in ' +
- * componentName
- * );
- * }
- * }
- * },
- * render: function() {...}
- * });
- *
- * @internal
- */
-
-var ANONYMOUS = '<<anonymous>>';
-
-var ReactPropTypes = {
- array: createPrimitiveTypeChecker('array'),
- bool: createPrimitiveTypeChecker('boolean'),
- func: createPrimitiveTypeChecker('function'),
- number: createPrimitiveTypeChecker('number'),
- object: createPrimitiveTypeChecker('object'),
- string: createPrimitiveTypeChecker('string'),
- symbol: createPrimitiveTypeChecker('symbol'),
-
- any: createAnyTypeChecker(),
- arrayOf: createArrayOfTypeChecker,
- element: createElementTypeChecker(),
- instanceOf: createInstanceTypeChecker,
- node: createNodeChecker(),
- objectOf: createObjectOfTypeChecker,
- oneOf: createEnumTypeChecker,
- oneOfType: createUnionTypeChecker,
- shape: createShapeTypeChecker
-};
-
-/**
- * inlined Object.is polyfill to avoid requiring consumers ship their own
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
- */
-/*eslint-disable no-self-compare*/
-function is(x, y) {
- // SameValue algorithm
- if (x === y) {
- // Steps 1-5, 7-10
- // Steps 6.b-6.e: +0 != -0
- return x !== 0 || 1 / x === 1 / y;
- } else {
- // Step 6.a: NaN == NaN
- return x !== x && y !== y;
- }
-}
-/*eslint-enable no-self-compare*/
-
-function createChainableTypeChecker(validate) {
- function checkType(isRequired, props, propName, componentName, location, propFullName) {
- componentName = componentName || ANONYMOUS;
- propFullName = propFullName || propName;
- if (props[propName] == null) {
- var locationName = ReactPropTypeLocationNames[location];
- if (isRequired) {
- return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.'));
- }
- return null;
- } else {
- return validate(props, propName, componentName, location, propFullName);
- }
- }
-
- var chainedCheckType = checkType.bind(null, false);
- chainedCheckType.isRequired = checkType.bind(null, true);
-
- return chainedCheckType;
-}
-
-function createPrimitiveTypeChecker(expectedType) {
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== expectedType) {
- var locationName = ReactPropTypeLocationNames[location];
- // `propValue` being instance of, say, date/regexp, pass the 'object'
- // check, but we can offer a more precise error message here rather than
- // 'of type `object`'.
- var preciseType = getPreciseType(propValue);
-
- return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
-}
-
-function createAnyTypeChecker() {
- return createChainableTypeChecker(emptyFunction.thatReturns(null));
-}
-
-function createArrayOfTypeChecker(typeChecker) {
- function validate(props, propName, componentName, location, propFullName) {
- if (typeof typeChecker !== 'function') {
- return new Error('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
- }
- var propValue = props[propName];
- if (!Array.isArray(propValue)) {
- var locationName = ReactPropTypeLocationNames[location];
- var propType = getPropType(propValue);
- return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
- }
- for (var i = 0; i < propValue.length; i++) {
- var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']');
- if (error instanceof Error) {
- return error;
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
-}
-
-function createElementTypeChecker() {
- function validate(props, propName, componentName, location, propFullName) {
- if (!ReactElement.isValidElement(props[propName])) {
- var locationName = ReactPropTypeLocationNames[location];
- return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a single ReactElement.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
-}
-
-function createInstanceTypeChecker(expectedClass) {
- function validate(props, propName, componentName, location, propFullName) {
- if (!(props[propName] instanceof expectedClass)) {
- var locationName = ReactPropTypeLocationNames[location];
- var expectedClassName = expectedClass.name || ANONYMOUS;
- var actualClassName = getClassName(props[propName]);
- return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
-}
-
-function createEnumTypeChecker(expectedValues) {
- if (!Array.isArray(expectedValues)) {
- return createChainableTypeChecker(function () {
- return new Error('Invalid argument supplied to oneOf, expected an instance of array.');
- });
- }
-
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- for (var i = 0; i < expectedValues.length; i++) {
- if (is(propValue, expectedValues[i])) {
- return null;
- }
- }
-
- var locationName = ReactPropTypeLocationNames[location];
- var valuesString = JSON.stringify(expectedValues);
- return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
- }
- return createChainableTypeChecker(validate);
-}
-
-function createObjectOfTypeChecker(typeChecker) {
- function validate(props, propName, componentName, location, propFullName) {
- if (typeof typeChecker !== 'function') {
- return new Error('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
- }
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== 'object') {
- var locationName = ReactPropTypeLocationNames[location];
- return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
- }
- for (var key in propValue) {
- if (propValue.hasOwnProperty(key)) {
- var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key);
- if (error instanceof Error) {
- return error;
- }
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
-}
-
-function createUnionTypeChecker(arrayOfTypeCheckers) {
- if (!Array.isArray(arrayOfTypeCheckers)) {
- return createChainableTypeChecker(function () {
- return new Error('Invalid argument supplied to oneOfType, expected an instance of array.');
- });
- }
-
- function validate(props, propName, componentName, location, propFullName) {
- for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
- var checker = arrayOfTypeCheckers[i];
- if (checker(props, propName, componentName, location, propFullName) == null) {
- return null;
- }
- }
-
- var locationName = ReactPropTypeLocationNames[location];
- return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
- }
- return createChainableTypeChecker(validate);
-}
-
-function createNodeChecker() {
- function validate(props, propName, componentName, location, propFullName) {
- if (!isNode(props[propName])) {
- var locationName = ReactPropTypeLocationNames[location];
- return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
- }
- return null;
- }
- return createChainableTypeChecker(validate);
-}
-
-function createShapeTypeChecker(shapeTypes) {
- function validate(props, propName, componentName, location, propFullName) {
- var propValue = props[propName];
- var propType = getPropType(propValue);
- if (propType !== 'object') {
- var locationName = ReactPropTypeLocationNames[location];
- return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
- }
- for (var key in shapeTypes) {
- var checker = shapeTypes[key];
- if (!checker) {
- continue;
- }
- var error = checker(propValue, key, componentName, location, propFullName + '.' + key);
- if (error) {
- return error;
- }
- }
- return null;
- }
- return createChainableTypeChecker(validate);
-}
-
-function isNode(propValue) {
- switch (typeof propValue) {
- case 'number':
- case 'string':
- case 'undefined':
- return true;
- case 'boolean':
- return !propValue;
- case 'object':
- if (Array.isArray(propValue)) {
- return propValue.every(isNode);
- }
- if (propValue === null || ReactElement.isValidElement(propValue)) {
- return true;
- }
-
- var iteratorFn = getIteratorFn(propValue);
- if (iteratorFn) {
- var iterator = iteratorFn.call(propValue);
- var step;
- if (iteratorFn !== propValue.entries) {
- while (!(step = iterator.next()).done) {
- if (!isNode(step.value)) {
- return false;
- }
- }
- } else {
- // Iterator will provide entry [k,v] tuples rather than values.
- while (!(step = iterator.next()).done) {
- var entry = step.value;
- if (entry) {
- if (!isNode(entry[1])) {
- return false;
- }
- }
- }
- }
- } else {
- return false;
- }
-
- return true;
- default:
- return false;
- }
-}
-
-function isSymbol(propType, propValue) {
- // Native Symbol.
- if (propType === 'symbol') {
- return true;
- }
-
- // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
- if (propValue['@@toStringTag'] === 'Symbol') {
- return true;
- }
-
- // Fallback for non-spec compliant Symbols which are polyfilled.
- if (typeof Symbol === 'function' && propValue instanceof Symbol) {
- return true;
- }
-
- return false;
-}
-
-// Equivalent of `typeof` but with special handling for array and regexp.
-function getPropType(propValue) {
- var propType = typeof propValue;
- if (Array.isArray(propValue)) {
- return 'array';
- }
- if (propValue instanceof RegExp) {
- // Old webkits (at least until Android 4.0) return 'function' rather than
- // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
- // passes PropTypes.object.
- return 'object';
- }
- if (isSymbol(propType, propValue)) {
- return 'symbol';
- }
- return propType;
-}
-
-// This handles more types than `getPropType`. Only used for error messages.
-// See `createPrimitiveTypeChecker`.
-function getPreciseType(propValue) {
- var propType = getPropType(propValue);
- if (propType === 'object') {
- if (propValue instanceof Date) {
- return 'date';
- } else if (propValue instanceof RegExp) {
- return 'regexp';
- }
- }
- return propType;
-}
-
-// Returns class name of the object, if any.
-function getClassName(propValue) {
- if (!propValue.constructor || !propValue.constructor.name) {
- return ANONYMOUS;
- }
- return propValue.constructor.name;
-}
+var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
-module.exports = ReactPropTypes;
-},{"./ReactElement":82,"./ReactPropTypeLocationNames":103,"./getIteratorFn":147,"fbjs/lib/emptyFunction":170}],106:[function(require,module,exports){
+module.exports = ReactPropTypesSecret;
+},{}],114:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -24564,7 +23259,6 @@ module.exports = ReactPropTypes;
* 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
*/
'use strict';
@@ -24729,14 +23423,14 @@ var Mixin = {
}
};
-_assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
+_assign(ReactReconcileTransaction.prototype, Transaction, Mixin);
PooledClass.addPoolingTo(ReactReconcileTransaction);
module.exports = ReactReconcileTransaction;
}).call(this,require('_process'))
-},{"./CallbackQueue":26,"./PooledClass":46,"./ReactBrowserEventEmitter":48,"./ReactInputSelection":92,"./ReactInstrumentation":94,"./ReactUpdateQueue":111,"./Transaction":130,"_process":15,"object-assign":14}],107:[function(require,module,exports){
+},{"./CallbackQueue":49,"./PooledClass":67,"./ReactBrowserEventEmitter":68,"./ReactInputSelection":103,"./ReactInstrumentation":105,"./ReactUpdateQueue":119,"./Transaction":138,"_process":43,"object-assign":170}],115:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -24746,17 +23440,14 @@ module.exports = ReactReconcileTransaction;
* 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 ReactReconciler
*/
'use strict';
-var _prodInvariant = require('./reactProdInvariant');
-
var ReactRef = require('./ReactRef');
var ReactInstrumentation = require('./ReactInstrumentation');
-var invariant = require('fbjs/lib/invariant');
+var warning = require('fbjs/lib/warning');
/**
* Helper to call ReactRef.attachRefs with this composite component, split out
@@ -24779,20 +23470,19 @@ var ReactReconciler = {
* @final
* @internal
*/
- mountComponent: function (internalInstance, transaction, hostParent, hostContainerInfo, context) {
+ mountComponent: function (internalInstance, transaction, hostParent, hostContainerInfo, context, parentDebugID // 0 in production and for roots
+ ) {
if (process.env.NODE_ENV !== 'production') {
if (internalInstance._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeforeMountComponent(internalInstance._debugID, internalInstance._currentElement);
- ReactInstrumentation.debugTool.onBeginReconcilerTimer(internalInstance._debugID, 'mountComponent');
+ ReactInstrumentation.debugTool.onBeforeMountComponent(internalInstance._debugID, internalInstance._currentElement, parentDebugID);
}
}
- var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context);
+ var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context, parentDebugID);
if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
}
if (process.env.NODE_ENV !== 'production') {
if (internalInstance._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndReconcilerTimer(internalInstance._debugID, 'mountComponent');
ReactInstrumentation.debugTool.onMountComponent(internalInstance._debugID);
}
}
@@ -24816,14 +23506,13 @@ var ReactReconciler = {
unmountComponent: function (internalInstance, safely) {
if (process.env.NODE_ENV !== 'production') {
if (internalInstance._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginReconcilerTimer(internalInstance._debugID, 'unmountComponent');
+ ReactInstrumentation.debugTool.onBeforeUnmountComponent(internalInstance._debugID);
}
}
ReactRef.detachRefs(internalInstance, internalInstance._currentElement);
internalInstance.unmountComponent(safely);
if (process.env.NODE_ENV !== 'production') {
if (internalInstance._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndReconcilerTimer(internalInstance._debugID, 'unmountComponent');
ReactInstrumentation.debugTool.onUnmountComponent(internalInstance._debugID);
}
}
@@ -24858,7 +23547,6 @@ var ReactReconciler = {
if (process.env.NODE_ENV !== 'production') {
if (internalInstance._debugID !== 0) {
ReactInstrumentation.debugTool.onBeforeUpdateComponent(internalInstance._debugID, nextElement);
- ReactInstrumentation.debugTool.onBeginReconcilerTimer(internalInstance._debugID, 'receiveComponent');
}
}
@@ -24876,7 +23564,6 @@ var ReactReconciler = {
if (process.env.NODE_ENV !== 'production') {
if (internalInstance._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndReconcilerTimer(internalInstance._debugID, 'receiveComponent');
ReactInstrumentation.debugTool.onUpdateComponent(internalInstance._debugID);
}
}
@@ -24893,19 +23580,17 @@ var ReactReconciler = {
if (internalInstance._updateBatchNumber !== updateBatchNumber) {
// The component's enqueued batch number should always be the current
// batch or the following one.
- !(internalInstance._updateBatchNumber == null || internalInstance._updateBatchNumber === updateBatchNumber + 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'performUpdateIfNecessary: Unexpected batch number (current %s, pending %s)', updateBatchNumber, internalInstance._updateBatchNumber) : _prodInvariant('121', updateBatchNumber, internalInstance._updateBatchNumber) : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(internalInstance._updateBatchNumber == null || internalInstance._updateBatchNumber === updateBatchNumber + 1, 'performUpdateIfNecessary: Unexpected batch number (current %s, ' + 'pending %s)', updateBatchNumber, internalInstance._updateBatchNumber) : void 0;
return;
}
if (process.env.NODE_ENV !== 'production') {
if (internalInstance._debugID !== 0) {
- ReactInstrumentation.debugTool.onBeginReconcilerTimer(internalInstance._debugID, 'performUpdateIfNecessary');
ReactInstrumentation.debugTool.onBeforeUpdateComponent(internalInstance._debugID, internalInstance._currentElement);
}
}
internalInstance.performUpdateIfNecessary(transaction);
if (process.env.NODE_ENV !== 'production') {
if (internalInstance._debugID !== 0) {
- ReactInstrumentation.debugTool.onEndReconcilerTimer(internalInstance._debugID, 'performUpdateIfNecessary');
ReactInstrumentation.debugTool.onUpdateComponent(internalInstance._debugID);
}
}
@@ -24916,7 +23601,7 @@ var ReactReconciler = {
module.exports = ReactReconciler;
}).call(this,require('_process'))
-},{"./ReactInstrumentation":94,"./ReactRef":108,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],108:[function(require,module,exports){
+},{"./ReactInstrumentation":105,"./ReactRef":116,"_process":43,"fbjs/lib/warning":25}],116:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -24925,7 +23610,7 @@ module.exports = ReactReconciler;
* 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 ReactRef
+ *
*/
'use strict';
@@ -24953,7 +23638,7 @@ function detachRef(ref, component, owner) {
}
ReactRef.attachRefs = function (instance, element) {
- if (element === null || element === false) {
+ if (element === null || typeof element !== 'object') {
return;
}
var ref = element.ref;
@@ -24975,17 +23660,27 @@ ReactRef.shouldUpdateRefs = function (prevElement, nextElement) {
// is made. It probably belongs where the key checking and
// instantiateReactComponent is done.
- var prevEmpty = prevElement === null || prevElement === false;
- var nextEmpty = nextElement === null || nextElement === false;
+ var prevRef = null;
+ var prevOwner = null;
+ if (prevElement !== null && typeof prevElement === 'object') {
+ prevRef = prevElement.ref;
+ prevOwner = prevElement._owner;
+ }
- return(
- // This has a few false positives w/r/t empty components.
- prevEmpty || nextEmpty || nextElement._owner !== prevElement._owner || nextElement.ref !== prevElement.ref
- );
+ var nextRef = null;
+ var nextOwner = null;
+ if (nextElement !== null && typeof nextElement === 'object') {
+ nextRef = nextElement.ref;
+ nextOwner = nextElement._owner;
+ }
+
+ return prevRef !== nextRef ||
+ // If owner changes but we have an unchanged function ref, don't update refs
+ typeof nextRef === 'string' && nextOwner !== prevOwner;
};
ReactRef.detachRefs = function (instance, element) {
- if (element === null || element === false) {
+ if (element === null || typeof element !== 'object') {
return;
}
var ref = element.ref;
@@ -24995,7 +23690,7 @@ ReactRef.detachRefs = function (instance, element) {
};
module.exports = ReactRef;
-},{"./ReactOwner":102}],109:[function(require,module,exports){
+},{"./ReactOwner":111}],117:[function(require,module,exports){
(function (process){
/**
* Copyright 2014-present, Facebook, Inc.
@@ -25005,7 +23700,6 @@ module.exports = ReactRef;
* 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
*/
'use strict';
@@ -25082,14 +23776,14 @@ var Mixin = {
rollback: function () {}
};
-_assign(ReactServerRenderingTransaction.prototype, Transaction.Mixin, Mixin);
+_assign(ReactServerRenderingTransaction.prototype, Transaction, Mixin);
PooledClass.addPoolingTo(ReactServerRenderingTransaction);
module.exports = ReactServerRenderingTransaction;
}).call(this,require('_process'))
-},{"./PooledClass":46,"./ReactInstrumentation":94,"./ReactServerUpdateQueue":110,"./Transaction":130,"_process":15,"object-assign":14}],110:[function(require,module,exports){
+},{"./PooledClass":67,"./ReactInstrumentation":105,"./ReactServerUpdateQueue":118,"./Transaction":138,"_process":43,"object-assign":170}],118:[function(require,module,exports){
(function (process){
/**
* Copyright 2015-present, Facebook, Inc.
@@ -25099,7 +23793,6 @@ module.exports = ReactServerRenderingTransaction;
* 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 ReactServerUpdateQueue
*
*/
@@ -25108,7 +23801,7 @@ module.exports = ReactServerRenderingTransaction;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var ReactUpdateQueue = require('./ReactUpdateQueue');
-var Transaction = require('./Transaction');
+
var warning = require('fbjs/lib/warning');
function warnNoop(publicInstance, callerName) {
@@ -25127,8 +23820,6 @@ function warnNoop(publicInstance, callerName) {
*/
var ReactServerUpdateQueue = function () {
- /* :: transaction: Transaction; */
-
function ReactServerUpdateQueue(transaction) {
_classCallCheck(this, ReactServerUpdateQueue);
@@ -25234,7 +23925,7 @@ var ReactServerUpdateQueue = function () {
module.exports = ReactServerUpdateQueue;
}).call(this,require('_process'))
-},{"./ReactUpdateQueue":111,"./Transaction":130,"_process":15,"fbjs/lib/warning":188}],111:[function(require,module,exports){
+},{"./ReactUpdateQueue":119,"_process":43,"fbjs/lib/warning":25}],119:[function(require,module,exports){
(function (process){
/**
* Copyright 2015-present, Facebook, Inc.
@@ -25244,14 +23935,13 @@ module.exports = ReactServerUpdateQueue;
* 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 ReactUpdateQueue
*/
'use strict';
var _prodInvariant = require('./reactProdInvariant');
-var ReactCurrentOwner = require('./ReactCurrentOwner');
+var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
var ReactInstanceMap = require('./ReactInstanceMap');
var ReactInstrumentation = require('./ReactInstrumentation');
var ReactUpdates = require('./ReactUpdates');
@@ -25280,10 +23970,11 @@ function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
var internalInstance = ReactInstanceMap.get(publicInstance);
if (!internalInstance) {
if (process.env.NODE_ENV !== 'production') {
+ var ctor = publicInstance.constructor;
// Only warn when we have a callerName. Otherwise we should be silent.
// We're probably calling from enqueueCallback. We don't want to warn
// there because we already warned for the corresponding lifecycle method.
- process.env.NODE_ENV !== 'production' ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor.displayName) : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, ctor && (ctor.displayName || ctor.name) || 'ReactClass') : void 0;
}
return null;
}
@@ -25463,7 +24154,7 @@ var ReactUpdateQueue = {
module.exports = ReactUpdateQueue;
}).call(this,require('_process'))
-},{"./ReactCurrentOwner":57,"./ReactInstanceMap":93,"./ReactInstrumentation":94,"./ReactUpdates":112,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"fbjs/lib/warning":188}],112:[function(require,module,exports){
+},{"./ReactInstanceMap":104,"./ReactInstrumentation":105,"./ReactUpdates":120,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25,"react/lib/ReactCurrentOwner":192}],120:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -25473,7 +24164,6 @@ module.exports = ReactUpdateQueue;
* 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
*/
'use strict';
@@ -25538,7 +24228,7 @@ function ReactUpdatesFlushTransaction() {
/* useCreateElement */true);
}
-_assign(ReactUpdatesFlushTransaction.prototype, Transaction.Mixin, {
+_assign(ReactUpdatesFlushTransaction.prototype, Transaction, {
getTransactionWrappers: function () {
return TRANSACTION_WRAPPERS;
},
@@ -25554,7 +24244,7 @@ _assign(ReactUpdatesFlushTransaction.prototype, Transaction.Mixin, {
perform: function (method, scope, a) {
// Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
// with this transaction's wrappers around it.
- return Transaction.Mixin.perform.call(this, this.reconcileTransaction.perform, this.reconcileTransaction, method, scope, a);
+ return Transaction.perform.call(this, this.reconcileTransaction.perform, this.reconcileTransaction, method, scope, a);
}
});
@@ -25562,7 +24252,7 @@ PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
function batchedUpdates(callback, a, b, c, d, e) {
ensureInjected();
- batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
+ return batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
}
/**
@@ -25608,7 +24298,7 @@ function runBatchedUpdates(transaction) {
if (ReactFeatureFlags.logTopLevelRenders) {
var namedComponent = component;
// Duck type TopLevelWrapper. This is probably always true.
- if (component._currentElement.props === component._renderedComponent._currentElement) {
+ if (component._currentElement.type.isReactTopLevelWrapper) {
namedComponent = component._renderedComponent;
}
markerName = 'React update: ' + namedComponent.getName();
@@ -25718,7 +24408,7 @@ var ReactUpdates = {
module.exports = ReactUpdates;
}).call(this,require('_process'))
-},{"./CallbackQueue":26,"./PooledClass":46,"./ReactFeatureFlags":88,"./ReactReconciler":107,"./Transaction":130,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"object-assign":14}],113:[function(require,module,exports){
+},{"./CallbackQueue":49,"./PooledClass":67,"./ReactFeatureFlags":99,"./ReactReconciler":115,"./Transaction":138,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18,"object-assign":170}],121:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -25727,13 +24417,12 @@ module.exports = ReactUpdates;
* 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 ReactVersion
*/
'use strict';
-module.exports = '15.2.1';
-},{}],114:[function(require,module,exports){
+module.exports = '15.4.2';
+},{}],122:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -25742,7 +24431,6 @@ module.exports = '15.2.1';
* 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
*/
'use strict';
@@ -25999,6 +24687,8 @@ var ATTRS = {
xlinkTitle: 'xlink:title',
xlinkType: 'xlink:type',
xmlBase: 'xml:base',
+ xmlns: 0,
+ xmlnsXlink: 'xmlns:xlink',
xmlLang: 'xml:lang',
xmlSpace: 'xml:space',
y: 0,
@@ -26034,7 +24724,7 @@ Object.keys(ATTRS).forEach(function (key) {
});
module.exports = SVGDOMPropertyConfig;
-},{}],115:[function(require,module,exports){
+},{}],123:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -26043,12 +24733,10 @@ module.exports = SVGDOMPropertyConfig;
* 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
*/
'use strict';
-var EventConstants = require('./EventConstants');
var EventPropagators = require('./EventPropagators');
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
@@ -26057,20 +24745,17 @@ var SyntheticEvent = require('./SyntheticEvent');
var getActiveElement = require('fbjs/lib/getActiveElement');
var isTextInputElement = require('./isTextInputElement');
-var keyOf = require('fbjs/lib/keyOf');
var shallowEqual = require('fbjs/lib/shallowEqual');
-var topLevelTypes = EventConstants.topLevelTypes;
-
var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
var eventTypes = {
select: {
phasedRegistrationNames: {
- bubbled: keyOf({ onSelect: null }),
- captured: keyOf({ onSelectCapture: null })
+ bubbled: 'onSelect',
+ captured: 'onSelectCapture'
},
- dependencies: [topLevelTypes.topBlur, topLevelTypes.topContextMenu, topLevelTypes.topFocus, topLevelTypes.topKeyDown, topLevelTypes.topMouseDown, topLevelTypes.topMouseUp, topLevelTypes.topSelectionChange]
+ dependencies: ['topBlur', 'topContextMenu', 'topFocus', 'topKeyDown', 'topKeyUp', 'topMouseDown', 'topMouseUp', 'topSelectionChange']
}
};
@@ -26082,7 +24767,6 @@ var mouseDown = false;
// Track whether a listener exists for this plugin. If none exist, we do
// not extract events. See #3639.
var hasListener = false;
-var ON_SELECT_KEY = keyOf({ onSelect: null });
/**
* Get an object which is a unique representation of the current selection.
@@ -26178,14 +24862,14 @@ var SelectEventPlugin = {
switch (topLevelType) {
// Track the input node that has focus.
- case topLevelTypes.topFocus:
+ case 'topFocus':
if (isTextInputElement(targetNode) || targetNode.contentEditable === 'true') {
activeElement = targetNode;
activeElementInst = targetInst;
lastSelection = null;
}
break;
- case topLevelTypes.topBlur:
+ case 'topBlur':
activeElement = null;
activeElementInst = null;
lastSelection = null;
@@ -26193,11 +24877,11 @@ var SelectEventPlugin = {
// Don't fire the event while the user is dragging. This matches the
// semantics of the native select event.
- case topLevelTypes.topMouseDown:
+ case 'topMouseDown':
mouseDown = true;
break;
- case topLevelTypes.topContextMenu:
- case topLevelTypes.topMouseUp:
+ case 'topContextMenu':
+ case 'topMouseUp':
mouseDown = false;
return constructSelectEvent(nativeEvent, nativeEventTarget);
@@ -26210,13 +24894,13 @@ var SelectEventPlugin = {
// keyup, but we check on keydown as well in the case of holding down a
// key, when multiple keydown events are fired but only one keyup is.
// This is also our approach for IE handling, for the reason above.
- case topLevelTypes.topSelectionChange:
+ case 'topSelectionChange':
if (skipSelectionChangeEvent) {
break;
}
// falls through
- case topLevelTypes.topKeyDown:
- case topLevelTypes.topKeyUp:
+ case 'topKeyDown':
+ case 'topKeyUp':
return constructSelectEvent(nativeEvent, nativeEventTarget);
}
@@ -26224,14 +24908,14 @@ var SelectEventPlugin = {
},
didPutListener: function (inst, registrationName, listener) {
- if (registrationName === ON_SELECT_KEY) {
+ if (registrationName === 'onSelect') {
hasListener = true;
}
}
};
module.exports = SelectEventPlugin;
-},{"./EventConstants":37,"./EventPropagators":41,"./ReactDOMComponentTree":62,"./ReactInputSelection":92,"./SyntheticEvent":121,"./isTextInputElement":153,"fbjs/lib/ExecutionEnvironment":164,"fbjs/lib/getActiveElement":173,"fbjs/lib/keyOf":182,"fbjs/lib/shallowEqual":187}],116:[function(require,module,exports){
+},{"./EventPropagators":62,"./ReactDOMComponentTree":76,"./ReactInputSelection":103,"./SyntheticEvent":129,"./isTextInputElement":161,"fbjs/lib/ExecutionEnvironment":4,"fbjs/lib/getActiveElement":13,"fbjs/lib/shallowEqual":24}],124:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -26241,14 +24925,13 @@ module.exports = SelectEventPlugin;
* 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
+ *
*/
'use strict';
var _prodInvariant = require('./reactProdInvariant');
-var EventConstants = require('./EventConstants');
var EventListener = require('fbjs/lib/EventListener');
var EventPropagators = require('./EventPropagators');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
@@ -26267,459 +24950,55 @@ var SyntheticWheelEvent = require('./SyntheticWheelEvent');
var emptyFunction = require('fbjs/lib/emptyFunction');
var getEventCharCode = require('./getEventCharCode');
var invariant = require('fbjs/lib/invariant');
-var keyOf = require('fbjs/lib/keyOf');
-
-var topLevelTypes = EventConstants.topLevelTypes;
-var eventTypes = {
- abort: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onAbort: true }),
- captured: keyOf({ onAbortCapture: true })
- }
- },
- animationEnd: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onAnimationEnd: true }),
- captured: keyOf({ onAnimationEndCapture: true })
- }
- },
- animationIteration: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onAnimationIteration: true }),
- captured: keyOf({ onAnimationIterationCapture: true })
- }
- },
- animationStart: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onAnimationStart: true }),
- captured: keyOf({ onAnimationStartCapture: true })
- }
- },
- blur: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onBlur: true }),
- captured: keyOf({ onBlurCapture: true })
- }
- },
- canPlay: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onCanPlay: true }),
- captured: keyOf({ onCanPlayCapture: true })
- }
- },
- canPlayThrough: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onCanPlayThrough: true }),
- captured: keyOf({ onCanPlayThroughCapture: true })
- }
- },
- click: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onClick: true }),
- captured: keyOf({ onClickCapture: true })
- }
- },
- contextMenu: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onContextMenu: true }),
- captured: keyOf({ onContextMenuCapture: true })
- }
- },
- copy: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onCopy: true }),
- captured: keyOf({ onCopyCapture: true })
- }
- },
- cut: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onCut: true }),
- captured: keyOf({ onCutCapture: true })
- }
- },
- doubleClick: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onDoubleClick: true }),
- captured: keyOf({ onDoubleClickCapture: true })
- }
- },
- drag: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onDrag: true }),
- captured: keyOf({ onDragCapture: true })
- }
- },
- dragEnd: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onDragEnd: true }),
- captured: keyOf({ onDragEndCapture: true })
- }
- },
- dragEnter: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onDragEnter: true }),
- captured: keyOf({ onDragEnterCapture: true })
- }
- },
- dragExit: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onDragExit: true }),
- captured: keyOf({ onDragExitCapture: true })
- }
- },
- dragLeave: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onDragLeave: true }),
- captured: keyOf({ onDragLeaveCapture: true })
- }
- },
- dragOver: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onDragOver: true }),
- captured: keyOf({ onDragOverCapture: true })
- }
- },
- dragStart: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onDragStart: true }),
- captured: keyOf({ onDragStartCapture: true })
- }
- },
- drop: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onDrop: true }),
- captured: keyOf({ onDropCapture: true })
- }
- },
- durationChange: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onDurationChange: true }),
- captured: keyOf({ onDurationChangeCapture: true })
- }
- },
- emptied: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onEmptied: true }),
- captured: keyOf({ onEmptiedCapture: true })
- }
- },
- encrypted: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onEncrypted: true }),
- captured: keyOf({ onEncryptedCapture: true })
- }
- },
- ended: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onEnded: true }),
- captured: keyOf({ onEndedCapture: true })
- }
- },
- error: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onError: true }),
- captured: keyOf({ onErrorCapture: true })
- }
- },
- focus: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onFocus: true }),
- captured: keyOf({ onFocusCapture: true })
- }
- },
- input: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onInput: true }),
- captured: keyOf({ onInputCapture: true })
- }
- },
- invalid: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onInvalid: true }),
- captured: keyOf({ onInvalidCapture: true })
- }
- },
- keyDown: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onKeyDown: true }),
- captured: keyOf({ onKeyDownCapture: true })
- }
- },
- keyPress: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onKeyPress: true }),
- captured: keyOf({ onKeyPressCapture: true })
- }
- },
- keyUp: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onKeyUp: true }),
- captured: keyOf({ onKeyUpCapture: true })
- }
- },
- load: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onLoad: true }),
- captured: keyOf({ onLoadCapture: true })
- }
- },
- loadedData: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onLoadedData: true }),
- captured: keyOf({ onLoadedDataCapture: true })
- }
- },
- loadedMetadata: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onLoadedMetadata: true }),
- captured: keyOf({ onLoadedMetadataCapture: true })
- }
- },
- loadStart: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onLoadStart: true }),
- captured: keyOf({ onLoadStartCapture: true })
- }
- },
- // Note: We do not allow listening to mouseOver events. Instead, use the
- // onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
- mouseDown: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onMouseDown: true }),
- captured: keyOf({ onMouseDownCapture: true })
- }
- },
- mouseMove: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onMouseMove: true }),
- captured: keyOf({ onMouseMoveCapture: true })
- }
- },
- mouseOut: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onMouseOut: true }),
- captured: keyOf({ onMouseOutCapture: true })
- }
- },
- mouseOver: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onMouseOver: true }),
- captured: keyOf({ onMouseOverCapture: true })
- }
- },
- mouseUp: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onMouseUp: true }),
- captured: keyOf({ onMouseUpCapture: true })
- }
- },
- paste: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onPaste: true }),
- captured: keyOf({ onPasteCapture: true })
- }
- },
- pause: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onPause: true }),
- captured: keyOf({ onPauseCapture: true })
- }
- },
- play: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onPlay: true }),
- captured: keyOf({ onPlayCapture: true })
- }
- },
- playing: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onPlaying: true }),
- captured: keyOf({ onPlayingCapture: true })
- }
- },
- progress: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onProgress: true }),
- captured: keyOf({ onProgressCapture: true })
- }
- },
- rateChange: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onRateChange: true }),
- captured: keyOf({ onRateChangeCapture: true })
- }
- },
- reset: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onReset: true }),
- captured: keyOf({ onResetCapture: true })
- }
- },
- scroll: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onScroll: true }),
- captured: keyOf({ onScrollCapture: true })
- }
- },
- seeked: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onSeeked: true }),
- captured: keyOf({ onSeekedCapture: true })
- }
- },
- seeking: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onSeeking: true }),
- captured: keyOf({ onSeekingCapture: true })
- }
- },
- stalled: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onStalled: true }),
- captured: keyOf({ onStalledCapture: true })
- }
- },
- submit: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onSubmit: true }),
- captured: keyOf({ onSubmitCapture: true })
- }
- },
- suspend: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onSuspend: true }),
- captured: keyOf({ onSuspendCapture: true })
- }
- },
- timeUpdate: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onTimeUpdate: true }),
- captured: keyOf({ onTimeUpdateCapture: true })
- }
- },
- touchCancel: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onTouchCancel: true }),
- captured: keyOf({ onTouchCancelCapture: true })
- }
- },
- touchEnd: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onTouchEnd: true }),
- captured: keyOf({ onTouchEndCapture: true })
- }
- },
- touchMove: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onTouchMove: true }),
- captured: keyOf({ onTouchMoveCapture: true })
- }
- },
- touchStart: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onTouchStart: true }),
- captured: keyOf({ onTouchStartCapture: true })
- }
- },
- transitionEnd: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onTransitionEnd: true }),
- captured: keyOf({ onTransitionEndCapture: true })
- }
- },
- volumeChange: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onVolumeChange: true }),
- captured: keyOf({ onVolumeChangeCapture: true })
- }
- },
- waiting: {
- phasedRegistrationNames: {
- bubbled: keyOf({ onWaiting: true }),
- captured: keyOf({ onWaitingCapture: true })
- }
- },
- wheel: {
+/**
+ * Turns
+ * ['abort', ...]
+ * into
+ * eventTypes = {
+ * 'abort': {
+ * phasedRegistrationNames: {
+ * bubbled: 'onAbort',
+ * captured: 'onAbortCapture',
+ * },
+ * dependencies: ['topAbort'],
+ * },
+ * ...
+ * };
+ * topLevelEventsToDispatchConfig = {
+ * 'topAbort': { sameConfig }
+ * };
+ */
+var eventTypes = {};
+var topLevelEventsToDispatchConfig = {};
+['abort', 'animationEnd', 'animationIteration', 'animationStart', 'blur', 'canPlay', 'canPlayThrough', 'click', 'contextMenu', 'copy', 'cut', 'doubleClick', 'drag', 'dragEnd', 'dragEnter', 'dragExit', 'dragLeave', 'dragOver', 'dragStart', 'drop', 'durationChange', 'emptied', 'encrypted', 'ended', 'error', 'focus', 'input', 'invalid', 'keyDown', 'keyPress', 'keyUp', 'load', 'loadedData', 'loadedMetadata', 'loadStart', 'mouseDown', 'mouseMove', 'mouseOut', 'mouseOver', 'mouseUp', 'paste', 'pause', 'play', 'playing', 'progress', 'rateChange', 'reset', 'scroll', 'seeked', 'seeking', 'stalled', 'submit', 'suspend', 'timeUpdate', 'touchCancel', 'touchEnd', 'touchMove', 'touchStart', 'transitionEnd', 'volumeChange', 'waiting', 'wheel'].forEach(function (event) {
+ var capitalizedEvent = event[0].toUpperCase() + event.slice(1);
+ var onEvent = 'on' + capitalizedEvent;
+ var topEvent = 'top' + capitalizedEvent;
+
+ var type = {
phasedRegistrationNames: {
- bubbled: keyOf({ onWheel: true }),
- captured: keyOf({ onWheelCapture: true })
- }
- }
-};
-
-var topLevelEventsToDispatchConfig = {
- topAbort: eventTypes.abort,
- topAnimationEnd: eventTypes.animationEnd,
- topAnimationIteration: eventTypes.animationIteration,
- topAnimationStart: eventTypes.animationStart,
- topBlur: eventTypes.blur,
- topCanPlay: eventTypes.canPlay,
- topCanPlayThrough: eventTypes.canPlayThrough,
- topClick: eventTypes.click,
- topContextMenu: eventTypes.contextMenu,
- topCopy: eventTypes.copy,
- topCut: eventTypes.cut,
- topDoubleClick: eventTypes.doubleClick,
- topDrag: eventTypes.drag,
- topDragEnd: eventTypes.dragEnd,
- topDragEnter: eventTypes.dragEnter,
- topDragExit: eventTypes.dragExit,
- topDragLeave: eventTypes.dragLeave,
- topDragOver: eventTypes.dragOver,
- topDragStart: eventTypes.dragStart,
- topDrop: eventTypes.drop,
- topDurationChange: eventTypes.durationChange,
- topEmptied: eventTypes.emptied,
- topEncrypted: eventTypes.encrypted,
- topEnded: eventTypes.ended,
- topError: eventTypes.error,
- topFocus: eventTypes.focus,
- topInput: eventTypes.input,
- topInvalid: eventTypes.invalid,
- topKeyDown: eventTypes.keyDown,
- topKeyPress: eventTypes.keyPress,
- topKeyUp: eventTypes.keyUp,
- topLoad: eventTypes.load,
- topLoadedData: eventTypes.loadedData,
- topLoadedMetadata: eventTypes.loadedMetadata,
- topLoadStart: eventTypes.loadStart,
- topMouseDown: eventTypes.mouseDown,
- topMouseMove: eventTypes.mouseMove,
- topMouseOut: eventTypes.mouseOut,
- topMouseOver: eventTypes.mouseOver,
- topMouseUp: eventTypes.mouseUp,
- topPaste: eventTypes.paste,
- topPause: eventTypes.pause,
- topPlay: eventTypes.play,
- topPlaying: eventTypes.playing,
- topProgress: eventTypes.progress,
- topRateChange: eventTypes.rateChange,
- topReset: eventTypes.reset,
- topScroll: eventTypes.scroll,
- topSeeked: eventTypes.seeked,
- topSeeking: eventTypes.seeking,
- topStalled: eventTypes.stalled,
- topSubmit: eventTypes.submit,
- topSuspend: eventTypes.suspend,
- topTimeUpdate: eventTypes.timeUpdate,
- topTouchCancel: eventTypes.touchCancel,
- topTouchEnd: eventTypes.touchEnd,
- topTouchMove: eventTypes.touchMove,
- topTouchStart: eventTypes.touchStart,
- topTransitionEnd: eventTypes.transitionEnd,
- topVolumeChange: eventTypes.volumeChange,
- topWaiting: eventTypes.waiting,
- topWheel: eventTypes.wheel
-};
-
-for (var type in topLevelEventsToDispatchConfig) {
- topLevelEventsToDispatchConfig[type].dependencies = [type];
-}
-
-var ON_CLICK_KEY = keyOf({ onClick: null });
+ bubbled: onEvent,
+ captured: onEvent + 'Capture'
+ },
+ dependencies: [topEvent]
+ };
+ eventTypes[event] = type;
+ topLevelEventsToDispatchConfig[topEvent] = type;
+});
+
var onClickListeners = {};
+function getDictionaryKey(inst) {
+ // Prevents V8 performance issue:
+ // https://github.com/facebook/react/pull/7232
+ return '.' + inst._rootNodeID;
+}
+
+function isInteractive(tag) {
+ return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
+}
+
var SimpleEventPlugin = {
eventTypes: eventTypes,
@@ -26731,39 +25010,39 @@ var SimpleEventPlugin = {
}
var EventConstructor;
switch (topLevelType) {
- case topLevelTypes.topAbort:
- case topLevelTypes.topCanPlay:
- case topLevelTypes.topCanPlayThrough:
- case topLevelTypes.topDurationChange:
- case topLevelTypes.topEmptied:
- case topLevelTypes.topEncrypted:
- case topLevelTypes.topEnded:
- case topLevelTypes.topError:
- case topLevelTypes.topInput:
- case topLevelTypes.topInvalid:
- case topLevelTypes.topLoad:
- case topLevelTypes.topLoadedData:
- case topLevelTypes.topLoadedMetadata:
- case topLevelTypes.topLoadStart:
- case topLevelTypes.topPause:
- case topLevelTypes.topPlay:
- case topLevelTypes.topPlaying:
- case topLevelTypes.topProgress:
- case topLevelTypes.topRateChange:
- case topLevelTypes.topReset:
- case topLevelTypes.topSeeked:
- case topLevelTypes.topSeeking:
- case topLevelTypes.topStalled:
- case topLevelTypes.topSubmit:
- case topLevelTypes.topSuspend:
- case topLevelTypes.topTimeUpdate:
- case topLevelTypes.topVolumeChange:
- case topLevelTypes.topWaiting:
+ case 'topAbort':
+ case 'topCanPlay':
+ case 'topCanPlayThrough':
+ case 'topDurationChange':
+ case 'topEmptied':
+ case 'topEncrypted':
+ case 'topEnded':
+ case 'topError':
+ case 'topInput':
+ case 'topInvalid':
+ case 'topLoad':
+ case 'topLoadedData':
+ case 'topLoadedMetadata':
+ case 'topLoadStart':
+ case 'topPause':
+ case 'topPlay':
+ case 'topPlaying':
+ case 'topProgress':
+ case 'topRateChange':
+ case 'topReset':
+ case 'topSeeked':
+ case 'topSeeking':
+ case 'topStalled':
+ case 'topSubmit':
+ case 'topSuspend':
+ case 'topTimeUpdate':
+ case 'topVolumeChange':
+ case 'topWaiting':
// HTML Events
// @see http://www.w3.org/TR/html5/index.html#events-0
EventConstructor = SyntheticEvent;
break;
- case topLevelTypes.topKeyPress:
+ case 'topKeyPress':
// Firefox creates a keypress event for function keys too. This removes
// the unwanted keypress events. Enter is however both printable and
// non-printable. One would expect Tab to be as well (but it isn't).
@@ -26771,63 +25050,65 @@ var SimpleEventPlugin = {
return null;
}
/* falls through */
- case topLevelTypes.topKeyDown:
- case topLevelTypes.topKeyUp:
+ case 'topKeyDown':
+ case 'topKeyUp':
EventConstructor = SyntheticKeyboardEvent;
break;
- case topLevelTypes.topBlur:
- case topLevelTypes.topFocus:
+ case 'topBlur':
+ case 'topFocus':
EventConstructor = SyntheticFocusEvent;
break;
- case topLevelTypes.topClick:
+ case 'topClick':
// Firefox creates a click event on right mouse clicks. This removes the
// unwanted click events.
if (nativeEvent.button === 2) {
return null;
}
/* falls through */
- case topLevelTypes.topContextMenu:
- case topLevelTypes.topDoubleClick:
- case topLevelTypes.topMouseDown:
- case topLevelTypes.topMouseMove:
- case topLevelTypes.topMouseOut:
- case topLevelTypes.topMouseOver:
- case topLevelTypes.topMouseUp:
+ case 'topDoubleClick':
+ case 'topMouseDown':
+ case 'topMouseMove':
+ case 'topMouseUp':
+ // TODO: Disabled elements should not respond to mouse events
+ /* falls through */
+ case 'topMouseOut':
+ case 'topMouseOver':
+ case 'topContextMenu':
EventConstructor = SyntheticMouseEvent;
break;
- case topLevelTypes.topDrag:
- case topLevelTypes.topDragEnd:
- case topLevelTypes.topDragEnter:
- case topLevelTypes.topDragExit:
- case topLevelTypes.topDragLeave:
- case topLevelTypes.topDragOver:
- case topLevelTypes.topDragStart:
- case topLevelTypes.topDrop:
+ case 'topDrag':
+ case 'topDragEnd':
+ case 'topDragEnter':
+ case 'topDragExit':
+ case 'topDragLeave':
+ case 'topDragOver':
+ case 'topDragStart':
+ case 'topDrop':
EventConstructor = SyntheticDragEvent;
break;
- case topLevelTypes.topTouchCancel:
- case topLevelTypes.topTouchEnd:
- case topLevelTypes.topTouchMove:
- case topLevelTypes.topTouchStart:
+ case 'topTouchCancel':
+ case 'topTouchEnd':
+ case 'topTouchMove':
+ case 'topTouchStart':
EventConstructor = SyntheticTouchEvent;
break;
- case topLevelTypes.topAnimationEnd:
- case topLevelTypes.topAnimationIteration:
- case topLevelTypes.topAnimationStart:
+ case 'topAnimationEnd':
+ case 'topAnimationIteration':
+ case 'topAnimationStart':
EventConstructor = SyntheticAnimationEvent;
break;
- case topLevelTypes.topTransitionEnd:
+ case 'topTransitionEnd':
EventConstructor = SyntheticTransitionEvent;
break;
- case topLevelTypes.topScroll:
+ case 'topScroll':
EventConstructor = SyntheticUIEvent;
break;
- case topLevelTypes.topWheel:
+ case 'topWheel':
EventConstructor = SyntheticWheelEvent;
break;
- case topLevelTypes.topCopy:
- case topLevelTypes.topCut:
- case topLevelTypes.topPaste:
+ case 'topCopy':
+ case 'topCut':
+ case 'topPaste':
EventConstructor = SyntheticClipboardEvent;
break;
}
@@ -26842,20 +25123,21 @@ var SimpleEventPlugin = {
// non-interactive elements, which means delegated click listeners do not
// fire. The workaround for this bug involves attaching an empty click
// listener on the target node.
- if (registrationName === ON_CLICK_KEY) {
- var id = inst._rootNodeID;
+ // http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
+ if (registrationName === 'onClick' && !isInteractive(inst._tag)) {
+ var key = getDictionaryKey(inst);
var node = ReactDOMComponentTree.getNodeFromInstance(inst);
- if (!onClickListeners[id]) {
- onClickListeners[id] = EventListener.listen(node, 'click', emptyFunction);
+ if (!onClickListeners[key]) {
+ onClickListeners[key] = EventListener.listen(node, 'click', emptyFunction);
}
}
},
willDeleteListener: function (inst, registrationName) {
- if (registrationName === ON_CLICK_KEY) {
- var id = inst._rootNodeID;
- onClickListeners[id].remove();
- delete onClickListeners[id];
+ if (registrationName === 'onClick' && !isInteractive(inst._tag)) {
+ var key = getDictionaryKey(inst);
+ onClickListeners[key].remove();
+ delete onClickListeners[key];
}
}
@@ -26864,7 +25146,7 @@ var SimpleEventPlugin = {
module.exports = SimpleEventPlugin;
}).call(this,require('_process'))
-},{"./EventConstants":37,"./EventPropagators":41,"./ReactDOMComponentTree":62,"./SyntheticAnimationEvent":117,"./SyntheticClipboardEvent":118,"./SyntheticDragEvent":120,"./SyntheticEvent":121,"./SyntheticFocusEvent":122,"./SyntheticKeyboardEvent":124,"./SyntheticMouseEvent":125,"./SyntheticTouchEvent":126,"./SyntheticTransitionEvent":127,"./SyntheticUIEvent":128,"./SyntheticWheelEvent":129,"./getEventCharCode":142,"./reactProdInvariant":156,"_process":15,"fbjs/lib/EventListener":163,"fbjs/lib/emptyFunction":170,"fbjs/lib/invariant":178,"fbjs/lib/keyOf":182}],117:[function(require,module,exports){
+},{"./EventPropagators":62,"./ReactDOMComponentTree":76,"./SyntheticAnimationEvent":125,"./SyntheticClipboardEvent":126,"./SyntheticDragEvent":128,"./SyntheticEvent":129,"./SyntheticFocusEvent":130,"./SyntheticKeyboardEvent":132,"./SyntheticMouseEvent":133,"./SyntheticTouchEvent":134,"./SyntheticTransitionEvent":135,"./SyntheticUIEvent":136,"./SyntheticWheelEvent":137,"./getEventCharCode":149,"./reactProdInvariant":163,"_process":43,"fbjs/lib/EventListener":3,"fbjs/lib/emptyFunction":10,"fbjs/lib/invariant":18}],125:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -26873,7 +25155,6 @@ module.exports = SimpleEventPlugin;
* 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 SyntheticAnimationEvent
*/
'use strict';
@@ -26904,7 +25185,7 @@ function SyntheticAnimationEvent(dispatchConfig, dispatchMarker, nativeEvent, na
SyntheticEvent.augmentClass(SyntheticAnimationEvent, AnimationEventInterface);
module.exports = SyntheticAnimationEvent;
-},{"./SyntheticEvent":121}],118:[function(require,module,exports){
+},{"./SyntheticEvent":129}],126:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -26913,7 +25194,6 @@ module.exports = SyntheticAnimationEvent;
* 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
*/
'use strict';
@@ -26943,7 +25223,7 @@ function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent, na
SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
module.exports = SyntheticClipboardEvent;
-},{"./SyntheticEvent":121}],119:[function(require,module,exports){
+},{"./SyntheticEvent":129}],127:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -26952,7 +25232,6 @@ module.exports = SyntheticClipboardEvent;
* 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
*/
'use strict';
@@ -26980,7 +25259,7 @@ function SyntheticCompositionEvent(dispatchConfig, dispatchMarker, nativeEvent,
SyntheticEvent.augmentClass(SyntheticCompositionEvent, CompositionEventInterface);
module.exports = SyntheticCompositionEvent;
-},{"./SyntheticEvent":121}],120:[function(require,module,exports){
+},{"./SyntheticEvent":129}],128:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -26989,7 +25268,6 @@ module.exports = SyntheticCompositionEvent;
* 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
*/
'use strict';
@@ -27017,7 +25295,7 @@ function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeE
SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
module.exports = SyntheticDragEvent;
-},{"./SyntheticMouseEvent":125}],121:[function(require,module,exports){
+},{"./SyntheticMouseEvent":133}],129:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -27027,7 +25305,6 @@ module.exports = SyntheticDragEvent;
* 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
*/
'use strict';
@@ -27134,7 +25411,8 @@ _assign(SyntheticEvent.prototype, {
if (event.preventDefault) {
event.preventDefault();
- } else {
+ } else if (typeof event.returnValue !== 'unknown') {
+ // eslint-disable-line valid-typeof
event.returnValue = false;
}
this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
@@ -27148,9 +25426,16 @@ _assign(SyntheticEvent.prototype, {
if (event.stopPropagation) {
event.stopPropagation();
- } else {
+ } else if (typeof event.cancelBubble !== 'unknown') {
+ // eslint-disable-line valid-typeof
+ // The ChangeEventPlugin registers a "propertychange" event for
+ // IE. This event does not support bubbling or cancelling, and
+ // any references to cancelBubble throw "Member not found". A
+ // typeof check of "unknown" circumvents this issue (and is also
+ // IE specific).
event.cancelBubble = true;
}
+
this.isPropagationStopped = emptyFunction.thatReturnsTrue;
},
@@ -27281,7 +25566,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
}
}).call(this,require('_process'))
-},{"./PooledClass":46,"_process":15,"fbjs/lib/emptyFunction":170,"fbjs/lib/warning":188,"object-assign":14}],122:[function(require,module,exports){
+},{"./PooledClass":67,"_process":43,"fbjs/lib/emptyFunction":10,"fbjs/lib/warning":25,"object-assign":170}],130:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -27290,7 +25575,6 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
* 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
*/
'use strict';
@@ -27318,7 +25602,7 @@ function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent, native
SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
module.exports = SyntheticFocusEvent;
-},{"./SyntheticUIEvent":128}],123:[function(require,module,exports){
+},{"./SyntheticUIEvent":136}],131:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -27327,7 +25611,6 @@ module.exports = SyntheticFocusEvent;
* 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
*/
'use strict';
@@ -27356,7 +25639,7 @@ function SyntheticInputEvent(dispatchConfig, dispatchMarker, nativeEvent, native
SyntheticEvent.augmentClass(SyntheticInputEvent, InputEventInterface);
module.exports = SyntheticInputEvent;
-},{"./SyntheticEvent":121}],124:[function(require,module,exports){
+},{"./SyntheticEvent":129}],132:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -27365,7 +25648,6 @@ module.exports = SyntheticInputEvent;
* 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
*/
'use strict';
@@ -27441,7 +25723,7 @@ function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nat
SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
module.exports = SyntheticKeyboardEvent;
-},{"./SyntheticUIEvent":128,"./getEventCharCode":142,"./getEventKey":143,"./getEventModifierState":144}],125:[function(require,module,exports){
+},{"./SyntheticUIEvent":136,"./getEventCharCode":149,"./getEventKey":150,"./getEventModifierState":151}],133:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -27450,7 +25732,6 @@ module.exports = SyntheticKeyboardEvent;
* 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
*/
'use strict';
@@ -27514,7 +25795,7 @@ function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent, native
SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
module.exports = SyntheticMouseEvent;
-},{"./SyntheticUIEvent":128,"./ViewportMetrics":131,"./getEventModifierState":144}],126:[function(require,module,exports){
+},{"./SyntheticUIEvent":136,"./ViewportMetrics":139,"./getEventModifierState":151}],134:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -27523,7 +25804,6 @@ module.exports = SyntheticMouseEvent;
* 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
*/
'use strict';
@@ -27560,7 +25840,7 @@ function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent, native
SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
module.exports = SyntheticTouchEvent;
-},{"./SyntheticUIEvent":128,"./getEventModifierState":144}],127:[function(require,module,exports){
+},{"./SyntheticUIEvent":136,"./getEventModifierState":151}],135:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -27569,7 +25849,6 @@ module.exports = SyntheticTouchEvent;
* 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 SyntheticTransitionEvent
*/
'use strict';
@@ -27600,7 +25879,7 @@ function SyntheticTransitionEvent(dispatchConfig, dispatchMarker, nativeEvent, n
SyntheticEvent.augmentClass(SyntheticTransitionEvent, TransitionEventInterface);
module.exports = SyntheticTransitionEvent;
-},{"./SyntheticEvent":121}],128:[function(require,module,exports){
+},{"./SyntheticEvent":129}],136:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -27609,7 +25888,6 @@ module.exports = SyntheticTransitionEvent;
* 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
*/
'use strict';
@@ -27660,7 +25938,7 @@ function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEve
SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
module.exports = SyntheticUIEvent;
-},{"./SyntheticEvent":121,"./getEventTarget":145}],129:[function(require,module,exports){
+},{"./SyntheticEvent":129,"./getEventTarget":152}],137:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -27669,7 +25947,6 @@ module.exports = SyntheticUIEvent;
* 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
*/
'use strict';
@@ -27715,7 +25992,7 @@ function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent, native
SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
module.exports = SyntheticWheelEvent;
-},{"./SyntheticMouseEvent":125}],130:[function(require,module,exports){
+},{"./SyntheticMouseEvent":133}],138:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -27725,7 +26002,7 @@ module.exports = SyntheticWheelEvent;
* 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
+ *
*/
'use strict';
@@ -27734,6 +26011,8 @@ var _prodInvariant = require('./reactProdInvariant');
var invariant = require('fbjs/lib/invariant');
+var OBSERVED_ERROR = {};
+
/**
* `Transaction` creates a black box that is able to wrap any method such that
* certain invariants are maintained before and after the method is invoked
@@ -27795,7 +26074,7 @@ var invariant = require('fbjs/lib/invariant');
*
* @class Transaction
*/
-var Mixin = {
+var TransactionImpl = {
/**
* Sets up this instance so that it is prepared for collecting metrics. Does
* so such that this setup method may be used on an instance that is already
@@ -27885,10 +26164,10 @@ var Mixin = {
// OBSERVED_ERROR state before overwriting it with the real return value
// of initialize -- if it's still set to OBSERVED_ERROR in the finally
// block, it means wrapper.initialize threw.
- this.wrapperInitData[i] = Transaction.OBSERVED_ERROR;
+ this.wrapperInitData[i] = OBSERVED_ERROR;
this.wrapperInitData[i] = wrapper.initialize ? wrapper.initialize.call(this) : null;
} finally {
- if (this.wrapperInitData[i] === Transaction.OBSERVED_ERROR) {
+ if (this.wrapperInitData[i] === OBSERVED_ERROR) {
// The initializer for wrapper i threw an error; initialize the
// remaining wrappers but silence any exceptions from them to ensure
// that the first error is the one to bubble up.
@@ -27919,7 +26198,7 @@ var Mixin = {
// close -- if it's still set to true in the finally block, it means
// wrapper.close threw.
errorThrown = true;
- if (initData !== Transaction.OBSERVED_ERROR && wrapper.close) {
+ if (initData !== OBSERVED_ERROR && wrapper.close) {
wrapper.close.call(this, initData);
}
errorThrown = false;
@@ -27938,21 +26217,10 @@ var Mixin = {
}
};
-var Transaction = {
-
- Mixin: Mixin,
-
- /**
- * Token to look for to determine if an error occurred.
- */
- OBSERVED_ERROR: {}
-
-};
-
-module.exports = Transaction;
+module.exports = TransactionImpl;
}).call(this,require('_process'))
-},{"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],131:[function(require,module,exports){
+},{"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],139:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -27961,7 +26229,6 @@ module.exports = Transaction;
* 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
*/
'use strict';
@@ -27980,7 +26247,7 @@ var ViewportMetrics = {
};
module.exports = ViewportMetrics;
-},{}],132:[function(require,module,exports){
+},{}],140:[function(require,module,exports){
(function (process){
/**
* Copyright 2014-present, Facebook, Inc.
@@ -27990,7 +26257,6 @@ module.exports = ViewportMetrics;
* 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 accumulateInto
*
*/
@@ -28042,7 +26308,7 @@ function accumulateInto(current, next) {
module.exports = accumulateInto;
}).call(this,require('_process'))
-},{"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],133:[function(require,module,exports){
+},{"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18}],141:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -28051,7 +26317,6 @@ module.exports = accumulateInto;
* 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
*
*/
@@ -28087,35 +26352,7 @@ function adler32(data) {
}
module.exports = adler32;
-},{}],134:[function(require,module,exports){
-(function (process){
-/**
- * Copyright 2013-present, 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 canDefineProperty
- */
-
-'use strict';
-
-var canDefineProperty = false;
-if (process.env.NODE_ENV !== 'production') {
- try {
- Object.defineProperty({}, 'x', { get: function () {} });
- canDefineProperty = true;
- } catch (x) {
- // IE will fail on defineProperty
- }
-}
-
-module.exports = canDefineProperty;
-}).call(this,require('_process'))
-
-},{"_process":15}],135:[function(require,module,exports){
+},{}],142:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -28125,7 +26362,6 @@ module.exports = canDefineProperty;
* 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 checkReactTypeSpec
*/
'use strict';
@@ -28133,10 +26369,22 @@ module.exports = canDefineProperty;
var _prodInvariant = require('./reactProdInvariant');
var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
+var ReactPropTypesSecret = require('./ReactPropTypesSecret');
var invariant = require('fbjs/lib/invariant');
var warning = require('fbjs/lib/warning');
+var ReactComponentTreeHook;
+
+if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') {
+ // Temporary hack.
+ // Inline requires don't work well with Jest:
+ // https://github.com/facebook/react/issues/7240
+ // Remove the inline requires when we don't need them anymore:
+ // https://github.com/facebook/react/pull/7178
+ ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
+}
+
var loggedTypeFailures = {};
/**
@@ -28162,7 +26410,7 @@ function checkReactTypeSpec(typeSpecs, values, location, componentName, element,
// This is intentionally an invariant that gets caught. It's the same
// behavior as without this statement except with a better message.
!(typeof typeSpecs[typeSpecName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : _prodInvariant('84', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : void 0;
- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location);
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
} catch (ex) {
error = ex;
}
@@ -28175,11 +26423,13 @@ function checkReactTypeSpec(typeSpecs, values, location, componentName, element,
var componentStackInfo = '';
if (process.env.NODE_ENV !== 'production') {
- var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
+ if (!ReactComponentTreeHook) {
+ ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
+ }
if (debugID !== null) {
- componentStackInfo = ReactComponentTreeDevtool.getStackAddendumByID(debugID);
+ componentStackInfo = ReactComponentTreeHook.getStackAddendumByID(debugID);
} else if (element !== null) {
- componentStackInfo = ReactComponentTreeDevtool.getCurrentStackAddendum(element);
+ componentStackInfo = ReactComponentTreeHook.getCurrentStackAddendum(element);
}
}
@@ -28192,7 +26442,7 @@ function checkReactTypeSpec(typeSpecs, values, location, componentName, element,
module.exports = checkReactTypeSpec;
}).call(this,require('_process'))
-},{"./ReactComponentTreeDevtool":55,"./ReactPropTypeLocationNames":103,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"fbjs/lib/warning":188}],136:[function(require,module,exports){
+},{"./ReactPropTypeLocationNames":112,"./ReactPropTypesSecret":113,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25,"react/lib/ReactComponentTreeHook":191}],143:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -28201,7 +26451,6 @@ module.exports = checkReactTypeSpec;
* 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 createMicrosoftUnsafeLocalFunction
*/
/* globals MSApp */
@@ -28225,7 +26474,7 @@ var createMicrosoftUnsafeLocalFunction = function (func) {
};
module.exports = createMicrosoftUnsafeLocalFunction;
-},{}],137:[function(require,module,exports){
+},{}],144:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -28235,7 +26484,6 @@ module.exports = createMicrosoftUnsafeLocalFunction;
* 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
*/
'use strict';
@@ -28308,7 +26556,7 @@ function dangerousStyleValue(name, value, component) {
module.exports = dangerousStyleValue;
}).call(this,require('_process'))
-},{"./CSSProperty":24,"_process":15,"fbjs/lib/warning":188}],138:[function(require,module,exports){
+},{"./CSSProperty":47,"_process":43,"fbjs/lib/warning":25}],145:[function(require,module,exports){
/**
* Copyright 2016-present, Facebook, Inc.
* All rights reserved.
@@ -28342,7 +26590,6 @@ module.exports = dangerousStyleValue;
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
- * @providesModule escapeTextContentForBrowser
*/
'use strict';
@@ -28414,6 +26661,7 @@ function escapeHtml(string) {
}
// end code copied and modified from escape-html
+
/**
* Escapes text to prevent scripting attacks.
*
@@ -28431,7 +26679,7 @@ function escapeTextContentForBrowser(text) {
}
module.exports = escapeTextContentForBrowser;
-},{}],139:[function(require,module,exports){
+},{}],146:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -28441,14 +26689,13 @@ module.exports = escapeTextContentForBrowser;
* 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 findDOMNode
*/
'use strict';
var _prodInvariant = require('./reactProdInvariant');
-var ReactCurrentOwner = require('./ReactCurrentOwner');
+var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
var ReactDOMComponentTree = require('./ReactDOMComponentTree');
var ReactInstanceMap = require('./ReactInstanceMap');
@@ -28495,7 +26742,7 @@ function findDOMNode(componentOrElement) {
module.exports = findDOMNode;
}).call(this,require('_process'))
-},{"./ReactCurrentOwner":57,"./ReactDOMComponentTree":62,"./ReactInstanceMap":93,"./getHostComponentFromComposite":146,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"fbjs/lib/warning":188}],140:[function(require,module,exports){
+},{"./ReactDOMComponentTree":76,"./ReactInstanceMap":104,"./getHostComponentFromComposite":153,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25,"react/lib/ReactCurrentOwner":192}],147:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -28505,7 +26752,6 @@ module.exports = findDOMNode;
* 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
*
*/
@@ -28515,6 +26761,17 @@ var KeyEscapeUtils = require('./KeyEscapeUtils');
var traverseAllChildren = require('./traverseAllChildren');
var warning = require('fbjs/lib/warning');
+var ReactComponentTreeHook;
+
+if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') {
+ // Temporary hack.
+ // Inline requires don't work well with Jest:
+ // https://github.com/facebook/react/issues/7240
+ // Remove the inline requires when we don't need them anymore:
+ // https://github.com/facebook/react/pull/7178
+ ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
+}
+
/**
* @param {function} traverseContext Context passed through traversal.
* @param {?ReactComponent} child React child component.
@@ -28527,8 +26784,12 @@ function flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID
var result = traverseContext;
var keyUnique = result[name] === undefined;
if (process.env.NODE_ENV !== 'production') {
- var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
- process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeDevtool.getStackAddendumByID(selfDebugID)) : void 0;
+ if (!ReactComponentTreeHook) {
+ ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
+ }
+ if (!keyUnique) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.%s', KeyEscapeUtils.unescape(name), ReactComponentTreeHook.getStackAddendumByID(selfDebugID)) : void 0;
+ }
}
if (keyUnique && child != null) {
result[name] = child;
@@ -28560,7 +26821,7 @@ function flattenChildren(children, selfDebugID) {
module.exports = flattenChildren;
}).call(this,require('_process'))
-},{"./KeyEscapeUtils":44,"./ReactComponentTreeDevtool":55,"./traverseAllChildren":161,"_process":15,"fbjs/lib/warning":188}],141:[function(require,module,exports){
+},{"./KeyEscapeUtils":65,"./traverseAllChildren":168,"_process":43,"fbjs/lib/warning":25,"react/lib/ReactComponentTreeHook":191}],148:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -28569,7 +26830,6 @@ module.exports = flattenChildren;
* 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
*
*/
@@ -28592,7 +26852,7 @@ function forEachAccumulated(arr, cb, scope) {
}
module.exports = forEachAccumulated;
-},{}],142:[function(require,module,exports){
+},{}],149:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -28601,7 +26861,6 @@ module.exports = forEachAccumulated;
* 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 getEventCharCode
*/
'use strict';
@@ -28643,7 +26902,7 @@ function getEventCharCode(nativeEvent) {
}
module.exports = getEventCharCode;
-},{}],143:[function(require,module,exports){
+},{}],150:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -28652,7 +26911,6 @@ module.exports = getEventCharCode;
* 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
*/
'use strict';
@@ -28746,7 +27004,7 @@ function getEventKey(nativeEvent) {
}
module.exports = getEventKey;
-},{"./getEventCharCode":142}],144:[function(require,module,exports){
+},{"./getEventCharCode":149}],151:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -28755,7 +27013,6 @@ module.exports = getEventKey;
* 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
*/
'use strict';
@@ -28790,7 +27047,7 @@ function getEventModifierState(nativeEvent) {
}
module.exports = getEventModifierState;
-},{}],145:[function(require,module,exports){
+},{}],152:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -28799,7 +27056,6 @@ module.exports = getEventModifierState;
* 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
*/
'use strict';
@@ -28826,7 +27082,7 @@ function getEventTarget(nativeEvent) {
}
module.exports = getEventTarget;
-},{}],146:[function(require,module,exports){
+},{}],153:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -28835,7 +27091,6 @@ module.exports = getEventTarget;
* 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 getHostComponentFromComposite
*/
'use strict';
@@ -28857,7 +27112,7 @@ function getHostComponentFromComposite(inst) {
}
module.exports = getHostComponentFromComposite;
-},{"./ReactNodeTypes":100}],147:[function(require,module,exports){
+},{"./ReactNodeTypes":110}],154:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -28866,7 +27121,6 @@ module.exports = getHostComponentFromComposite;
* 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 getIteratorFn
*
*/
@@ -28899,7 +27153,28 @@ function getIteratorFn(maybeIterable) {
}
module.exports = getIteratorFn;
-},{}],148:[function(require,module,exports){
+},{}],155:[function(require,module,exports){
+/**
+ * Copyright 2013-present, 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.
+ *
+ *
+ */
+
+'use strict';
+
+var nextDebugID = 1;
+
+function getNextDebugID() {
+ return nextDebugID++;
+}
+
+module.exports = getNextDebugID;
+},{}],156:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -28908,7 +27183,6 @@ module.exports = getIteratorFn;
* 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
*/
'use strict';
@@ -28974,7 +27248,7 @@ function getNodeForCharacterOffset(root, offset) {
}
module.exports = getNodeForCharacterOffset;
-},{}],149:[function(require,module,exports){
+},{}],157:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -28983,7 +27257,6 @@ module.exports = getNodeForCharacterOffset;
* 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
*/
'use strict';
@@ -29008,7 +27281,7 @@ function getTextContentAccessor() {
}
module.exports = getTextContentAccessor;
-},{"fbjs/lib/ExecutionEnvironment":164}],150:[function(require,module,exports){
+},{"fbjs/lib/ExecutionEnvironment":4}],158:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -29017,7 +27290,6 @@ module.exports = getTextContentAccessor;
* 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 getVendorPrefixedEventName
*/
'use strict';
@@ -29110,7 +27382,7 @@ function getVendorPrefixedEventName(eventName) {
}
module.exports = getVendorPrefixedEventName;
-},{"fbjs/lib/ExecutionEnvironment":164}],151:[function(require,module,exports){
+},{"fbjs/lib/ExecutionEnvironment":4}],159:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -29120,7 +27392,6 @@ module.exports = getVendorPrefixedEventName;
* 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
*/
'use strict';
@@ -29131,8 +27402,8 @@ var _prodInvariant = require('./reactProdInvariant'),
var ReactCompositeComponent = require('./ReactCompositeComponent');
var ReactEmptyComponent = require('./ReactEmptyComponent');
var ReactHostComponent = require('./ReactHostComponent');
-var ReactInstrumentation = require('./ReactInstrumentation');
+var getNextDebugID = require('./getNextDebugID');
var invariant = require('fbjs/lib/invariant');
var warning = require('fbjs/lib/warning');
@@ -29140,7 +27411,7 @@ var warning = require('fbjs/lib/warning');
var ReactCompositeComponentWrapper = function (element) {
this.construct(element);
};
-_assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
+_assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent, {
_instantiateReactComponent: instantiateReactComponent
});
@@ -29154,21 +27425,6 @@ function getDeclarationErrorAddendum(owner) {
return '';
}
-function getDisplayName(instance) {
- var element = instance._currentElement;
- if (element == null) {
- return '#empty';
- } else if (typeof element === 'string' || typeof element === 'number') {
- return '#text';
- } else if (typeof element.type === 'string') {
- return element.type;
- } else if (instance.getName) {
- return instance.getName() || 'Unknown';
- } else {
- return element.type.displayName || element.type.name || 'Unknown';
- }
-}
-
/**
* Check if the type reference is a known internal type. I.e. not a user
* provided composite type.
@@ -29180,8 +27436,6 @@ function isInternalComponentType(type) {
return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function';
}
-var nextDebugID = 1;
-
/**
* Given a ReactNode, create an instance that will actually be mounted.
*
@@ -29197,7 +27451,17 @@ function instantiateReactComponent(node, shouldHaveDebugID) {
instance = ReactEmptyComponent.create(instantiateReactComponent);
} else if (typeof node === 'object') {
var element = node;
- !(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : _prodInvariant('130', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : void 0;
+ var type = element.type;
+ if (typeof type !== 'function' && typeof type !== 'string') {
+ var info = '';
+ if (process.env.NODE_ENV !== 'production') {
+ if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
+ info += ' You likely forgot to export your component from the file ' + 'it\'s defined in.';
+ }
+ }
+ info += getDeclarationErrorAddendum(element._owner);
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s', type == null ? type : typeof type, info) : _prodInvariant('130', type == null ? type : typeof type, info) : void 0;
+ }
// Special case string values
if (typeof element.type === 'string') {
@@ -29232,18 +27496,7 @@ function instantiateReactComponent(node, shouldHaveDebugID) {
instance._mountImage = null;
if (process.env.NODE_ENV !== 'production') {
- if (shouldHaveDebugID) {
- var debugID = nextDebugID++;
- instance._debugID = debugID;
- var displayName = getDisplayName(instance);
- ReactInstrumentation.debugTool.onSetDisplayName(debugID, displayName);
- var owner = node && node._owner;
- if (owner) {
- ReactInstrumentation.debugTool.onSetOwner(debugID, owner._debugID);
- }
- } else {
- instance._debugID = 0;
- }
+ instance._debugID = shouldHaveDebugID ? getNextDebugID() : 0;
}
// Internal instances should fully constructed at this point, so they should
@@ -29260,7 +27513,7 @@ function instantiateReactComponent(node, shouldHaveDebugID) {
module.exports = instantiateReactComponent;
}).call(this,require('_process'))
-},{"./ReactCompositeComponent":56,"./ReactEmptyComponent":84,"./ReactHostComponent":89,"./ReactInstrumentation":94,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"fbjs/lib/warning":188,"object-assign":14}],152:[function(require,module,exports){
+},{"./ReactCompositeComponent":72,"./ReactEmptyComponent":95,"./ReactHostComponent":100,"./getNextDebugID":155,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25,"object-assign":170}],160:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -29269,7 +27522,6 @@ module.exports = instantiateReactComponent;
* 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
*/
'use strict';
@@ -29321,7 +27573,7 @@ function isEventSupported(eventNameSuffix, capture) {
}
module.exports = isEventSupported;
-},{"fbjs/lib/ExecutionEnvironment":164}],153:[function(require,module,exports){
+},{"fbjs/lib/ExecutionEnvironment":4}],161:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -29330,7 +27582,6 @@ module.exports = isEventSupported;
* 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
*
*/
@@ -29373,8 +27624,7 @@ function isTextInputElement(elem) {
}
module.exports = isTextInputElement;
-},{}],154:[function(require,module,exports){
-(function (process){
+},{}],162:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -29383,48 +27633,6 @@ module.exports = isTextInputElement;
* 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 _prodInvariant = require('./reactProdInvariant');
-
-var ReactElement = require('./ReactElement');
-
-var invariant = require('fbjs/lib/invariant');
-
-/**
- * Returns the first child in a collection of children and verifies that there
- * is only one child in the collection.
- *
- * See https://facebook.github.io/react/docs/top-level-api.html#react.children.only
- *
- * The current implementation of this function assumes that a single child gets
- * passed without a wrapper, but the purpose of this helper function is to
- * abstract away the particular structure of children.
- *
- * @param {?object} children Child collection structure.
- * @return {ReactElement} The first and only `ReactElement` contained in the
- * structure.
- */
-function onlyChild(children) {
- !ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : _prodInvariant('23') : void 0;
- return children;
-}
-
-module.exports = onlyChild;
-}).call(this,require('_process'))
-
-},{"./ReactElement":82,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178}],155:[function(require,module,exports){
-/**
- * Copyright 2013-present, 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 quoteAttributeValueForBrowser
*/
'use strict';
@@ -29442,7 +27650,7 @@ function quoteAttributeValueForBrowser(value) {
}
module.exports = quoteAttributeValueForBrowser;
-},{"./escapeTextContentForBrowser":138}],156:[function(require,module,exports){
+},{"./escapeTextContentForBrowser":145}],163:[function(require,module,exports){
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
@@ -29451,7 +27659,6 @@ module.exports = quoteAttributeValueForBrowser;
* 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 reactProdInvariant
*
*/
'use strict';
@@ -29482,7 +27689,7 @@ function reactProdInvariant(code) {
}
module.exports = reactProdInvariant;
-},{}],157:[function(require,module,exports){
+},{}],164:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -29491,15 +27698,14 @@ module.exports = reactProdInvariant;
* 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 renderSubtreeIntoContainer
-*/
+ */
'use strict';
var ReactMount = require('./ReactMount');
module.exports = ReactMount.renderSubtreeIntoContainer;
-},{"./ReactMount":97}],158:[function(require,module,exports){
+},{"./ReactMount":108}],165:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -29508,7 +27714,6 @@ module.exports = ReactMount.renderSubtreeIntoContainer;
* 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
*/
'use strict';
@@ -29539,9 +27744,9 @@ var setInnerHTML = createMicrosoftUnsafeLocalFunction(function (node, html) {
if (node.namespaceURI === DOMNamespaces.svg && !('innerHTML' in node)) {
reusableSVGContainer = reusableSVGContainer || document.createElement('div');
reusableSVGContainer.innerHTML = '<svg>' + html + '</svg>';
- var newNodes = reusableSVGContainer.firstChild.childNodes;
- for (var i = 0; i < newNodes.length; i++) {
- node.appendChild(newNodes[i]);
+ var svgNode = reusableSVGContainer.firstChild;
+ while (svgNode.firstChild) {
+ node.appendChild(svgNode.firstChild);
}
} else {
node.innerHTML = html;
@@ -29598,7 +27803,7 @@ if (ExecutionEnvironment.canUseDOM) {
}
module.exports = setInnerHTML;
-},{"./DOMNamespaces":30,"./createMicrosoftUnsafeLocalFunction":136,"fbjs/lib/ExecutionEnvironment":164}],159:[function(require,module,exports){
+},{"./DOMNamespaces":53,"./createMicrosoftUnsafeLocalFunction":143,"fbjs/lib/ExecutionEnvironment":4}],166:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -29607,7 +27812,6 @@ module.exports = setInnerHTML;
* 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 setTextContent
*/
'use strict';
@@ -29641,13 +27845,17 @@ var setTextContent = function (node, text) {
if (ExecutionEnvironment.canUseDOM) {
if (!('textContent' in document.documentElement)) {
setTextContent = function (node, text) {
+ if (node.nodeType === 3) {
+ node.nodeValue = text;
+ return;
+ }
setInnerHTML(node, escapeTextContentForBrowser(text));
};
}
}
module.exports = setTextContent;
-},{"./escapeTextContentForBrowser":138,"./setInnerHTML":158,"fbjs/lib/ExecutionEnvironment":164}],160:[function(require,module,exports){
+},{"./escapeTextContentForBrowser":145,"./setInnerHTML":165,"fbjs/lib/ExecutionEnvironment":4}],167:[function(require,module,exports){
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
@@ -29656,7 +27864,6 @@ module.exports = setTextContent;
* 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
*/
'use strict';
@@ -29690,7 +27897,7 @@ function shouldUpdateReactComponent(prevElement, nextElement) {
}
module.exports = shouldUpdateReactComponent;
-},{}],161:[function(require,module,exports){
+},{}],168:[function(require,module,exports){
(function (process){
/**
* Copyright 2013-present, Facebook, Inc.
@@ -29700,15 +27907,14 @@ module.exports = shouldUpdateReactComponent;
* 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 _prodInvariant = require('./reactProdInvariant');
-var ReactCurrentOwner = require('./ReactCurrentOwner');
-var ReactElement = require('./ReactElement');
+var ReactCurrentOwner = require('react/lib/ReactCurrentOwner');
+var REACT_ELEMENT_TYPE = require('./ReactElementSymbol');
var getIteratorFn = require('./getIteratorFn');
var invariant = require('fbjs/lib/invariant');
@@ -29719,6 +27925,12 @@ var SEPARATOR = '.';
var SUBSEPARATOR = ':';
/**
+ * This is inlined from ReactElement since this file is shared between
+ * isomorphic and renderers. We could extract this to a
+ *
+ */
+
+/**
* TODO: Test that a single child and an array with one item have the same key
* pattern.
*/
@@ -29759,7 +27971,10 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
children = null;
}
- if (children === null || type === 'string' || type === 'number' || ReactElement.isValidElement(children)) {
+ if (children === null || type === 'string' || type === 'number' ||
+ // The following is inlined from ReactElement. This means we can optimize
+ // some checks. React Fiber also inlines this logic for similar purposes.
+ type === 'object' && children.$$typeof === REACT_ELEMENT_TYPE) {
callback(traverseContext, children,
// If it's the only child, treat the name as if it was wrapped in an array
// so that it's consistent if the number of children grows.
@@ -29792,7 +28007,14 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
}
} else {
if (process.env.NODE_ENV !== 'production') {
- process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.') : void 0;
+ var mapsAsChildrenAddendum = '';
+ if (ReactCurrentOwner.current) {
+ var mapsAsChildrenOwnerName = ReactCurrentOwner.current.getName();
+ if (mapsAsChildrenOwnerName) {
+ mapsAsChildrenAddendum = ' Check the render method of `' + mapsAsChildrenOwnerName + '`.';
+ }
+ }
+ process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.%s', mapsAsChildrenAddendum) : void 0;
didWarnAboutMaps = true;
}
// Iterator will provide entry [k,v] tuples rather than values.
@@ -29854,7 +28076,7 @@ function traverseAllChildren(children, callback, traverseContext) {
module.exports = traverseAllChildren;
}).call(this,require('_process'))
-},{"./KeyEscapeUtils":44,"./ReactCurrentOwner":57,"./ReactElement":82,"./getIteratorFn":147,"./reactProdInvariant":156,"_process":15,"fbjs/lib/invariant":178,"fbjs/lib/warning":188}],162:[function(require,module,exports){
+},{"./KeyEscapeUtils":65,"./ReactElementSymbol":94,"./getIteratorFn":154,"./reactProdInvariant":163,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25,"react/lib/ReactCurrentOwner":192}],169:[function(require,module,exports){
(function (process){
/**
* Copyright 2015-present, Facebook, Inc.
@@ -29864,7 +28086,6 @@ module.exports = traverseAllChildren;
* 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 validateDOMNesting
*/
'use strict';
@@ -30145,11 +28366,16 @@ if (process.env.NODE_ENV !== 'production') {
var didWarn = {};
- validateDOMNesting = function (childTag, childInstance, ancestorInfo) {
+ validateDOMNesting = function (childTag, childText, childInstance, ancestorInfo) {
ancestorInfo = ancestorInfo || emptyAncestorInfo;
var parentInfo = ancestorInfo.current;
var parentTag = parentInfo && parentInfo.tag;
+ if (childText != null) {
+ process.env.NODE_ENV !== 'production' ? warning(childTag == null, 'validateDOMNesting: when childText is passed, childTag should be null') : void 0;
+ childTag = '#text';
+ }
+
var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
var problematic = invalidParent || invalidAncestor;
@@ -30197,7 +28423,15 @@ if (process.env.NODE_ENV !== 'production') {
didWarn[warnKey] = true;
var tagDisplayName = childTag;
- if (childTag !== '#text') {
+ var whitespaceInfo = '';
+ if (childTag === '#text') {
+ if (/\S/.test(childText)) {
+ tagDisplayName = 'Text nodes';
+ } else {
+ tagDisplayName = 'Whitespace text nodes';
+ whitespaceInfo = ' Make sure you don\'t have any extra whitespace between tags on ' + 'each line of your source code.';
+ }
+ } else {
tagDisplayName = '<' + childTag + '>';
}
@@ -30206,7 +28440,7 @@ if (process.env.NODE_ENV !== 'production') {
if (ancestorTag === 'table' && childTag === 'tr') {
info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.';
}
- process.env.NODE_ENV !== 'production' ? warning(false, 'validateDOMNesting(...): %s cannot appear as a child of <%s>. ' + 'See %s.%s', tagDisplayName, ancestorTag, ownerInfo, info) : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(false, 'validateDOMNesting(...): %s cannot appear as a child of <%s>.%s ' + 'See %s.%s', tagDisplayName, ancestorTag, whitespaceInfo, ownerInfo, info) : void 0;
} else {
process.env.NODE_ENV !== 'production' ? warning(false, 'validateDOMNesting(...): %s cannot appear as a descendant of ' + '<%s>. See %s.', tagDisplayName, ancestorTag, ownerInfo) : void 0;
}
@@ -30227,523 +28461,2231 @@ if (process.env.NODE_ENV !== 'production') {
module.exports = validateDOMNesting;
}).call(this,require('_process'))
-},{"_process":15,"fbjs/lib/emptyFunction":170,"fbjs/lib/warning":188,"object-assign":14}],163:[function(require,module,exports){
+},{"_process":43,"fbjs/lib/emptyFunction":10,"fbjs/lib/warning":25,"object-assign":170}],170:[function(require,module,exports){
+/*
+object-assign
+(c) Sindre Sorhus
+@license MIT
+*/
+
+'use strict';
+/* eslint-disable no-unused-vars */
+var getOwnPropertySymbols = Object.getOwnPropertySymbols;
+var hasOwnProperty = Object.prototype.hasOwnProperty;
+var propIsEnumerable = Object.prototype.propertyIsEnumerable;
+
+function toObject(val) {
+ if (val === null || val === undefined) {
+ throw new TypeError('Object.assign cannot be called with null or undefined');
+ }
+
+ return Object(val);
+}
+
+function shouldUseNative() {
+ try {
+ if (!Object.assign) {
+ return false;
+ }
+
+ // Detect buggy property enumeration order in older V8 versions.
+
+ // https://bugs.chromium.org/p/v8/issues/detail?id=4118
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
+ test1[5] = 'de';
+ if (Object.getOwnPropertyNames(test1)[0] === '5') {
+ return false;
+ }
+
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
+ var test2 = {};
+ for (var i = 0; i < 10; i++) {
+ test2['_' + String.fromCharCode(i)] = i;
+ }
+ var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
+ return test2[n];
+ });
+ if (order2.join('') !== '0123456789') {
+ return false;
+ }
+
+ // https://bugs.chromium.org/p/v8/issues/detail?id=3056
+ var test3 = {};
+ 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
+ test3[letter] = letter;
+ });
+ if (Object.keys(Object.assign({}, test3)).join('') !==
+ 'abcdefghijklmnopqrst') {
+ return false;
+ }
+
+ return true;
+ } catch (err) {
+ // We don't expect any of the above to throw, but better to be safe.
+ return false;
+ }
+}
+
+module.exports = shouldUseNative() ? Object.assign : function (target, source) {
+ var from;
+ var to = toObject(target);
+ var symbols;
+
+ for (var s = 1; s < arguments.length; s++) {
+ from = Object(arguments[s]);
+
+ for (var key in from) {
+ if (hasOwnProperty.call(from, key)) {
+ to[key] = from[key];
+ }
+ }
+
+ if (getOwnPropertySymbols) {
+ symbols = getOwnPropertySymbols(from);
+ for (var i = 0; i < symbols.length; i++) {
+ if (propIsEnumerable.call(from, symbols[i])) {
+ to[symbols[i]] = from[symbols[i]];
+ }
+ }
+ }
+ }
+
+ return to;
+};
+
+},{}],171:[function(require,module,exports){
(function (process){
'use strict';
-/**
- * Copyright (c) 2013-present, 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.
- *
- * @typechecks
- */
+exports.__esModule = true;
+exports.default = undefined;
-var emptyFunction = require('./emptyFunction');
+var _react = require('react');
-/**
- * Upstream version of event listener. Does not take into account specific
- * nature of platform.
- */
-var EventListener = {
- /**
- * Listen to DOM events during the bubble phase.
- *
- * @param {DOMEventTarget} target DOM element to register listener on.
- * @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
- * @param {function} callback Callback function.
- * @return {object} Object with a `remove` method.
- */
- listen: function listen(target, eventType, callback) {
- if (target.addEventListener) {
- target.addEventListener(eventType, callback, false);
- return {
- remove: function remove() {
- target.removeEventListener(eventType, callback, false);
- }
+var _Subscription = require('../utils/Subscription');
+
+var _Subscription2 = _interopRequireDefault(_Subscription);
+
+var _storeShape = require('../utils/storeShape');
+
+var _storeShape2 = _interopRequireDefault(_storeShape);
+
+var _warning = require('../utils/warning');
+
+var _warning2 = _interopRequireDefault(_warning);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+var didWarnAboutReceivingStore = false;
+function warnAboutReceivingStore() {
+ if (didWarnAboutReceivingStore) {
+ return;
+ }
+ didWarnAboutReceivingStore = true;
+
+ (0, _warning2.default)('<Provider> does not support changing `store` on the fly. ' + 'It is most likely that you see this error because you updated to ' + 'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' + 'automatically. See https://github.com/reactjs/react-redux/releases/' + 'tag/v2.0.0 for the migration instructions.');
+}
+
+var Provider = function (_Component) {
+ _inherits(Provider, _Component);
+
+ Provider.prototype.getChildContext = function getChildContext() {
+ return { store: this.store, storeSubscription: null };
+ };
+
+ function Provider(props, context) {
+ _classCallCheck(this, Provider);
+
+ var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
+
+ _this.store = props.store;
+ return _this;
+ }
+
+ Provider.prototype.render = function render() {
+ return _react.Children.only(this.props.children);
+ };
+
+ return Provider;
+}(_react.Component);
+
+exports.default = Provider;
+
+
+if (process.env.NODE_ENV !== 'production') {
+ Provider.prototype.componentWillReceiveProps = function (nextProps) {
+ var store = this.store;
+ var nextStore = nextProps.store;
+
+
+ if (store !== nextStore) {
+ warnAboutReceivingStore();
+ }
+ };
+}
+
+Provider.propTypes = {
+ store: _storeShape2.default.isRequired,
+ children: _react.PropTypes.element.isRequired
+};
+Provider.childContextTypes = {
+ store: _storeShape2.default.isRequired,
+ storeSubscription: _react.PropTypes.instanceOf(_Subscription2.default)
+};
+Provider.displayName = 'Provider';
+}).call(this,require('_process'))
+
+},{"../utils/Subscription":180,"../utils/storeShape":182,"../utils/warning":184,"_process":43,"react":"react"}],172:[function(require,module,exports){
+(function (process){
+'use strict';
+
+exports.__esModule = true;
+
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
+
+exports.default = connectAdvanced;
+
+var _hoistNonReactStatics = require('hoist-non-react-statics');
+
+var _hoistNonReactStatics2 = _interopRequireDefault(_hoistNonReactStatics);
+
+var _invariant = require('invariant');
+
+var _invariant2 = _interopRequireDefault(_invariant);
+
+var _react = require('react');
+
+var _Subscription = require('../utils/Subscription');
+
+var _Subscription2 = _interopRequireDefault(_Subscription);
+
+var _storeShape = require('../utils/storeShape');
+
+var _storeShape2 = _interopRequireDefault(_storeShape);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
+
+var hotReloadingVersion = 0;
+function connectAdvanced(
+/*
+ selectorFactory is a func that is responsible for returning the selector function used to
+ compute new props from state, props, and dispatch. For example:
+ export default connectAdvanced((dispatch, options) => (state, props) => ({
+ thing: state.things[props.thingId],
+ saveThing: fields => dispatch(actionCreators.saveThing(props.thingId, fields)),
+ }))(YourComponent)
+ Access to dispatch is provided to the factory so selectorFactories can bind actionCreators
+ outside of their selector as an optimization. Options passed to connectAdvanced are passed to
+ the selectorFactory, along with displayName and WrappedComponent, as the second argument.
+ Note that selectorFactory is responsible for all caching/memoization of inbound and outbound
+ props. Do not use connectAdvanced directly without memoizing results between calls to your
+ selector, otherwise the Connect component will re-render on every state or props change.
+*/
+selectorFactory) {
+ var _contextTypes, _childContextTypes;
+
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$getDisplayName = _ref.getDisplayName,
+ getDisplayName = _ref$getDisplayName === undefined ? function (name) {
+ return 'ConnectAdvanced(' + name + ')';
+ } : _ref$getDisplayName,
+ _ref$methodName = _ref.methodName,
+ methodName = _ref$methodName === undefined ? 'connectAdvanced' : _ref$methodName,
+ _ref$renderCountProp = _ref.renderCountProp,
+ renderCountProp = _ref$renderCountProp === undefined ? undefined : _ref$renderCountProp,
+ _ref$shouldHandleStat = _ref.shouldHandleStateChanges,
+ shouldHandleStateChanges = _ref$shouldHandleStat === undefined ? true : _ref$shouldHandleStat,
+ _ref$storeKey = _ref.storeKey,
+ storeKey = _ref$storeKey === undefined ? 'store' : _ref$storeKey,
+ _ref$withRef = _ref.withRef,
+ withRef = _ref$withRef === undefined ? false : _ref$withRef,
+ connectOptions = _objectWithoutProperties(_ref, ['getDisplayName', 'methodName', 'renderCountProp', 'shouldHandleStateChanges', 'storeKey', 'withRef']);
+
+ var subscriptionKey = storeKey + 'Subscription';
+ var version = hotReloadingVersion++;
+
+ var contextTypes = (_contextTypes = {}, _contextTypes[storeKey] = _storeShape2.default, _contextTypes[subscriptionKey] = _react.PropTypes.instanceOf(_Subscription2.default), _contextTypes);
+ var childContextTypes = (_childContextTypes = {}, _childContextTypes[subscriptionKey] = _react.PropTypes.instanceOf(_Subscription2.default), _childContextTypes);
+
+ return function wrapWithConnect(WrappedComponent) {
+ (0, _invariant2.default)(typeof WrappedComponent == 'function', 'You must pass a component to the function returned by ' + ('connect. Instead received ' + WrappedComponent));
+
+ var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
+
+ var displayName = getDisplayName(wrappedComponentName);
+
+ var selectorFactoryOptions = _extends({}, connectOptions, {
+ getDisplayName: getDisplayName,
+ methodName: methodName,
+ renderCountProp: renderCountProp,
+ shouldHandleStateChanges: shouldHandleStateChanges,
+ storeKey: storeKey,
+ withRef: withRef,
+ displayName: displayName,
+ wrappedComponentName: wrappedComponentName,
+ WrappedComponent: WrappedComponent
+ });
+
+ var Connect = function (_Component) {
+ _inherits(Connect, _Component);
+
+ function Connect(props, context) {
+ _classCallCheck(this, Connect);
+
+ var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
+
+ _this.version = version;
+ _this.state = {};
+ _this.renderCount = 0;
+ _this.store = _this.props[storeKey] || _this.context[storeKey];
+ _this.parentSub = props[subscriptionKey] || context[subscriptionKey];
+
+ _this.setWrappedInstance = _this.setWrappedInstance.bind(_this);
+
+ (0, _invariant2.default)(_this.store, 'Could not find "' + storeKey + '" in either the context or ' + ('props of "' + displayName + '". ') + 'Either wrap the root component in a <Provider>, ' + ('or explicitly pass "' + storeKey + '" as a prop to "' + displayName + '".'));
+
+ // make sure `getState` is properly bound in order to avoid breaking
+ // custom store implementations that rely on the store's context
+ _this.getState = _this.store.getState.bind(_this.store);
+
+ _this.initSelector();
+ _this.initSubscription();
+ return _this;
+ }
+
+ Connect.prototype.getChildContext = function getChildContext() {
+ var _ref2;
+
+ return _ref2 = {}, _ref2[subscriptionKey] = this.subscription || this.parentSub, _ref2;
};
- } else if (target.attachEvent) {
- target.attachEvent('on' + eventType, callback);
- return {
- remove: function remove() {
- target.detachEvent('on' + eventType, callback);
+
+ Connect.prototype.componentDidMount = function componentDidMount() {
+ if (!shouldHandleStateChanges) return;
+
+ // componentWillMount fires during server side rendering, but componentDidMount and
+ // componentWillUnmount do not. Because of this, trySubscribe happens during ...didMount.
+ // Otherwise, unsubscription would never take place during SSR, causing a memory leak.
+ // To handle the case where a child component may have triggered a state change by
+ // dispatching an action in its componentWillMount, we have to re-run the select and maybe
+ // re-render.
+ this.subscription.trySubscribe();
+ this.selector.run(this.props);
+ if (this.selector.shouldComponentUpdate) this.forceUpdate();
+ };
+
+ Connect.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
+ this.selector.run(nextProps);
+ };
+
+ Connect.prototype.shouldComponentUpdate = function shouldComponentUpdate() {
+ return this.selector.shouldComponentUpdate;
+ };
+
+ Connect.prototype.componentWillUnmount = function componentWillUnmount() {
+ if (this.subscription) this.subscription.tryUnsubscribe();
+ // these are just to guard against extra memory leakage if a parent element doesn't
+ // dereference this instance properly, such as an async callback that never finishes
+ this.subscription = null;
+ this.store = null;
+ this.parentSub = null;
+ this.selector.run = function () {};
+ };
+
+ Connect.prototype.getWrappedInstance = function getWrappedInstance() {
+ (0, _invariant2.default)(withRef, 'To access the wrapped instance, you need to specify ' + ('{ withRef: true } in the options argument of the ' + methodName + '() call.'));
+ return this.wrappedInstance;
+ };
+
+ Connect.prototype.setWrappedInstance = function setWrappedInstance(ref) {
+ this.wrappedInstance = ref;
+ };
+
+ Connect.prototype.initSelector = function initSelector() {
+ var dispatch = this.store.dispatch;
+ var getState = this.getState;
+
+ var sourceSelector = selectorFactory(dispatch, selectorFactoryOptions);
+
+ // wrap the selector in an object that tracks its results between runs
+ var selector = this.selector = {
+ shouldComponentUpdate: true,
+ props: sourceSelector(getState(), this.props),
+ run: function runComponentSelector(props) {
+ try {
+ var nextProps = sourceSelector(getState(), props);
+ if (selector.error || nextProps !== selector.props) {
+ selector.shouldComponentUpdate = true;
+ selector.props = nextProps;
+ selector.error = null;
+ }
+ } catch (error) {
+ selector.shouldComponentUpdate = true;
+ selector.error = error;
+ }
+ }
+ };
+ };
+
+ Connect.prototype.initSubscription = function initSubscription() {
+ var _this2 = this;
+
+ if (shouldHandleStateChanges) {
+ (function () {
+ var subscription = _this2.subscription = new _Subscription2.default(_this2.store, _this2.parentSub);
+ var dummyState = {};
+
+ subscription.onStateChange = function onStateChange() {
+ this.selector.run(this.props);
+
+ if (!this.selector.shouldComponentUpdate) {
+ subscription.notifyNestedSubs();
+ } else {
+ this.componentDidUpdate = function componentDidUpdate() {
+ this.componentDidUpdate = undefined;
+ subscription.notifyNestedSubs();
+ };
+
+ this.setState(dummyState);
+ }
+ }.bind(_this2);
+ })();
}
};
- }
- },
- /**
- * Listen to DOM events during the capture phase.
- *
- * @param {DOMEventTarget} target DOM element to register listener on.
- * @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
- * @param {function} callback Callback function.
- * @return {object} Object with a `remove` method.
- */
- capture: function capture(target, eventType, callback) {
- if (target.addEventListener) {
- target.addEventListener(eventType, callback, true);
- return {
- remove: function remove() {
- target.removeEventListener(eventType, callback, true);
+ Connect.prototype.isSubscribed = function isSubscribed() {
+ return Boolean(this.subscription) && this.subscription.isSubscribed();
+ };
+
+ Connect.prototype.addExtraProps = function addExtraProps(props) {
+ if (!withRef && !renderCountProp) return props;
+ // make a shallow copy so that fields added don't leak to the original selector.
+ // this is especially important for 'ref' since that's a reference back to the component
+ // instance. a singleton memoized selector would then be holding a reference to the
+ // instance, preventing the instance from being garbage collected, and that would be bad
+ var withExtras = _extends({}, props);
+ if (withRef) withExtras.ref = this.setWrappedInstance;
+ if (renderCountProp) withExtras[renderCountProp] = this.renderCount++;
+ return withExtras;
+ };
+
+ Connect.prototype.render = function render() {
+ var selector = this.selector;
+ selector.shouldComponentUpdate = false;
+
+ if (selector.error) {
+ throw selector.error;
+ } else {
+ return (0, _react.createElement)(WrappedComponent, this.addExtraProps(selector.props));
}
};
- } else {
- if (process.env.NODE_ENV !== 'production') {
- console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.');
- }
- return {
- remove: emptyFunction
+
+ return Connect;
+ }(_react.Component);
+
+ Connect.WrappedComponent = WrappedComponent;
+ Connect.displayName = displayName;
+ Connect.childContextTypes = childContextTypes;
+ Connect.contextTypes = contextTypes;
+ Connect.propTypes = contextTypes;
+
+ if (process.env.NODE_ENV !== 'production') {
+ Connect.prototype.componentWillUpdate = function componentWillUpdate() {
+ // We are hot reloading!
+ if (this.version !== version) {
+ this.version = version;
+ this.initSelector();
+
+ if (this.subscription) this.subscription.tryUnsubscribe();
+ this.initSubscription();
+ if (shouldHandleStateChanges) this.subscription.trySubscribe();
+ }
};
}
- },
-
- registerDefault: function registerDefault() {}
-};
-module.exports = EventListener;
+ return (0, _hoistNonReactStatics2.default)(Connect, WrappedComponent);
+ };
+}
}).call(this,require('_process'))
-},{"./emptyFunction":170,"_process":15}],164:[function(require,module,exports){
-/**
- * Copyright (c) 2013-present, 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.
- *
+},{"../utils/Subscription":180,"../utils/storeShape":182,"_process":43,"hoist-non-react-statics":26,"invariant":27,"react":"react"}],173:[function(require,module,exports){
+'use strict';
+
+exports.__esModule = true;
+
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
+
+exports.createConnect = createConnect;
+
+var _connectAdvanced = require('../components/connectAdvanced');
+
+var _connectAdvanced2 = _interopRequireDefault(_connectAdvanced);
+
+var _shallowEqual = require('../utils/shallowEqual');
+
+var _shallowEqual2 = _interopRequireDefault(_shallowEqual);
+
+var _mapDispatchToProps = require('./mapDispatchToProps');
+
+var _mapDispatchToProps2 = _interopRequireDefault(_mapDispatchToProps);
+
+var _mapStateToProps = require('./mapStateToProps');
+
+var _mapStateToProps2 = _interopRequireDefault(_mapStateToProps);
+
+var _mergeProps = require('./mergeProps');
+
+var _mergeProps2 = _interopRequireDefault(_mergeProps);
+
+var _selectorFactory = require('./selectorFactory');
+
+var _selectorFactory2 = _interopRequireDefault(_selectorFactory);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
+
+/*
+ connect is a facade over connectAdvanced. It turns its args into a compatible
+ selectorFactory, which has the signature:
+
+ (dispatch, options) => (nextState, nextOwnProps) => nextFinalProps
+
+ connect passes its args to connectAdvanced as options, which will in turn pass them to
+ selectorFactory each time a Connect component instance is instantiated or hot reloaded.
+
+ selectorFactory returns a final props selector from its mapStateToProps,
+ mapStateToPropsFactories, mapDispatchToProps, mapDispatchToPropsFactories, mergeProps,
+ mergePropsFactories, and pure args.
+
+ The resulting final props selector is called by the Connect component instance whenever
+ it receives new props or store state.
*/
+function match(arg, factories, name) {
+ for (var i = factories.length - 1; i >= 0; i--) {
+ var result = factories[i](arg);
+ if (result) return result;
+ }
+
+ return function (dispatch, options) {
+ throw new Error('Invalid value of type ' + typeof arg + ' for ' + name + ' argument when connecting component ' + options.wrappedComponentName + '.');
+ };
+}
+
+function strictEqual(a, b) {
+ return a === b;
+}
+
+// createConnect with default args builds the 'official' connect behavior. Calling it with
+// different options opens up some testing and extensibility scenarios
+function createConnect() {
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
+ _ref$connectHOC = _ref.connectHOC,
+ connectHOC = _ref$connectHOC === undefined ? _connectAdvanced2.default : _ref$connectHOC,
+ _ref$mapStateToPropsF = _ref.mapStateToPropsFactories,
+ mapStateToPropsFactories = _ref$mapStateToPropsF === undefined ? _mapStateToProps2.default : _ref$mapStateToPropsF,
+ _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories,
+ mapDispatchToPropsFactories = _ref$mapDispatchToPro === undefined ? _mapDispatchToProps2.default : _ref$mapDispatchToPro,
+ _ref$mergePropsFactor = _ref.mergePropsFactories,
+ mergePropsFactories = _ref$mergePropsFactor === undefined ? _mergeProps2.default : _ref$mergePropsFactor,
+ _ref$selectorFactory = _ref.selectorFactory,
+ selectorFactory = _ref$selectorFactory === undefined ? _selectorFactory2.default : _ref$selectorFactory;
+
+ return function connect(mapStateToProps, mapDispatchToProps, mergeProps) {
+ var _ref2 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
+ _ref2$pure = _ref2.pure,
+ pure = _ref2$pure === undefined ? true : _ref2$pure,
+ _ref2$areStatesEqual = _ref2.areStatesEqual,
+ areStatesEqual = _ref2$areStatesEqual === undefined ? strictEqual : _ref2$areStatesEqual,
+ _ref2$areOwnPropsEqua = _ref2.areOwnPropsEqual,
+ areOwnPropsEqual = _ref2$areOwnPropsEqua === undefined ? _shallowEqual2.default : _ref2$areOwnPropsEqua,
+ _ref2$areStatePropsEq = _ref2.areStatePropsEqual,
+ areStatePropsEqual = _ref2$areStatePropsEq === undefined ? _shallowEqual2.default : _ref2$areStatePropsEq,
+ _ref2$areMergedPropsE = _ref2.areMergedPropsEqual,
+ areMergedPropsEqual = _ref2$areMergedPropsE === undefined ? _shallowEqual2.default : _ref2$areMergedPropsE,
+ extraOptions = _objectWithoutProperties(_ref2, ['pure', 'areStatesEqual', 'areOwnPropsEqual', 'areStatePropsEqual', 'areMergedPropsEqual']);
+
+ var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps');
+ var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps');
+ var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps');
+
+ return connectHOC(selectorFactory, _extends({
+ // used in error messages
+ methodName: 'connect',
+
+ // used to compute Connect's displayName from the wrapped component's displayName.
+ getDisplayName: function getDisplayName(name) {
+ return 'Connect(' + name + ')';
+ },
+
+ // if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes
+ shouldHandleStateChanges: Boolean(mapStateToProps),
+
+ // passed through to selectorFactory
+ initMapStateToProps: initMapStateToProps,
+ initMapDispatchToProps: initMapDispatchToProps,
+ initMergeProps: initMergeProps,
+ pure: pure,
+ areStatesEqual: areStatesEqual,
+ areOwnPropsEqual: areOwnPropsEqual,
+ areStatePropsEqual: areStatePropsEqual,
+ areMergedPropsEqual: areMergedPropsEqual
+
+ }, extraOptions));
+ };
+}
+
+exports.default = createConnect();
+},{"../components/connectAdvanced":172,"../utils/shallowEqual":181,"./mapDispatchToProps":174,"./mapStateToProps":175,"./mergeProps":176,"./selectorFactory":177}],174:[function(require,module,exports){
'use strict';
-var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
+exports.__esModule = true;
+exports.whenMapDispatchToPropsIsFunction = whenMapDispatchToPropsIsFunction;
+exports.whenMapDispatchToPropsIsMissing = whenMapDispatchToPropsIsMissing;
+exports.whenMapDispatchToPropsIsObject = whenMapDispatchToPropsIsObject;
-/**
- * Simple, lightweight module assisting with the detection and context of
- * Worker. Helps avoid circular dependencies and allows code to reason about
- * whether or not they are in a Worker, even if they never include the main
- * `ReactWorker` dependency.
- */
-var ExecutionEnvironment = {
+var _redux = require('redux');
- canUseDOM: canUseDOM,
+var _wrapMapToProps = require('./wrapMapToProps');
- canUseWorkers: typeof Worker !== 'undefined',
+function whenMapDispatchToPropsIsFunction(mapDispatchToProps) {
+ return typeof mapDispatchToProps === 'function' ? (0, _wrapMapToProps.wrapMapToPropsFunc)(mapDispatchToProps, 'mapDispatchToProps') : undefined;
+}
- canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent),
+function whenMapDispatchToPropsIsMissing(mapDispatchToProps) {
+ return !mapDispatchToProps ? (0, _wrapMapToProps.wrapMapToPropsConstant)(function (dispatch) {
+ return { dispatch: dispatch };
+ }) : undefined;
+}
- canUseViewport: canUseDOM && !!window.screen,
+function whenMapDispatchToPropsIsObject(mapDispatchToProps) {
+ return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? (0, _wrapMapToProps.wrapMapToPropsConstant)(function (dispatch) {
+ return (0, _redux.bindActionCreators)(mapDispatchToProps, dispatch);
+ }) : undefined;
+}
- isInWorker: !canUseDOM // For now, this is true - might change in the future.
+exports.default = [whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject];
+},{"./wrapMapToProps":179,"redux":"redux"}],175:[function(require,module,exports){
+'use strict';
+
+exports.__esModule = true;
+exports.whenMapStateToPropsIsFunction = whenMapStateToPropsIsFunction;
+exports.whenMapStateToPropsIsMissing = whenMapStateToPropsIsMissing;
+
+var _wrapMapToProps = require('./wrapMapToProps');
+
+function whenMapStateToPropsIsFunction(mapStateToProps) {
+ return typeof mapStateToProps === 'function' ? (0, _wrapMapToProps.wrapMapToPropsFunc)(mapStateToProps, 'mapStateToProps') : undefined;
+}
+
+function whenMapStateToPropsIsMissing(mapStateToProps) {
+ return !mapStateToProps ? (0, _wrapMapToProps.wrapMapToPropsConstant)(function () {
+ return {};
+ }) : undefined;
+}
+
+exports.default = [whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing];
+},{"./wrapMapToProps":179}],176:[function(require,module,exports){
+(function (process){
+'use strict';
+
+exports.__esModule = true;
+
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
+
+exports.defaultMergeProps = defaultMergeProps;
+exports.wrapMergePropsFunc = wrapMergePropsFunc;
+exports.whenMergePropsIsFunction = whenMergePropsIsFunction;
+exports.whenMergePropsIsOmitted = whenMergePropsIsOmitted;
+
+var _verifyPlainObject = require('../utils/verifyPlainObject');
+
+var _verifyPlainObject2 = _interopRequireDefault(_verifyPlainObject);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function defaultMergeProps(stateProps, dispatchProps, ownProps) {
+ return _extends({}, ownProps, stateProps, dispatchProps);
+}
+
+function wrapMergePropsFunc(mergeProps) {
+ return function initMergePropsProxy(dispatch, _ref) {
+ var displayName = _ref.displayName,
+ pure = _ref.pure,
+ areMergedPropsEqual = _ref.areMergedPropsEqual;
+
+ var hasRunOnce = false;
+ var mergedProps = void 0;
+
+ return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
+ var nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
+
+ if (hasRunOnce) {
+ if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps;
+ } else {
+ hasRunOnce = true;
+ mergedProps = nextMergedProps;
+
+ if (process.env.NODE_ENV !== 'production') (0, _verifyPlainObject2.default)(mergedProps, displayName, 'mergeProps');
+ }
+ return mergedProps;
+ };
+ };
+}
+
+function whenMergePropsIsFunction(mergeProps) {
+ return typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : undefined;
+}
+
+function whenMergePropsIsOmitted(mergeProps) {
+ return !mergeProps ? function () {
+ return defaultMergeProps;
+ } : undefined;
+}
+
+exports.default = [whenMergePropsIsFunction, whenMergePropsIsOmitted];
+}).call(this,require('_process'))
+
+},{"../utils/verifyPlainObject":183,"_process":43}],177:[function(require,module,exports){
+(function (process){
+'use strict';
+
+exports.__esModule = true;
+exports.impureFinalPropsSelectorFactory = impureFinalPropsSelectorFactory;
+exports.pureFinalPropsSelectorFactory = pureFinalPropsSelectorFactory;
+exports.default = finalPropsSelectorFactory;
+
+var _verifySubselectors = require('./verifySubselectors');
+
+var _verifySubselectors2 = _interopRequireDefault(_verifySubselectors);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
+
+function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) {
+ return function impureFinalPropsSelector(state, ownProps) {
+ return mergeProps(mapStateToProps(state, ownProps), mapDispatchToProps(dispatch, ownProps), ownProps);
+ };
+}
+
+function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, _ref) {
+ var areStatesEqual = _ref.areStatesEqual,
+ areOwnPropsEqual = _ref.areOwnPropsEqual,
+ areStatePropsEqual = _ref.areStatePropsEqual;
+
+ var hasRunAtLeastOnce = false;
+ var state = void 0;
+ var ownProps = void 0;
+ var stateProps = void 0;
+ var dispatchProps = void 0;
+ var mergedProps = void 0;
+
+ function handleFirstCall(firstState, firstOwnProps) {
+ state = firstState;
+ ownProps = firstOwnProps;
+ stateProps = mapStateToProps(state, ownProps);
+ dispatchProps = mapDispatchToProps(dispatch, ownProps);
+ mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
+ hasRunAtLeastOnce = true;
+ return mergedProps;
+ }
+
+ function handleNewPropsAndNewState() {
+ stateProps = mapStateToProps(state, ownProps);
+
+ if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
+
+ mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
+ return mergedProps;
+ }
+
+ function handleNewProps() {
+ if (mapStateToProps.dependsOnOwnProps) stateProps = mapStateToProps(state, ownProps);
+
+ if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
+
+ mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
+ return mergedProps;
+ }
+
+ function handleNewState() {
+ var nextStateProps = mapStateToProps(state, ownProps);
+ var statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps);
+ stateProps = nextStateProps;
+
+ if (statePropsChanged) mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
+
+ return mergedProps;
+ }
+
+ function handleSubsequentCalls(nextState, nextOwnProps) {
+ var propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps);
+ var stateChanged = !areStatesEqual(nextState, state);
+ state = nextState;
+ ownProps = nextOwnProps;
+
+ if (propsChanged && stateChanged) return handleNewPropsAndNewState();
+ if (propsChanged) return handleNewProps();
+ if (stateChanged) return handleNewState();
+ return mergedProps;
+ }
+
+ return function pureFinalPropsSelector(nextState, nextOwnProps) {
+ return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps);
+ };
+}
+
+// TODO: Add more comments
+
+// If pure is true, the selector returned by selectorFactory will memoize its results,
+// allowing connectAdvanced's shouldComponentUpdate to return false if final
+// props have not changed. If false, the selector will always return a new
+// object and shouldComponentUpdate will always return true.
+
+function finalPropsSelectorFactory(dispatch, _ref2) {
+ var initMapStateToProps = _ref2.initMapStateToProps,
+ initMapDispatchToProps = _ref2.initMapDispatchToProps,
+ initMergeProps = _ref2.initMergeProps,
+ options = _objectWithoutProperties(_ref2, ['initMapStateToProps', 'initMapDispatchToProps', 'initMergeProps']);
+
+ var mapStateToProps = initMapStateToProps(dispatch, options);
+ var mapDispatchToProps = initMapDispatchToProps(dispatch, options);
+ var mergeProps = initMergeProps(dispatch, options);
+
+ if (process.env.NODE_ENV !== 'production') {
+ (0, _verifySubselectors2.default)(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName);
+ }
+
+ var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory;
+
+ return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
+}
+}).call(this,require('_process'))
+
+},{"./verifySubselectors":178,"_process":43}],178:[function(require,module,exports){
+'use strict';
+
+exports.__esModule = true;
+exports.default = verifySubselectors;
+
+var _warning = require('../utils/warning');
+
+var _warning2 = _interopRequireDefault(_warning);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function verify(selector, methodName, displayName) {
+ if (!selector) {
+ throw new Error('Unexpected value for ' + methodName + ' in ' + displayName + '.');
+ } else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') {
+ if (!selector.hasOwnProperty('dependsOnOwnProps')) {
+ (0, _warning2.default)('The selector for ' + methodName + ' of ' + displayName + ' did not specify a value for dependsOnOwnProps.');
+ }
+ }
+}
+
+function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, displayName) {
+ verify(mapStateToProps, 'mapStateToProps', displayName);
+ verify(mapDispatchToProps, 'mapDispatchToProps', displayName);
+ verify(mergeProps, 'mergeProps', displayName);
+}
+},{"../utils/warning":184}],179:[function(require,module,exports){
+(function (process){
+'use strict';
+
+exports.__esModule = true;
+exports.wrapMapToPropsConstant = wrapMapToPropsConstant;
+exports.getDependsOnOwnProps = getDependsOnOwnProps;
+exports.wrapMapToPropsFunc = wrapMapToPropsFunc;
+
+var _verifyPlainObject = require('../utils/verifyPlainObject');
+
+var _verifyPlainObject2 = _interopRequireDefault(_verifyPlainObject);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function wrapMapToPropsConstant(getConstant) {
+ return function initConstantSelector(dispatch, options) {
+ var constant = getConstant(dispatch, options);
+
+ function constantSelector() {
+ return constant;
+ }
+ constantSelector.dependsOnOwnProps = false;
+ return constantSelector;
+ };
+}
+
+// dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args
+// to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine
+// whether mapToProps needs to be invoked when props have changed.
+//
+// A length of one signals that mapToProps does not depend on props from the parent component.
+// A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and
+// therefore not reporting its length accurately..
+function getDependsOnOwnProps(mapToProps) {
+ return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;
+}
+
+// Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction,
+// this function wraps mapToProps in a proxy function which does several things:
+//
+// * Detects whether the mapToProps function being called depends on props, which
+// is used by selectorFactory to decide if it should reinvoke on props changes.
+//
+// * On first call, handles mapToProps if returns another function, and treats that
+// new function as the true mapToProps for subsequent calls.
+//
+// * On first call, verifies the first result is a plain object, in order to warn
+// the developer that their mapToProps function is not returning a valid result.
+//
+function wrapMapToPropsFunc(mapToProps, methodName) {
+ return function initProxySelector(dispatch, _ref) {
+ var displayName = _ref.displayName;
+
+ var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
+ return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch);
+ };
+
+ proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);
+
+ proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {
+ proxy.mapToProps = mapToProps;
+ var props = proxy(stateOrDispatch, ownProps);
+
+ if (typeof props === 'function') {
+ proxy.mapToProps = props;
+ proxy.dependsOnOwnProps = getDependsOnOwnProps(props);
+ props = proxy(stateOrDispatch, ownProps);
+ }
+
+ if (process.env.NODE_ENV !== 'production') (0, _verifyPlainObject2.default)(props, displayName, methodName);
+
+ return props;
+ };
+
+ return proxy;
+ };
+}
+}).call(this,require('_process'))
+
+},{"../utils/verifyPlainObject":183,"_process":43}],180:[function(require,module,exports){
+"use strict";
+
+exports.__esModule = true;
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+// encapsulates the subscription logic for connecting a component to the redux store, as
+// well as nesting subscriptions of descendant components, so that we can ensure the
+// ancestor components re-render before descendants
+
+var CLEARED = null;
+var nullListeners = {
+ notify: function notify() {}
};
-module.exports = ExecutionEnvironment;
-},{}],165:[function(require,module,exports){
+function createListenerCollection() {
+ // the current/next pattern is copied from redux's createStore code.
+ // TODO: refactor+expose that code to be reusable here?
+ var current = [];
+ var next = [];
+
+ return {
+ clear: function clear() {
+ next = CLEARED;
+ current = CLEARED;
+ },
+ notify: function notify() {
+ var listeners = current = next;
+ for (var i = 0; i < listeners.length; i++) {
+ listeners[i]();
+ }
+ },
+ subscribe: function subscribe(listener) {
+ var isSubscribed = true;
+ if (next === current) next = current.slice();
+ next.push(listener);
+
+ return function unsubscribe() {
+ if (!isSubscribed || current === CLEARED) return;
+ isSubscribed = false;
+
+ if (next === current) next = current.slice();
+ next.splice(next.indexOf(listener), 1);
+ };
+ }
+ };
+}
+
+var Subscription = function () {
+ function Subscription(store, parentSub) {
+ _classCallCheck(this, Subscription);
+
+ this.store = store;
+ this.parentSub = parentSub;
+ this.unsubscribe = null;
+ this.listeners = nullListeners;
+ }
+
+ Subscription.prototype.addNestedSub = function addNestedSub(listener) {
+ this.trySubscribe();
+ return this.listeners.subscribe(listener);
+ };
+
+ Subscription.prototype.notifyNestedSubs = function notifyNestedSubs() {
+ this.listeners.notify();
+ };
+
+ Subscription.prototype.isSubscribed = function isSubscribed() {
+ return Boolean(this.unsubscribe);
+ };
+
+ Subscription.prototype.trySubscribe = function trySubscribe() {
+ if (!this.unsubscribe) {
+ // this.onStateChange is set by connectAdvanced.initSubscription()
+ this.unsubscribe = this.parentSub ? this.parentSub.addNestedSub(this.onStateChange) : this.store.subscribe(this.onStateChange);
+
+ this.listeners = createListenerCollection();
+ }
+ };
+
+ Subscription.prototype.tryUnsubscribe = function tryUnsubscribe() {
+ if (this.unsubscribe) {
+ this.unsubscribe();
+ this.unsubscribe = null;
+ this.listeners.clear();
+ this.listeners = nullListeners;
+ }
+ };
+
+ return Subscription;
+}();
+
+exports.default = Subscription;
+},{}],181:[function(require,module,exports){
"use strict";
+exports.__esModule = true;
+exports.default = shallowEqual;
+var hasOwn = Object.prototype.hasOwnProperty;
+
+function shallowEqual(a, b) {
+ if (a === b) return true;
+
+ var countA = 0;
+ var countB = 0;
+
+ for (var key in a) {
+ if (hasOwn.call(a, key) && a[key] !== b[key]) return false;
+ countA++;
+ }
+
+ for (var _key in b) {
+ if (hasOwn.call(b, _key)) countB++;
+ }
+
+ return countA === countB;
+}
+},{}],182:[function(require,module,exports){
+'use strict';
+
+exports.__esModule = true;
+
+var _react = require('react');
+
+exports.default = _react.PropTypes.shape({
+ subscribe: _react.PropTypes.func.isRequired,
+ dispatch: _react.PropTypes.func.isRequired,
+ getState: _react.PropTypes.func.isRequired
+});
+},{"react":"react"}],183:[function(require,module,exports){
+'use strict';
+
+exports.__esModule = true;
+exports.default = verifyPlainObject;
+
+var _isPlainObject = require('lodash/isPlainObject');
+
+var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
+
+var _warning = require('./warning');
+
+var _warning2 = _interopRequireDefault(_warning);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function verifyPlainObject(value, displayName, methodName) {
+ if (!(0, _isPlainObject2.default)(value)) {
+ (0, _warning2.default)(methodName + '() in ' + displayName + ' must return a plain object. Instead received ' + value + '.');
+ }
+}
+},{"./warning":184,"lodash/isPlainObject":42}],184:[function(require,module,exports){
+'use strict';
+
+exports.__esModule = true;
+exports.default = warning;
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Prints a warning in the console if it exists.
+ *
+ * @param {String} message The warning message.
+ * @returns {void}
+ */
+function warning(message) {
+ /* eslint-disable no-console */
+ if (typeof console !== 'undefined' && typeof console.error === 'function') {
+ console.error(message);
+ }
+ /* eslint-enable no-console */
+ try {
+ // This error was thrown as a convenience so that if you enable
+ // "break on all exceptions" in your console,
+ // it would pause the execution at this line.
+ throw new Error(message);
+ /* eslint-disable no-empty */
+ } catch (e) {}
+ /* eslint-enable no-empty */
+}
+},{}],185:[function(require,module,exports){
+arguments[4][65][0].apply(exports,arguments)
+},{"dup":65}],186:[function(require,module,exports){
+(function (process){
+/**
+ * Copyright 2013-present, 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
+ *
*/
-var _hyphenPattern = /-(.)/g;
+'use strict';
+
+var _prodInvariant = require('./reactProdInvariant');
+
+var invariant = require('fbjs/lib/invariant');
/**
- * Camelcases a hyphenated string, for example:
- *
- * > camelize('background-color')
- * < "backgroundColor"
+ * Static poolers. Several custom versions for each potential number of
+ * arguments. A completely generic pooler is easy to implement, but would
+ * require accessing the `arguments` object. In each of these, `this` refers to
+ * the Class itself, not an instance. If any others are needed, simply add them
+ * here, or in their own files.
+ */
+var oneArgumentPooler = function (copyFieldsFrom) {
+ var Klass = this;
+ if (Klass.instancePool.length) {
+ var instance = Klass.instancePool.pop();
+ Klass.call(instance, copyFieldsFrom);
+ return instance;
+ } else {
+ return new Klass(copyFieldsFrom);
+ }
+};
+
+var twoArgumentPooler = function (a1, a2) {
+ var Klass = this;
+ if (Klass.instancePool.length) {
+ var instance = Klass.instancePool.pop();
+ Klass.call(instance, a1, a2);
+ return instance;
+ } else {
+ return new Klass(a1, a2);
+ }
+};
+
+var threeArgumentPooler = function (a1, a2, a3) {
+ var Klass = this;
+ if (Klass.instancePool.length) {
+ var instance = Klass.instancePool.pop();
+ Klass.call(instance, a1, a2, a3);
+ return instance;
+ } else {
+ return new Klass(a1, a2, a3);
+ }
+};
+
+var fourArgumentPooler = function (a1, a2, a3, a4) {
+ var Klass = this;
+ if (Klass.instancePool.length) {
+ var instance = Klass.instancePool.pop();
+ Klass.call(instance, a1, a2, a3, a4);
+ return instance;
+ } else {
+ return new Klass(a1, a2, a3, a4);
+ }
+};
+
+var standardReleaser = function (instance) {
+ var Klass = this;
+ !(instance instanceof Klass) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : _prodInvariant('25') : void 0;
+ instance.destructor();
+ if (Klass.instancePool.length < Klass.poolSize) {
+ Klass.instancePool.push(instance);
+ }
+};
+
+var DEFAULT_POOL_SIZE = 10;
+var DEFAULT_POOLER = oneArgumentPooler;
+
+/**
+ * Augments `CopyConstructor` to be a poolable class, augmenting only the class
+ * itself (statically) not adding any prototypical fields. Any CopyConstructor
+ * you give this may have a `poolSize` property, and will look for a
+ * prototypical `destructor` on instances.
*
- * @param {string} string
- * @return {string}
+ * @param {Function} CopyConstructor Constructor that can be used to reset.
+ * @param {Function} pooler Customizable pooler.
*/
-function camelize(string) {
- return string.replace(_hyphenPattern, function (_, character) {
- return character.toUpperCase();
- });
-}
+var addPoolingTo = function (CopyConstructor, pooler) {
+ // Casting as any so that flow ignores the actual implementation and trusts
+ // it to match the type we declared
+ var NewKlass = CopyConstructor;
+ NewKlass.instancePool = [];
+ NewKlass.getPooled = pooler || DEFAULT_POOLER;
+ if (!NewKlass.poolSize) {
+ NewKlass.poolSize = DEFAULT_POOL_SIZE;
+ }
+ NewKlass.release = standardReleaser;
+ return NewKlass;
+};
-module.exports = camelize;
-},{}],166:[function(require,module,exports){
+var PooledClass = {
+ addPoolingTo: addPoolingTo,
+ oneArgumentPooler: oneArgumentPooler,
+ twoArgumentPooler: twoArgumentPooler,
+ threeArgumentPooler: threeArgumentPooler,
+ fourArgumentPooler: fourArgumentPooler
+};
+
+module.exports = PooledClass;
+}).call(this,require('_process'))
+
+},{"./reactProdInvariant":207,"_process":43,"fbjs/lib/invariant":18}],187:[function(require,module,exports){
+(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, 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
*/
'use strict';
-var camelize = require('./camelize');
+var _assign = require('object-assign');
-var msPattern = /^-ms-/;
+var ReactChildren = require('./ReactChildren');
+var ReactComponent = require('./ReactComponent');
+var ReactPureComponent = require('./ReactPureComponent');
+var ReactClass = require('./ReactClass');
+var ReactDOMFactories = require('./ReactDOMFactories');
+var ReactElement = require('./ReactElement');
+var ReactPropTypes = require('./ReactPropTypes');
+var ReactVersion = require('./ReactVersion');
-/**
- * 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-'));
+var onlyChild = require('./onlyChild');
+var warning = require('fbjs/lib/warning');
+
+var createElement = ReactElement.createElement;
+var createFactory = ReactElement.createFactory;
+var cloneElement = ReactElement.cloneElement;
+
+if (process.env.NODE_ENV !== 'production') {
+ var ReactElementValidator = require('./ReactElementValidator');
+ createElement = ReactElementValidator.createElement;
+ createFactory = ReactElementValidator.createFactory;
+ cloneElement = ReactElementValidator.cloneElement;
}
-module.exports = camelizeStyleName;
-},{"./camelize":165}],167:[function(require,module,exports){
-'use strict';
+var __spread = _assign;
+
+if (process.env.NODE_ENV !== 'production') {
+ var warned = false;
+ __spread = function () {
+ process.env.NODE_ENV !== 'production' ? warning(warned, 'React.__spread is deprecated and should not be used. Use ' + 'Object.assign directly or another helper function with similar ' + 'semantics. You may be seeing this warning due to your compiler. ' + 'See https://fb.me/react-spread-deprecation for more details.') : void 0;
+ warned = true;
+ return _assign.apply(null, arguments);
+ };
+}
+
+var React = {
+
+ // Modern
+
+ Children: {
+ map: ReactChildren.map,
+ forEach: ReactChildren.forEach,
+ count: ReactChildren.count,
+ toArray: ReactChildren.toArray,
+ only: onlyChild
+ },
+
+ Component: ReactComponent,
+ PureComponent: ReactPureComponent,
+
+ createElement: createElement,
+ cloneElement: cloneElement,
+ isValidElement: ReactElement.isValidElement,
+
+ // Classic
+
+ PropTypes: ReactPropTypes,
+ createClass: ReactClass.createClass,
+ createFactory: createFactory,
+ createMixin: function (mixin) {
+ // Currently a noop. Will be used to validate and trace mixins.
+ return mixin;
+ },
+
+ // This looks DOM specific but these are actually isomorphic helpers
+ // since they are just generating DOM strings.
+ DOM: ReactDOMFactories,
+
+ version: ReactVersion,
+ // Deprecated hook for JSX spread, don't use this for anything.
+ __spread: __spread
+};
+
+module.exports = React;
+}).call(this,require('_process'))
+
+},{"./ReactChildren":188,"./ReactClass":189,"./ReactComponent":190,"./ReactDOMFactories":193,"./ReactElement":194,"./ReactElementValidator":196,"./ReactPropTypes":199,"./ReactPureComponent":201,"./ReactVersion":202,"./onlyChild":206,"_process":43,"fbjs/lib/warning":25,"object-assign":209}],188:[function(require,module,exports){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, 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.
*
- *
*/
-var isTextNode = require('./isTextNode');
+'use strict';
-/*eslint-disable no-bitwise */
+var PooledClass = require('./PooledClass');
+var ReactElement = require('./ReactElement');
+
+var emptyFunction = require('fbjs/lib/emptyFunction');
+var traverseAllChildren = require('./traverseAllChildren');
+
+var twoArgumentPooler = PooledClass.twoArgumentPooler;
+var fourArgumentPooler = PooledClass.fourArgumentPooler;
+
+var userProvidedKeyEscapeRegex = /\/+/g;
+function escapeUserProvidedKey(text) {
+ return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
+}
/**
- * Checks if a given DOM node contains or is another DOM node.
+ * PooledClass representing the bookkeeping associated with performing a child
+ * traversal. Allows avoiding binding callbacks.
+ *
+ * @constructor ForEachBookKeeping
+ * @param {!function} forEachFunction Function to perform traversal with.
+ * @param {?*} forEachContext Context to perform context with.
*/
-function containsNode(outerNode, innerNode) {
- if (!outerNode || !innerNode) {
- return false;
- } else if (outerNode === innerNode) {
- return true;
- } else if (isTextNode(outerNode)) {
- return false;
- } else if (isTextNode(innerNode)) {
- return containsNode(outerNode, innerNode.parentNode);
- } else if ('contains' in outerNode) {
- return outerNode.contains(innerNode);
- } else if (outerNode.compareDocumentPosition) {
- return !!(outerNode.compareDocumentPosition(innerNode) & 16);
- } else {
- return false;
- }
+function ForEachBookKeeping(forEachFunction, forEachContext) {
+ this.func = forEachFunction;
+ this.context = forEachContext;
+ this.count = 0;
}
+ForEachBookKeeping.prototype.destructor = function () {
+ this.func = null;
+ this.context = null;
+ this.count = 0;
+};
+PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
-module.exports = containsNode;
-},{"./isTextNode":180}],168:[function(require,module,exports){
-(function (process){
-'use strict';
+function forEachSingleChild(bookKeeping, child, name) {
+ var func = bookKeeping.func,
+ context = bookKeeping.context;
+
+ func.call(context, child, bookKeeping.count++);
+}
/**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
+ * Iterates through children that are typically specified as `props.children`.
*
- * 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.
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.children.foreach
*
- * @typechecks
+ * The provided forEachFunc(child, index) will be called for each
+ * leaf child.
+ *
+ * @param {?*} children Children tree container.
+ * @param {function(*, int)} forEachFunc
+ * @param {*} forEachContext Context for forEachContext.
*/
-
-var invariant = require('./invariant');
+function forEachChildren(children, forEachFunc, forEachContext) {
+ if (children == null) {
+ return children;
+ }
+ var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
+ traverseAllChildren(children, forEachSingleChild, traverseContext);
+ ForEachBookKeeping.release(traverseContext);
+}
/**
- * Convert array-like objects to arrays.
- *
- * This API assumes the caller knows the contents of the data type. For less
- * well defined inputs use createArrayFromMixed.
+ * PooledClass representing the bookkeeping associated with performing a child
+ * mapping. Allows avoiding binding callbacks.
*
- * @param {object|function|filelist} obj
- * @return {array}
+ * @constructor MapBookKeeping
+ * @param {!*} mapResult Object containing the ordered map of results.
+ * @param {!function} mapFunction Function to perform mapping with.
+ * @param {?*} mapContext Context to perform mapping with.
*/
-function toArray(obj) {
- var length = obj.length;
-
- // Some browsers builtin objects can report typeof 'function' (e.g. NodeList
- // in old versions of Safari).
- !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : void 0;
+function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
+ this.result = mapResult;
+ this.keyPrefix = keyPrefix;
+ this.func = mapFunction;
+ this.context = mapContext;
+ this.count = 0;
+}
+MapBookKeeping.prototype.destructor = function () {
+ this.result = null;
+ this.keyPrefix = null;
+ this.func = null;
+ this.context = null;
+ this.count = 0;
+};
+PooledClass.addPoolingTo(MapBookKeeping, fourArgumentPooler);
- !(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : void 0;
+function mapSingleChildIntoContext(bookKeeping, child, childKey) {
+ var result = bookKeeping.result,
+ keyPrefix = bookKeeping.keyPrefix,
+ func = bookKeeping.func,
+ context = bookKeeping.context;
- !(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : void 0;
- !(typeof obj.callee !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant(false) : void 0;
-
- // Old IE doesn't give collections access to hasOwnProperty. Assume inputs
- // without method will throw during the slice call and skip straight to the
- // fallback.
- if (obj.hasOwnProperty) {
- try {
- return Array.prototype.slice.call(obj);
- } catch (e) {
- // IE < 9 does not support Array#slice on collections objects
+ var mappedChild = func.call(context, child, bookKeeping.count++);
+ if (Array.isArray(mappedChild)) {
+ mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
+ } else if (mappedChild != null) {
+ if (ReactElement.isValidElement(mappedChild)) {
+ mappedChild = ReactElement.cloneAndReplaceKey(mappedChild,
+ // Keep both the (mapped) and old keys if they differ, just as
+ // traverseAllChildren used to do for objects as children
+ keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
}
+ result.push(mappedChild);
}
+}
- // Fall back to copying key by key. This assumes all keys have a value,
- // so will not preserve sparsely populated inputs.
- var ret = Array(length);
- for (var ii = 0; ii < length; ii++) {
- ret[ii] = obj[ii];
+function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
+ var escapedPrefix = '';
+ if (prefix != null) {
+ escapedPrefix = escapeUserProvidedKey(prefix) + '/';
}
- return ret;
+ var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
+ traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
+ MapBookKeeping.release(traverseContext);
}
/**
- * Perform a heuristic test to determine if an object is "array-like".
- *
- * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
- * Joshu replied: "Mu."
+ * Maps children that are typically specified as `props.children`.
*
- * This function determines if its argument has "array nature": it returns
- * true if the argument is an actual array, an `arguments' object, or an
- * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.children.map
*
- * It will return false for other array-like objects like Filelist.
+ * The provided mapFunction(child, key, index) will be called for each
+ * leaf child.
*
- * @param {*} obj
- * @return {boolean}
+ * @param {?*} children Children tree container.
+ * @param {function(*, int)} func The map function.
+ * @param {*} context Context for mapFunction.
+ * @return {object} Object containing the ordered map of results.
*/
-function hasArrayNature(obj) {
- return(
- // not null/false
- !!obj && (
- // arrays are objects, NodeLists are functions in Safari
- typeof obj == 'object' || typeof obj == 'function') &&
- // quacks like an array
- 'length' in obj &&
- // not window
- !('setInterval' in obj) &&
- // no DOM node should be considered an array-like
- // a 'select' element has 'length' and 'item' properties on IE8
- typeof obj.nodeType != 'number' && (
- // a real array
- Array.isArray(obj) ||
- // arguments
- 'callee' in obj ||
- // HTMLCollection/NodeList
- 'item' in obj)
- );
+function mapChildren(children, func, context) {
+ if (children == null) {
+ return children;
+ }
+ var result = [];
+ mapIntoWithKeyPrefixInternal(children, result, null, func, context);
+ return result;
+}
+
+function forEachSingleChildDummy(traverseContext, child, name) {
+ return null;
}
/**
- * Ensure that the argument is an array by wrapping it in an array if it is not.
- * Creates a copy of the argument if it is already an array.
- *
- * This is mostly useful idiomatically:
- *
- * var createArrayFromMixed = require('createArrayFromMixed');
- *
- * function takesOneOrMoreThings(things) {
- * things = createArrayFromMixed(things);
- * ...
- * }
+ * Count the number of children that are typically specified as
+ * `props.children`.
*
- * This allows you to treat `things' as an array, but accept scalars in the API.
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.children.count
*
- * If you need to convert an array-like object, like `arguments`, into an array
- * use toArray instead.
+ * @param {?*} children Children tree container.
+ * @return {number} The number of children.
+ */
+function countChildren(children, context) {
+ return traverseAllChildren(children, forEachSingleChildDummy, null);
+}
+
+/**
+ * Flatten a children object (typically specified as `props.children`) and
+ * return an array with appropriately re-keyed children.
*
- * @param {*} obj
- * @return {array}
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.children.toarray
*/
-function createArrayFromMixed(obj) {
- if (!hasArrayNature(obj)) {
- return [obj];
- } else if (Array.isArray(obj)) {
- return obj.slice();
- } else {
- return toArray(obj);
- }
+function toArray(children) {
+ var result = [];
+ mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
+ return result;
}
-module.exports = createArrayFromMixed;
-}).call(this,require('_process'))
+var ReactChildren = {
+ forEach: forEachChildren,
+ map: mapChildren,
+ mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
+ count: countChildren,
+ toArray: toArray
+};
-},{"./invariant":178,"_process":15}],169:[function(require,module,exports){
+module.exports = ReactChildren;
+},{"./PooledClass":186,"./ReactElement":194,"./traverseAllChildren":208,"fbjs/lib/emptyFunction":10}],189:[function(require,module,exports){
(function (process){
-'use strict';
-
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, 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
*/
-/*eslint-disable fb-www/unsafe-html*/
+'use strict';
-var ExecutionEnvironment = require('./ExecutionEnvironment');
+var _prodInvariant = require('./reactProdInvariant'),
+ _assign = require('object-assign');
-var createArrayFromMixed = require('./createArrayFromMixed');
-var getMarkupWrap = require('./getMarkupWrap');
-var invariant = require('./invariant');
+var ReactComponent = require('./ReactComponent');
+var ReactElement = require('./ReactElement');
+var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
+var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
+
+var emptyObject = require('fbjs/lib/emptyObject');
+var invariant = require('fbjs/lib/invariant');
+var warning = require('fbjs/lib/warning');
+
+var MIXINS_KEY = 'mixins';
+
+// Helper function to allow the creation of anonymous functions which do not
+// have .name set to the name of the variable being assigned to.
+function identity(fn) {
+ return fn;
+}
/**
- * Dummy container used to render all markup.
+ * Policies that describe methods in `ReactClassInterface`.
*/
-var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
+
+
+var injectedMixins = [];
/**
- * Pattern used by `getNodeName`.
+ * Composite components are higher-level components that compose other composite
+ * or host components.
+ *
+ * To create a new type of `ReactClass`, pass a specification of
+ * your new class to `React.createClass`. The only requirement of your class
+ * specification is that you implement a `render` method.
+ *
+ * var MyComponent = React.createClass({
+ * render: function() {
+ * return <div>Hello World</div>;
+ * }
+ * });
+ *
+ * The class specification supports a specific protocol of methods that have
+ * special meaning (e.g. `render`). See `ReactClassInterface` for
+ * more the comprehensive protocol. Any other properties and methods in the
+ * class specification will be available on the prototype.
+ *
+ * @interface ReactClassInterface
+ * @internal
*/
-var nodeNamePattern = /^\s*<(\w+)/;
+var ReactClassInterface = {
+
+ /**
+ * An array of Mixin objects to include when defining your component.
+ *
+ * @type {array}
+ * @optional
+ */
+ mixins: 'DEFINE_MANY',
+
+ /**
+ * An object containing properties and methods that should be defined on
+ * the component's constructor instead of its prototype (static methods).
+ *
+ * @type {object}
+ * @optional
+ */
+ statics: 'DEFINE_MANY',
+
+ /**
+ * Definition of prop types for this component.
+ *
+ * @type {object}
+ * @optional
+ */
+ propTypes: 'DEFINE_MANY',
+
+ /**
+ * Definition of context types for this component.
+ *
+ * @type {object}
+ * @optional
+ */
+ contextTypes: 'DEFINE_MANY',
+
+ /**
+ * Definition of context types this component sets for its children.
+ *
+ * @type {object}
+ * @optional
+ */
+ childContextTypes: 'DEFINE_MANY',
+
+ // ==== Definition methods ====
+
+ /**
+ * Invoked when the component is mounted. Values in the mapping will be set on
+ * `this.props` if that prop is not specified (i.e. using an `in` check).
+ *
+ * This method is invoked before `getInitialState` and therefore cannot rely
+ * on `this.state` or use `this.setState`.
+ *
+ * @return {object}
+ * @optional
+ */
+ getDefaultProps: 'DEFINE_MANY_MERGED',
+
+ /**
+ * Invoked once before the component is mounted. The return value will be used
+ * as the initial value of `this.state`.
+ *
+ * getInitialState: function() {
+ * return {
+ * isOn: false,
+ * fooBaz: new BazFoo()
+ * }
+ * }
+ *
+ * @return {object}
+ * @optional
+ */
+ getInitialState: 'DEFINE_MANY_MERGED',
+
+ /**
+ * @return {object}
+ * @optional
+ */
+ getChildContext: 'DEFINE_MANY_MERGED',
+
+ /**
+ * Uses props from `this.props` and state from `this.state` to render the
+ * structure of the component.
+ *
+ * No guarantees are made about when or how often this method is invoked, so
+ * it must not have side effects.
+ *
+ * render: function() {
+ * var name = this.props.name;
+ * return <div>Hello, {name}!</div>;
+ * }
+ *
+ * @return {ReactComponent}
+ * @nosideeffects
+ * @required
+ */
+ render: 'DEFINE_ONCE',
+
+ // ==== Delegate methods ====
+
+ /**
+ * Invoked when the component is initially created and about to be mounted.
+ * This may have side effects, but any external subscriptions or data created
+ * by this method must be cleaned up in `componentWillUnmount`.
+ *
+ * @optional
+ */
+ componentWillMount: 'DEFINE_MANY',
+
+ /**
+ * Invoked when the component has been mounted and has a DOM representation.
+ * However, there is no guarantee that the DOM node is in the document.
+ *
+ * Use this as an opportunity to operate on the DOM when the component has
+ * been mounted (initialized and rendered) for the first time.
+ *
+ * @param {DOMElement} rootNode DOM element representing the component.
+ * @optional
+ */
+ componentDidMount: 'DEFINE_MANY',
+
+ /**
+ * Invoked before the component receives new props.
+ *
+ * Use this as an opportunity to react to a prop transition by updating the
+ * state using `this.setState`. Current props are accessed via `this.props`.
+ *
+ * componentWillReceiveProps: function(nextProps, nextContext) {
+ * this.setState({
+ * likesIncreasing: nextProps.likeCount > this.props.likeCount
+ * });
+ * }
+ *
+ * NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
+ * transition may cause a state change, but the opposite is not true. If you
+ * need it, you are probably looking for `componentWillUpdate`.
+ *
+ * @param {object} nextProps
+ * @optional
+ */
+ componentWillReceiveProps: 'DEFINE_MANY',
+
+ /**
+ * Invoked while deciding if the component should be updated as a result of
+ * receiving new props, state and/or context.
+ *
+ * Use this as an opportunity to `return false` when you're certain that the
+ * transition to the new props/state/context will not require a component
+ * update.
+ *
+ * shouldComponentUpdate: function(nextProps, nextState, nextContext) {
+ * return !equal(nextProps, this.props) ||
+ * !equal(nextState, this.state) ||
+ * !equal(nextContext, this.context);
+ * }
+ *
+ * @param {object} nextProps
+ * @param {?object} nextState
+ * @param {?object} nextContext
+ * @return {boolean} True if the component should update.
+ * @optional
+ */
+ shouldComponentUpdate: 'DEFINE_ONCE',
+
+ /**
+ * Invoked when the component is about to update due to a transition from
+ * `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
+ * and `nextContext`.
+ *
+ * Use this as an opportunity to perform preparation before an update occurs.
+ *
+ * NOTE: You **cannot** use `this.setState()` in this method.
+ *
+ * @param {object} nextProps
+ * @param {?object} nextState
+ * @param {?object} nextContext
+ * @param {ReactReconcileTransaction} transaction
+ * @optional
+ */
+ componentWillUpdate: 'DEFINE_MANY',
+
+ /**
+ * Invoked when the component's DOM representation has been updated.
+ *
+ * Use this as an opportunity to operate on the DOM when the component has
+ * been updated.
+ *
+ * @param {object} prevProps
+ * @param {?object} prevState
+ * @param {?object} prevContext
+ * @param {DOMElement} rootNode DOM element representing the component.
+ * @optional
+ */
+ componentDidUpdate: 'DEFINE_MANY',
+
+ /**
+ * Invoked when the component is about to be removed from its parent and have
+ * its DOM representation destroyed.
+ *
+ * Use this as an opportunity to deallocate any external resources.
+ *
+ * NOTE: There is no `componentDidUnmount` since your component will have been
+ * destroyed by that point.
+ *
+ * @optional
+ */
+ componentWillUnmount: 'DEFINE_MANY',
+
+ // ==== Advanced methods ====
+
+ /**
+ * Updates the component's currently mounted DOM representation.
+ *
+ * By default, this implements React's rendering and reconciliation algorithm.
+ * Sophisticated clients may wish to override this.
+ *
+ * @param {ReactReconcileTransaction} transaction
+ * @internal
+ * @overridable
+ */
+ updateComponent: 'OVERRIDE_BASE'
+
+};
/**
- * Extracts the `nodeName` of the first element in a string of markup.
+ * Mapping from class specification keys to special processing functions.
*
- * @param {string} markup String of markup.
- * @return {?string} Node name of the supplied markup.
+ * Although these are declared like instance properties in the specification
+ * when defining classes using `React.createClass`, they are actually static
+ * and are accessible on the constructor instead of the prototype. Despite
+ * being static, they must be defined outside of the "statics" key under
+ * which all other static methods are defined.
*/
-function getNodeName(markup) {
- var nodeNameMatch = markup.match(nodeNamePattern);
- return nodeNameMatch && nodeNameMatch[1].toLowerCase();
+var RESERVED_SPEC_KEYS = {
+ displayName: function (Constructor, displayName) {
+ Constructor.displayName = displayName;
+ },
+ mixins: function (Constructor, mixins) {
+ if (mixins) {
+ for (var i = 0; i < mixins.length; i++) {
+ mixSpecIntoComponent(Constructor, mixins[i]);
+ }
+ }
+ },
+ childContextTypes: function (Constructor, childContextTypes) {
+ if (process.env.NODE_ENV !== 'production') {
+ validateTypeDef(Constructor, childContextTypes, 'childContext');
+ }
+ Constructor.childContextTypes = _assign({}, Constructor.childContextTypes, childContextTypes);
+ },
+ contextTypes: function (Constructor, contextTypes) {
+ if (process.env.NODE_ENV !== 'production') {
+ validateTypeDef(Constructor, contextTypes, 'context');
+ }
+ Constructor.contextTypes = _assign({}, Constructor.contextTypes, contextTypes);
+ },
+ /**
+ * Special case getDefaultProps which should move into statics but requires
+ * automatic merging.
+ */
+ getDefaultProps: function (Constructor, getDefaultProps) {
+ if (Constructor.getDefaultProps) {
+ Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps);
+ } else {
+ Constructor.getDefaultProps = getDefaultProps;
+ }
+ },
+ propTypes: function (Constructor, propTypes) {
+ if (process.env.NODE_ENV !== 'production') {
+ validateTypeDef(Constructor, propTypes, 'prop');
+ }
+ Constructor.propTypes = _assign({}, Constructor.propTypes, propTypes);
+ },
+ statics: function (Constructor, statics) {
+ mixStaticSpecIntoComponent(Constructor, statics);
+ },
+ autobind: function () {} };
+
+function validateTypeDef(Constructor, typeDef, location) {
+ for (var propName in typeDef) {
+ if (typeDef.hasOwnProperty(propName)) {
+ // use a warning instead of an invariant so components
+ // don't show up in prod but only in __DEV__
+ process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : void 0;
+ }
+ }
+}
+
+function validateMethodOverride(isAlreadyDefined, name) {
+ var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
+
+ // Disallow overriding of base class methods unless explicitly allowed.
+ if (ReactClassMixin.hasOwnProperty(name)) {
+ !(specPolicy === 'OVERRIDE_BASE') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to override `%s` from your class specification. Ensure that your method names do not overlap with React methods.', name) : _prodInvariant('73', name) : void 0;
+ }
+
+ // Disallow defining methods more than once unless explicitly allowed.
+ if (isAlreadyDefined) {
+ !(specPolicy === 'DEFINE_MANY' || specPolicy === 'DEFINE_MANY_MERGED') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : _prodInvariant('74', name) : void 0;
+ }
}
/**
- * Creates an array containing the nodes rendered from the supplied markup. The
- * optionally supplied `handleScript` function will be invoked once for each
- * <script> element that is rendered. If no `handleScript` function is supplied,
- * an exception is thrown if any <script> elements are rendered.
- *
- * @param {string} markup A string of valid HTML markup.
- * @param {?function} handleScript Invoked once for each rendered <script>.
- * @return {array<DOMElement|DOMTextNode>} An array of rendered nodes.
+ * Mixin helper which handles policy validation and reserved
+ * specification keys when building React classes.
*/
-function createNodesFromMarkup(markup, handleScript) {
- var node = dummyNode;
- !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup dummy not initialized') : invariant(false) : void 0;
- var nodeName = getNodeName(markup);
-
- var wrap = nodeName && getMarkupWrap(nodeName);
- if (wrap) {
- node.innerHTML = wrap[1] + markup + wrap[2];
+function mixSpecIntoComponent(Constructor, spec) {
+ if (!spec) {
+ if (process.env.NODE_ENV !== 'production') {
+ var typeofSpec = typeof spec;
+ var isMixinValid = typeofSpec === 'object' && spec !== null;
- var wrapDepth = wrap[0];
- while (wrapDepth--) {
- node = node.lastChild;
+ process.env.NODE_ENV !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either null ' + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec) : void 0;
}
- } else {
- node.innerHTML = markup;
+
+ return;
}
- var scripts = node.getElementsByTagName('script');
- if (scripts.length) {
- !handleScript ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup(...): Unexpected <script> element rendered.') : invariant(false) : void 0;
- createArrayFromMixed(scripts).forEach(handleScript);
+ !(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to use a component class or function as a mixin. Instead, just use a regular object.') : _prodInvariant('75') : void 0;
+ !!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to use a component as a mixin. Instead, just use a regular object.') : _prodInvariant('76') : void 0;
+
+ var proto = Constructor.prototype;
+ var autoBindPairs = proto.__reactAutoBindPairs;
+
+ // 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);
}
- var nodes = Array.from(node.childNodes);
- while (node.lastChild) {
- node.removeChild(node.lastChild);
+ for (var name in spec) {
+ if (!spec.hasOwnProperty(name)) {
+ continue;
+ }
+
+ if (name === MIXINS_KEY) {
+ // We have already handled mixins in a special case above.
+ continue;
+ }
+
+ var property = spec[name];
+ var isAlreadyDefined = proto.hasOwnProperty(name);
+ validateMethodOverride(isAlreadyDefined, name);
+
+ if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
+ RESERVED_SPEC_KEYS[name](Constructor, property);
+ } else {
+ // Setup methods on prototype:
+ // The following member methods should not be automatically bound:
+ // 1. Expected ReactClass methods (in the "interface").
+ // 2. Overridden methods (that were mixed in).
+ var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
+ var isFunction = typeof property === 'function';
+ var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;
+
+ if (shouldAutoBind) {
+ autoBindPairs.push(name, property);
+ proto[name] = property;
+ } else {
+ if (isAlreadyDefined) {
+ var specPolicy = ReactClassInterface[name];
+
+ // These cases should already be caught by validateMethodOverride.
+ !(isReactClassMethod && (specPolicy === 'DEFINE_MANY_MERGED' || specPolicy === 'DEFINE_MANY')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s when mixing in component specs.', specPolicy, name) : _prodInvariant('77', specPolicy, name) : void 0;
+
+ // For methods which are defined more than once, call the existing
+ // methods before calling the new property, merging if appropriate.
+ if (specPolicy === 'DEFINE_MANY_MERGED') {
+ proto[name] = createMergedResultFunction(proto[name], property);
+ } else if (specPolicy === 'DEFINE_MANY') {
+ proto[name] = createChainedFunction(proto[name], property);
+ }
+ } else {
+ proto[name] = property;
+ if (process.env.NODE_ENV !== 'production') {
+ // Add verbose displayName to the function, which helps when looking
+ // at profiling tools.
+ if (typeof property === 'function' && spec.displayName) {
+ proto[name].displayName = spec.displayName + '_' + name;
+ }
+ }
+ }
+ }
+ }
}
- return nodes;
}
-module.exports = createNodesFromMarkup;
-}).call(this,require('_process'))
+function mixStaticSpecIntoComponent(Constructor, statics) {
+ if (!statics) {
+ return;
+ }
+ for (var name in statics) {
+ var property = statics[name];
+ if (!statics.hasOwnProperty(name)) {
+ continue;
+ }
-},{"./ExecutionEnvironment":164,"./createArrayFromMixed":168,"./getMarkupWrap":174,"./invariant":178,"_process":15}],170:[function(require,module,exports){
-"use strict";
+ var isReserved = name in RESERVED_SPEC_KEYS;
+ !!isReserved ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: 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) : _prodInvariant('78', name) : void 0;
+
+ var isInherited = name in Constructor;
+ !!isInherited ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define `%s` on your component more than once. This conflict may be due to a mixin.', name) : _prodInvariant('79', name) : void 0;
+ Constructor[name] = property;
+ }
+}
/**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
+ * Merge two objects, but throw if both contain the same key.
*
- * 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.
+ * @param {object} one The first object, which is mutated.
+ * @param {object} two The second object
+ * @return {object} one after it has been mutated to contain everything in two.
+ */
+function mergeIntoWithNoDuplicateKeys(one, two) {
+ !(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : _prodInvariant('80') : void 0;
+
+ for (var key in two) {
+ if (two.hasOwnProperty(key)) {
+ !(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): 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) : _prodInvariant('81', key) : void 0;
+ one[key] = two[key];
+ }
+ }
+ return one;
+}
+
+/**
+ * Creates a function that invokes two functions and merges their return values.
*
- *
+ * @param {function} one Function to invoke first.
+ * @param {function} two Function to invoke second.
+ * @return {function} Function that invokes the two argument functions.
+ * @private
*/
+function createMergedResultFunction(one, two) {
+ return function mergedResult() {
+ var a = one.apply(this, arguments);
+ var b = two.apply(this, arguments);
+ if (a == null) {
+ return b;
+ } else if (b == null) {
+ return a;
+ }
+ var c = {};
+ mergeIntoWithNoDuplicateKeys(c, a);
+ mergeIntoWithNoDuplicateKeys(c, b);
+ return c;
+ };
+}
-function makeEmptyFunction(arg) {
- return function () {
- return arg;
+/**
+ * Creates a function that invokes two functions and ignores their return vales.
+ *
+ * @param {function} one Function to invoke first.
+ * @param {function} two Function to invoke second.
+ * @return {function} Function that invokes the two argument functions.
+ * @private
+ */
+function createChainedFunction(one, two) {
+ return function chainedFunction() {
+ one.apply(this, arguments);
+ two.apply(this, arguments);
};
}
/**
- * This function accepts and discards inputs; it has no side effects. This is
- * primarily useful idiomatically for overridable function endpoints which
- * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
+ * Binds a method to the component.
+ *
+ * @param {object} component Component whose method is going to be bound.
+ * @param {function} method Method to be bound.
+ * @return {function} The bound method.
*/
-var emptyFunction = function emptyFunction() {};
+function bindAutoBindMethod(component, method) {
+ var boundMethod = method.bind(component);
+ if (process.env.NODE_ENV !== 'production') {
+ boundMethod.__reactBoundContext = component;
+ boundMethod.__reactBoundMethod = method;
+ boundMethod.__reactBoundArguments = null;
+ var componentName = component.constructor.displayName;
+ var _bind = boundMethod.bind;
+ boundMethod.bind = function (newThis) {
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ args[_key - 1] = arguments[_key];
+ }
-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;
-};
+ // 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.
+ if (newThis !== component && newThis !== null) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : void 0;
+ } else if (!args.length) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : void 0;
+ return boundMethod;
+ }
+ var reboundMethod = _bind.apply(boundMethod, arguments);
+ reboundMethod.__reactBoundContext = component;
+ reboundMethod.__reactBoundMethod = method;
+ reboundMethod.__reactBoundArguments = args;
+ return reboundMethod;
+ };
+ }
+ return boundMethod;
+}
-module.exports = emptyFunction;
-},{}],171:[function(require,module,exports){
-(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
+ * Binds all auto-bound methods in a component.
*
- * 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.
+ * @param {object} component Component whose method is going to be bound.
+ */
+function bindAutoBindMethods(component) {
+ var pairs = component.__reactAutoBindPairs;
+ for (var i = 0; i < pairs.length; i += 2) {
+ var autoBindKey = pairs[i];
+ var method = pairs[i + 1];
+ component[autoBindKey] = bindAutoBindMethod(component, method);
+ }
+}
+
+/**
+ * Add more to the ReactClass base class. These are all legacy features and
+ * therefore not already part of the modern ReactComponent.
+ */
+var ReactClassMixin = {
+
+ /**
+ * TODO: This will be deprecated because state should always keep a consistent
+ * type signature and the only use case for this, is to avoid that.
+ */
+ replaceState: function (newState, callback) {
+ this.updater.enqueueReplaceState(this, newState);
+ if (callback) {
+ this.updater.enqueueCallback(this, callback, 'replaceState');
+ }
+ },
+
+ /**
+ * Checks whether or not this composite component is mounted.
+ * @return {boolean} True if mounted, false otherwise.
+ * @protected
+ * @final
+ */
+ isMounted: function () {
+ return this.updater.isMounted(this);
+ }
+};
+
+var ReactClassComponent = function () {};
+_assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);
+
+/**
+ * Module for creating composite components.
*
+ * @class ReactClass
*/
+var ReactClass = {
-'use strict';
+ /**
+ * Creates a composite component class given a class specification.
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.createclass
+ *
+ * @param {object} spec Class specification (which must define `render`).
+ * @return {function} Component constructor function.
+ * @public
+ */
+ createClass: function (spec) {
+ // To keep our warnings more understandable, we'll use a little hack here to
+ // ensure that Constructor.name !== 'Constructor'. This makes sure we don't
+ // unnecessarily identify a class without displayName as 'Constructor'.
+ var Constructor = identity(function (props, context, updater) {
+ // This constructor gets overridden by mocks. The argument is used
+ // by mocks to assert on what gets mounted.
-var emptyObject = {};
+ if (process.env.NODE_ENV !== 'production') {
+ process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : void 0;
+ }
-if (process.env.NODE_ENV !== 'production') {
- Object.freeze(emptyObject);
-}
+ // Wire up auto-binding
+ if (this.__reactAutoBindPairs.length) {
+ bindAutoBindMethods(this);
+ }
-module.exports = emptyObject;
+ this.props = props;
+ this.context = context;
+ this.refs = emptyObject;
+ this.updater = updater || ReactNoopUpdateQueue;
+
+ this.state = null;
+
+ // ReactClasses doesn't have constructors. Instead, they use the
+ // getInitialState and componentWillMount methods for initialization.
+
+ var initialState = this.getInitialState ? this.getInitialState() : null;
+ if (process.env.NODE_ENV !== 'production') {
+ // We allow auto-mocks to proceed as if they're returning null.
+ if (initialState === undefined && this.getInitialState._isMockFunction) {
+ // This is probably bad practice. Consider warning here and
+ // deprecating this convenience.
+ initialState = null;
+ }
+ }
+ !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : _prodInvariant('82', Constructor.displayName || 'ReactCompositeComponent') : void 0;
+
+ this.state = initialState;
+ });
+ Constructor.prototype = new ReactClassComponent();
+ Constructor.prototype.constructor = Constructor;
+ Constructor.prototype.__reactAutoBindPairs = [];
+
+ injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
+
+ mixSpecIntoComponent(Constructor, spec);
+
+ // Initialize the defaultProps property after all mixins have been merged.
+ if (Constructor.getDefaultProps) {
+ Constructor.defaultProps = Constructor.getDefaultProps();
+ }
+
+ if (process.env.NODE_ENV !== 'production') {
+ // This is a tag to indicate that the use of these method names is ok,
+ // since it's used with createClass. If it's not, then it's likely a
+ // mistake so we'll warn you to use the static property, property
+ // initializer or constructor respectively.
+ if (Constructor.getDefaultProps) {
+ Constructor.getDefaultProps.isReactClassApproved = {};
+ }
+ if (Constructor.prototype.getInitialState) {
+ Constructor.prototype.getInitialState.isReactClassApproved = {};
+ }
+ }
+
+ !Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : _prodInvariant('83') : void 0;
+
+ if (process.env.NODE_ENV !== 'production') {
+ process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : void 0;
+ }
+
+ // Reduce time spent doing lookups by setting these on the prototype.
+ for (var methodName in ReactClassInterface) {
+ if (!Constructor.prototype[methodName]) {
+ Constructor.prototype[methodName] = null;
+ }
+ }
+
+ return Constructor;
+ },
+
+ injection: {
+ injectMixin: function (mixin) {
+ injectedMixins.push(mixin);
+ }
+ }
+
+};
+
+module.exports = ReactClass;
}).call(this,require('_process'))
-},{"_process":15}],172:[function(require,module,exports){
+},{"./ReactComponent":190,"./ReactElement":194,"./ReactNoopUpdateQueue":197,"./ReactPropTypeLocationNames":198,"./reactProdInvariant":207,"_process":43,"fbjs/lib/emptyObject":11,"fbjs/lib/invariant":18,"fbjs/lib/warning":25,"object-assign":209}],190:[function(require,module,exports){
+(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
@@ -30754,268 +30696,1004 @@ module.exports = emptyObject;
'use strict';
+var _prodInvariant = require('./reactProdInvariant');
+
+var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
+
+var canDefineProperty = require('./canDefineProperty');
+var emptyObject = require('fbjs/lib/emptyObject');
+var invariant = require('fbjs/lib/invariant');
+var warning = require('fbjs/lib/warning');
+
/**
- * @param {DOMElement} node input/textarea to focus
+ * Base class helpers for the updating state of a component.
*/
-
-function focusNode(node) {
- // 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) {}
+function ReactComponent(props, context, updater) {
+ this.props = props;
+ this.context = context;
+ this.refs = emptyObject;
+ // We initialize the default updater but the real one gets injected by the
+ // renderer.
+ this.updater = updater || ReactNoopUpdateQueue;
}
-module.exports = focusNode;
-},{}],173:[function(require,module,exports){
-'use strict';
+ReactComponent.prototype.isReactComponent = {};
/**
- * Copyright (c) 2013-present, Facebook, Inc.
- * All rights reserved.
+ * Sets a subset of the state. Always use this to mutate
+ * state. You should treat `this.state` as immutable.
*
- * 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.
+ * There is no guarantee that `this.state` will be immediately updated, so
+ * accessing `this.state` after calling this method may return the old value.
*
- * @typechecks
+ * There is no guarantee that calls to `setState` will run synchronously,
+ * as they may eventually be batched together. You can provide an optional
+ * callback that will be executed when the call to setState is actually
+ * completed.
+ *
+ * When a function is provided to setState, it will be called at some point in
+ * the future (not synchronously). It will be called with the up to date
+ * component arguments (state, props, context). These values can be different
+ * from this.* because your function may be called after receiveProps but before
+ * shouldComponentUpdate, and this new state, props, and context will not yet be
+ * assigned to this.
+ *
+ * @param {object|function} partialState Next partial state or function to
+ * produce next partial state to be merged with current state.
+ * @param {?function} callback Called after state is updated.
+ * @final
+ * @protected
*/
-
-/* eslint-disable fb-www/typeof-undefined */
+ReactComponent.prototype.setState = function (partialState, callback) {
+ !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : _prodInvariant('85') : void 0;
+ this.updater.enqueueSetState(this, partialState);
+ if (callback) {
+ this.updater.enqueueCallback(this, callback, 'setState');
+ }
+};
/**
- * Same as document.activeElement but wraps in a try-catch block. In IE it is
- * not safe to call document.activeElement if there is nothing focused.
+ * Forces an update. This should only be invoked when it is known with
+ * certainty that we are **not** in a DOM transaction.
*
- * The activeElement will be null only if the document or document body is not
- * yet defined.
+ * You may want to call this when you know that some deeper aspect of the
+ * component's state has changed but `setState` was not called.
+ *
+ * This will not invoke `shouldComponentUpdate`, but it will invoke
+ * `componentWillUpdate` and `componentDidUpdate`.
+ *
+ * @param {?function} callback Called after update is complete.
+ * @final
+ * @protected
*/
-function getActiveElement() /*?DOMElement*/{
- if (typeof document === 'undefined') {
- return null;
+ReactComponent.prototype.forceUpdate = function (callback) {
+ this.updater.enqueueForceUpdate(this);
+ if (callback) {
+ this.updater.enqueueCallback(this, callback, 'forceUpdate');
}
- try {
- return document.activeElement || document.body;
- } catch (e) {
- return document.body;
+};
+
+/**
+ * Deprecated APIs. These APIs used to exist on classic React classes but since
+ * we would like to deprecate them, we're not going to move them over to this
+ * modern base class. Instead, we define a getter that warns if it's accessed.
+ */
+if (process.env.NODE_ENV !== 'production') {
+ var deprecatedAPIs = {
+ isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
+ replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
+ };
+ var defineDeprecationWarning = function (methodName, info) {
+ if (canDefineProperty) {
+ Object.defineProperty(ReactComponent.prototype, methodName, {
+ get: function () {
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) : void 0;
+ return undefined;
+ }
+ });
+ }
+ };
+ for (var fnName in deprecatedAPIs) {
+ if (deprecatedAPIs.hasOwnProperty(fnName)) {
+ defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
+ }
}
}
-module.exports = getActiveElement;
-},{}],174:[function(require,module,exports){
-(function (process){
-'use strict';
+module.exports = ReactComponent;
+}).call(this,require('_process'))
+},{"./ReactNoopUpdateQueue":197,"./canDefineProperty":203,"./reactProdInvariant":207,"_process":43,"fbjs/lib/emptyObject":11,"fbjs/lib/invariant":18,"fbjs/lib/warning":25}],191:[function(require,module,exports){
+(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2016-present, 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.
*
+ *
*/
-/*eslint-disable fb-www/unsafe-html */
+'use strict';
-var ExecutionEnvironment = require('./ExecutionEnvironment');
+var _prodInvariant = require('./reactProdInvariant');
-var invariant = require('./invariant');
+var ReactCurrentOwner = require('./ReactCurrentOwner');
-/**
- * Dummy container used to detect which wraps are necessary.
- */
-var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
+var invariant = require('fbjs/lib/invariant');
+var warning = require('fbjs/lib/warning');
-/**
- * Some browsers cannot use `innerHTML` to render certain elements standalone,
- * so we wrap them, render the wrapped nodes, then extract the desired node.
- *
- * In IE8, certain elements cannot render alone, so wrap all elements ('*').
- */
+function isNative(fn) {
+ // Based on isNative() from Lodash
+ var funcToString = Function.prototype.toString;
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ var reIsNative = RegExp('^' + funcToString
+ // Take an example native function source for comparison
+ .call(hasOwnProperty)
+ // Strip regex characters so we can use it for regex
+ .replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
+ // Remove hasOwnProperty from the template to make it generic
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
+ try {
+ var source = funcToString.call(fn);
+ return reIsNative.test(source);
+ } catch (err) {
+ return false;
+ }
+}
-var shouldWrap = {};
+var canUseCollections =
+// Array.from
+typeof Array.from === 'function' &&
+// Map
+typeof Map === 'function' && isNative(Map) &&
+// Map.prototype.keys
+Map.prototype != null && typeof Map.prototype.keys === 'function' && isNative(Map.prototype.keys) &&
+// Set
+typeof Set === 'function' && isNative(Set) &&
+// Set.prototype.keys
+Set.prototype != null && typeof Set.prototype.keys === 'function' && isNative(Set.prototype.keys);
+
+var setItem;
+var getItem;
+var removeItem;
+var getItemIDs;
+var addRoot;
+var removeRoot;
+var getRootIDs;
+
+if (canUseCollections) {
+ var itemMap = new Map();
+ var rootIDSet = new Set();
+
+ setItem = function (id, item) {
+ itemMap.set(id, item);
+ };
+ getItem = function (id) {
+ return itemMap.get(id);
+ };
+ removeItem = function (id) {
+ itemMap['delete'](id);
+ };
+ getItemIDs = function () {
+ return Array.from(itemMap.keys());
+ };
-var selectWrap = [1, '<select multiple="true">', '</select>'];
-var tableWrap = [1, '<table>', '</table>'];
-var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
+ addRoot = function (id) {
+ rootIDSet.add(id);
+ };
+ removeRoot = function (id) {
+ rootIDSet['delete'](id);
+ };
+ getRootIDs = function () {
+ return Array.from(rootIDSet.keys());
+ };
+} else {
+ var itemByKey = {};
+ var rootByKey = {};
-var svgWrap = [1, '<svg xmlns="http://www.w3.org/2000/svg">', '</svg>'];
+ // Use non-numeric keys to prevent V8 performance issues:
+ // https://github.com/facebook/react/pull/7232
+ var getKeyFromID = function (id) {
+ return '.' + id;
+ };
+ var getIDFromKey = function (key) {
+ return parseInt(key.substr(1), 10);
+ };
-var markupWrap = {
- '*': [1, '?<div>', '</div>'],
+ setItem = function (id, item) {
+ var key = getKeyFromID(id);
+ itemByKey[key] = item;
+ };
+ getItem = function (id) {
+ var key = getKeyFromID(id);
+ return itemByKey[key];
+ };
+ removeItem = function (id) {
+ var key = getKeyFromID(id);
+ delete itemByKey[key];
+ };
+ getItemIDs = function () {
+ return Object.keys(itemByKey).map(getIDFromKey);
+ };
- 'area': [1, '<map>', '</map>'],
- 'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
- 'legend': [1, '<fieldset>', '</fieldset>'],
- 'param': [1, '<object>', '</object>'],
- 'tr': [2, '<table><tbody>', '</tbody></table>'],
+ addRoot = function (id) {
+ var key = getKeyFromID(id);
+ rootByKey[key] = true;
+ };
+ removeRoot = function (id) {
+ var key = getKeyFromID(id);
+ delete rootByKey[key];
+ };
+ getRootIDs = function () {
+ return Object.keys(rootByKey).map(getIDFromKey);
+ };
+}
- 'optgroup': selectWrap,
- 'option': selectWrap,
+var unmountedIDs = [];
- 'caption': tableWrap,
- 'colgroup': tableWrap,
- 'tbody': tableWrap,
- 'tfoot': tableWrap,
- 'thead': tableWrap,
+function purgeDeep(id) {
+ var item = getItem(id);
+ if (item) {
+ var childIDs = item.childIDs;
- 'td': trWrap,
- 'th': trWrap
-};
+ removeItem(id);
+ childIDs.forEach(purgeDeep);
+ }
+}
-// Initialize the SVG elements since we know they'll always need to be wrapped
-// consistently. If they are created inside a <div> they will be initialized in
-// the wrong namespace (and will not display).
-var svgElements = ['circle', 'clipPath', 'defs', 'ellipse', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'text', 'tspan'];
-svgElements.forEach(function (nodeName) {
- markupWrap[nodeName] = svgWrap;
- shouldWrap[nodeName] = true;
-});
+function describeComponentFrame(name, source, ownerName) {
+ return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
+}
-/**
- * Gets the markup wrap configuration for the supplied `nodeName`.
- *
- * NOTE: This lazily detects which wraps are necessary for the current browser.
- *
- * @param {string} nodeName Lowercase `nodeName`.
- * @return {?array} Markup wrap configuration, if applicable.
- */
-function getMarkupWrap(nodeName) {
- !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Markup wrapping node not initialized') : invariant(false) : void 0;
- if (!markupWrap.hasOwnProperty(nodeName)) {
- nodeName = '*';
+function getDisplayName(element) {
+ if (element == null) {
+ return '#empty';
+ } else if (typeof element === 'string' || typeof element === 'number') {
+ return '#text';
+ } else if (typeof element.type === 'string') {
+ return element.type;
+ } else {
+ return element.type.displayName || element.type.name || 'Unknown';
}
- if (!shouldWrap.hasOwnProperty(nodeName)) {
- if (nodeName === '*') {
- dummyNode.innerHTML = '<link />';
- } else {
- dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>';
- }
- shouldWrap[nodeName] = !dummyNode.firstChild;
+}
+
+function describeID(id) {
+ var name = ReactComponentTreeHook.getDisplayName(id);
+ var element = ReactComponentTreeHook.getElement(id);
+ var ownerID = ReactComponentTreeHook.getOwnerID(id);
+ var ownerName;
+ if (ownerID) {
+ ownerName = ReactComponentTreeHook.getDisplayName(ownerID);
}
- return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
+ process.env.NODE_ENV !== 'production' ? warning(element, 'ReactComponentTreeHook: Missing React element for debugID %s when ' + 'building stack', id) : void 0;
+ return describeComponentFrame(name, element && element._source, ownerName);
}
-module.exports = getMarkupWrap;
+var ReactComponentTreeHook = {
+ onSetChildren: function (id, nextChildIDs) {
+ var item = getItem(id);
+ !item ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Item must have been set') : _prodInvariant('144') : void 0;
+ item.childIDs = nextChildIDs;
+
+ for (var i = 0; i < nextChildIDs.length; i++) {
+ var nextChildID = nextChildIDs[i];
+ var nextChild = getItem(nextChildID);
+ !nextChild ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected hook events to fire for the child before its parent includes it in onSetChildren().') : _prodInvariant('140') : void 0;
+ !(nextChild.childIDs != null || typeof nextChild.element !== 'object' || nextChild.element == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onSetChildren() to fire for a container child before its parent includes it in onSetChildren().') : _prodInvariant('141') : void 0;
+ !nextChild.isMounted ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onMountComponent() to fire for the child before its parent includes it in onSetChildren().') : _prodInvariant('71') : void 0;
+ if (nextChild.parentID == null) {
+ nextChild.parentID = id;
+ // TODO: This shouldn't be necessary but mounting a new root during in
+ // componentWillMount currently causes not-yet-mounted components to
+ // be purged from our tree data so their parent id is missing.
+ }
+ !(nextChild.parentID === id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected onBeforeMountComponent() parent and onSetChildren() to be consistent (%s has parents %s and %s).', nextChildID, nextChild.parentID, id) : _prodInvariant('142', nextChildID, nextChild.parentID, id) : void 0;
+ }
+ },
+ onBeforeMountComponent: function (id, element, parentID) {
+ var item = {
+ element: element,
+ parentID: parentID,
+ text: null,
+ childIDs: [],
+ isMounted: false,
+ updateCount: 0
+ };
+ setItem(id, item);
+ },
+ onBeforeUpdateComponent: function (id, element) {
+ var item = getItem(id);
+ if (!item || !item.isMounted) {
+ // We may end up here as a result of setState() in componentWillUnmount().
+ // In this case, ignore the element.
+ return;
+ }
+ item.element = element;
+ },
+ onMountComponent: function (id) {
+ var item = getItem(id);
+ !item ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Item must have been set') : _prodInvariant('144') : void 0;
+ item.isMounted = true;
+ var isRoot = item.parentID === 0;
+ if (isRoot) {
+ addRoot(id);
+ }
+ },
+ onUpdateComponent: function (id) {
+ var item = getItem(id);
+ if (!item || !item.isMounted) {
+ // We may end up here as a result of setState() in componentWillUnmount().
+ // In this case, ignore the element.
+ return;
+ }
+ item.updateCount++;
+ },
+ onUnmountComponent: function (id) {
+ var item = getItem(id);
+ if (item) {
+ // We need to check if it exists.
+ // `item` might not exist if it is inside an error boundary, and a sibling
+ // error boundary child threw while mounting. Then this instance never
+ // got a chance to mount, but it still gets an unmounting event during
+ // the error boundary cleanup.
+ item.isMounted = false;
+ var isRoot = item.parentID === 0;
+ if (isRoot) {
+ removeRoot(id);
+ }
+ }
+ unmountedIDs.push(id);
+ },
+ purgeUnmountedComponents: function () {
+ if (ReactComponentTreeHook._preventPurging) {
+ // Should only be used for testing.
+ return;
+ }
+
+ for (var i = 0; i < unmountedIDs.length; i++) {
+ var id = unmountedIDs[i];
+ purgeDeep(id);
+ }
+ unmountedIDs.length = 0;
+ },
+ isMounted: function (id) {
+ var item = getItem(id);
+ return item ? item.isMounted : false;
+ },
+ getCurrentStackAddendum: function (topElement) {
+ var info = '';
+ if (topElement) {
+ var name = getDisplayName(topElement);
+ var owner = topElement._owner;
+ info += describeComponentFrame(name, topElement._source, owner && owner.getName());
+ }
+
+ var currentOwner = ReactCurrentOwner.current;
+ var id = currentOwner && currentOwner._debugID;
+
+ info += ReactComponentTreeHook.getStackAddendumByID(id);
+ return info;
+ },
+ getStackAddendumByID: function (id) {
+ var info = '';
+ while (id) {
+ info += describeID(id);
+ id = ReactComponentTreeHook.getParentID(id);
+ }
+ return info;
+ },
+ getChildIDs: function (id) {
+ var item = getItem(id);
+ return item ? item.childIDs : [];
+ },
+ getDisplayName: function (id) {
+ var element = ReactComponentTreeHook.getElement(id);
+ if (!element) {
+ return null;
+ }
+ return getDisplayName(element);
+ },
+ getElement: function (id) {
+ var item = getItem(id);
+ return item ? item.element : null;
+ },
+ getOwnerID: function (id) {
+ var element = ReactComponentTreeHook.getElement(id);
+ if (!element || !element._owner) {
+ return null;
+ }
+ return element._owner._debugID;
+ },
+ getParentID: function (id) {
+ var item = getItem(id);
+ return item ? item.parentID : null;
+ },
+ getSource: function (id) {
+ var item = getItem(id);
+ var element = item ? item.element : null;
+ var source = element != null ? element._source : null;
+ return source;
+ },
+ getText: function (id) {
+ var element = ReactComponentTreeHook.getElement(id);
+ if (typeof element === 'string') {
+ return element;
+ } else if (typeof element === 'number') {
+ return '' + element;
+ } else {
+ return null;
+ }
+ },
+ getUpdateCount: function (id) {
+ var item = getItem(id);
+ return item ? item.updateCount : 0;
+ },
+
+
+ getRootIDs: getRootIDs,
+ getRegisteredIDs: getItemIDs
+};
+
+module.exports = ReactComponentTreeHook;
}).call(this,require('_process'))
-},{"./ExecutionEnvironment":164,"./invariant":178,"_process":15}],175:[function(require,module,exports){
+},{"./ReactCurrentOwner":192,"./reactProdInvariant":207,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25}],192:[function(require,module,exports){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, 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
+ *
*/
'use strict';
/**
- * Gets the scroll position of the supplied element or window.
- *
- * The return values are unbounded, unlike `getScrollPosition`. This means they
- * may be negative or exceed the element boundaries (which is possible using
- * inertial scrolling).
+ * Keeps track of the current owner.
*
- * @param {DOMWindow|DOMElement} scrollable
- * @return {object} Map with `x` and `y` keys.
+ * The current owner is the component who should own any components that are
+ * currently being constructed.
*/
+var ReactCurrentOwner = {
-function getUnboundedScrollPosition(scrollable) {
- if (scrollable === window) {
- return {
- x: window.pageXOffset || document.documentElement.scrollLeft,
- y: window.pageYOffset || document.documentElement.scrollTop
- };
- }
- return {
- x: scrollable.scrollLeft,
- y: scrollable.scrollTop
- };
-}
+ /**
+ * @internal
+ * @type {ReactComponent}
+ */
+ current: null
-module.exports = getUnboundedScrollPosition;
-},{}],176:[function(require,module,exports){
-'use strict';
+};
+module.exports = ReactCurrentOwner;
+},{}],193:[function(require,module,exports){
+(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, 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
*/
-var _uppercasePattern = /([A-Z])/g;
+'use strict';
+
+var ReactElement = require('./ReactElement');
/**
- * Hyphenates a camelcased string, for example:
- *
- * > hyphenate('backgroundColor')
- * < "background-color"
- *
- * For CSS style names, use `hyphenateStyleName` instead which works properly
- * with all vendor prefixes, including `ms`.
+ * Create a factory that creates HTML tag elements.
*
- * @param {string} string
- * @return {string}
+ * @private
*/
-function hyphenate(string) {
- return string.replace(_uppercasePattern, '-$1').toLowerCase();
+var createDOMFactory = ReactElement.createFactory;
+if (process.env.NODE_ENV !== 'production') {
+ var ReactElementValidator = require('./ReactElementValidator');
+ createDOMFactory = ReactElementValidator.createFactory;
}
-module.exports = hyphenate;
-},{}],177:[function(require,module,exports){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
+ * This is also accessible via `React.DOM`.
+ *
+ * @public
+ */
+var ReactDOMFactories = {
+ a: createDOMFactory('a'),
+ abbr: createDOMFactory('abbr'),
+ address: createDOMFactory('address'),
+ area: createDOMFactory('area'),
+ article: createDOMFactory('article'),
+ aside: createDOMFactory('aside'),
+ audio: createDOMFactory('audio'),
+ b: createDOMFactory('b'),
+ base: createDOMFactory('base'),
+ bdi: createDOMFactory('bdi'),
+ bdo: createDOMFactory('bdo'),
+ big: createDOMFactory('big'),
+ blockquote: createDOMFactory('blockquote'),
+ body: createDOMFactory('body'),
+ br: createDOMFactory('br'),
+ button: createDOMFactory('button'),
+ canvas: createDOMFactory('canvas'),
+ caption: createDOMFactory('caption'),
+ cite: createDOMFactory('cite'),
+ code: createDOMFactory('code'),
+ col: createDOMFactory('col'),
+ colgroup: createDOMFactory('colgroup'),
+ data: createDOMFactory('data'),
+ datalist: createDOMFactory('datalist'),
+ dd: createDOMFactory('dd'),
+ del: createDOMFactory('del'),
+ details: createDOMFactory('details'),
+ dfn: createDOMFactory('dfn'),
+ dialog: createDOMFactory('dialog'),
+ div: createDOMFactory('div'),
+ dl: createDOMFactory('dl'),
+ dt: createDOMFactory('dt'),
+ em: createDOMFactory('em'),
+ embed: createDOMFactory('embed'),
+ fieldset: createDOMFactory('fieldset'),
+ figcaption: createDOMFactory('figcaption'),
+ figure: createDOMFactory('figure'),
+ footer: createDOMFactory('footer'),
+ form: createDOMFactory('form'),
+ h1: createDOMFactory('h1'),
+ h2: createDOMFactory('h2'),
+ h3: createDOMFactory('h3'),
+ h4: createDOMFactory('h4'),
+ h5: createDOMFactory('h5'),
+ h6: createDOMFactory('h6'),
+ head: createDOMFactory('head'),
+ header: createDOMFactory('header'),
+ hgroup: createDOMFactory('hgroup'),
+ hr: createDOMFactory('hr'),
+ html: createDOMFactory('html'),
+ i: createDOMFactory('i'),
+ iframe: createDOMFactory('iframe'),
+ img: createDOMFactory('img'),
+ input: createDOMFactory('input'),
+ ins: createDOMFactory('ins'),
+ kbd: createDOMFactory('kbd'),
+ keygen: createDOMFactory('keygen'),
+ label: createDOMFactory('label'),
+ legend: createDOMFactory('legend'),
+ li: createDOMFactory('li'),
+ link: createDOMFactory('link'),
+ main: createDOMFactory('main'),
+ map: createDOMFactory('map'),
+ mark: createDOMFactory('mark'),
+ menu: createDOMFactory('menu'),
+ menuitem: createDOMFactory('menuitem'),
+ meta: createDOMFactory('meta'),
+ meter: createDOMFactory('meter'),
+ nav: createDOMFactory('nav'),
+ noscript: createDOMFactory('noscript'),
+ object: createDOMFactory('object'),
+ ol: createDOMFactory('ol'),
+ optgroup: createDOMFactory('optgroup'),
+ option: createDOMFactory('option'),
+ output: createDOMFactory('output'),
+ p: createDOMFactory('p'),
+ param: createDOMFactory('param'),
+ picture: createDOMFactory('picture'),
+ pre: createDOMFactory('pre'),
+ progress: createDOMFactory('progress'),
+ q: createDOMFactory('q'),
+ rp: createDOMFactory('rp'),
+ rt: createDOMFactory('rt'),
+ ruby: createDOMFactory('ruby'),
+ s: createDOMFactory('s'),
+ samp: createDOMFactory('samp'),
+ script: createDOMFactory('script'),
+ section: createDOMFactory('section'),
+ select: createDOMFactory('select'),
+ small: createDOMFactory('small'),
+ source: createDOMFactory('source'),
+ span: createDOMFactory('span'),
+ strong: createDOMFactory('strong'),
+ style: createDOMFactory('style'),
+ sub: createDOMFactory('sub'),
+ summary: createDOMFactory('summary'),
+ sup: createDOMFactory('sup'),
+ table: createDOMFactory('table'),
+ tbody: createDOMFactory('tbody'),
+ td: createDOMFactory('td'),
+ textarea: createDOMFactory('textarea'),
+ tfoot: createDOMFactory('tfoot'),
+ th: createDOMFactory('th'),
+ thead: createDOMFactory('thead'),
+ time: createDOMFactory('time'),
+ title: createDOMFactory('title'),
+ tr: createDOMFactory('tr'),
+ track: createDOMFactory('track'),
+ u: createDOMFactory('u'),
+ ul: createDOMFactory('ul'),
+ 'var': createDOMFactory('var'),
+ video: createDOMFactory('video'),
+ wbr: createDOMFactory('wbr'),
+
+ // SVG
+ circle: createDOMFactory('circle'),
+ clipPath: createDOMFactory('clipPath'),
+ defs: createDOMFactory('defs'),
+ ellipse: createDOMFactory('ellipse'),
+ g: createDOMFactory('g'),
+ image: createDOMFactory('image'),
+ line: createDOMFactory('line'),
+ linearGradient: createDOMFactory('linearGradient'),
+ mask: createDOMFactory('mask'),
+ path: createDOMFactory('path'),
+ pattern: createDOMFactory('pattern'),
+ polygon: createDOMFactory('polygon'),
+ polyline: createDOMFactory('polyline'),
+ radialGradient: createDOMFactory('radialGradient'),
+ rect: createDOMFactory('rect'),
+ stop: createDOMFactory('stop'),
+ svg: createDOMFactory('svg'),
+ text: createDOMFactory('text'),
+ tspan: createDOMFactory('tspan')
+};
+
+module.exports = ReactDOMFactories;
+}).call(this,require('_process'))
+
+},{"./ReactElement":194,"./ReactElementValidator":196,"_process":43}],194:[function(require,module,exports){
+(function (process){
+/**
+ * Copyright 2014-present, 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
*/
'use strict';
-var hyphenate = require('./hyphenate');
+var _assign = require('object-assign');
-var msPattern = /^ms-/;
+var ReactCurrentOwner = require('./ReactCurrentOwner');
+
+var warning = require('fbjs/lib/warning');
+var canDefineProperty = require('./canDefineProperty');
+var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+var REACT_ELEMENT_TYPE = require('./ReactElementSymbol');
+
+var RESERVED_PROPS = {
+ key: true,
+ ref: true,
+ __self: true,
+ __source: true
+};
+
+var specialPropKeyWarningShown, specialPropRefWarningShown;
+
+function hasValidRef(config) {
+ if (process.env.NODE_ENV !== 'production') {
+ if (hasOwnProperty.call(config, 'ref')) {
+ var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
+ if (getter && getter.isReactWarning) {
+ return false;
+ }
+ }
+ }
+ return config.ref !== undefined;
+}
+
+function hasValidKey(config) {
+ if (process.env.NODE_ENV !== 'production') {
+ if (hasOwnProperty.call(config, 'key')) {
+ var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
+ if (getter && getter.isReactWarning) {
+ return false;
+ }
+ }
+ }
+ return config.key !== undefined;
+}
+
+function defineKeyPropWarningGetter(props, displayName) {
+ var warnAboutAccessingKey = function () {
+ if (!specialPropKeyWarningShown) {
+ specialPropKeyWarningShown = true;
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName) : void 0;
+ }
+ };
+ warnAboutAccessingKey.isReactWarning = true;
+ Object.defineProperty(props, 'key', {
+ get: warnAboutAccessingKey,
+ configurable: true
+ });
+}
+
+function defineRefPropWarningGetter(props, displayName) {
+ var warnAboutAccessingRef = function () {
+ if (!specialPropRefWarningShown) {
+ specialPropRefWarningShown = true;
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName) : void 0;
+ }
+ };
+ warnAboutAccessingRef.isReactWarning = true;
+ Object.defineProperty(props, 'ref', {
+ get: warnAboutAccessingRef,
+ configurable: true
+ });
+}
/**
- * Hyphenates a camelcased CSS property name, for example:
- *
- * > hyphenateStyleName('backgroundColor')
- * < "background-color"
- * > hyphenateStyleName('MozTransition')
- * < "-moz-transition"
- * > hyphenateStyleName('msTransition')
- * < "-ms-transition"
- *
- * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
- * is converted to `-ms-`.
+ * Factory method to create a new React element. This no longer adheres to
+ * the class pattern, so do not use new to call it. Also, no instanceof check
+ * will work. Instead test $$typeof field against Symbol.for('react.element') to check
+ * if something is a React Element.
*
- * @param {string} string
- * @return {string}
+ * @param {*} type
+ * @param {*} key
+ * @param {string|object} ref
+ * @param {*} self A *temporary* helper to detect places where `this` is
+ * different from the `owner` when React.createElement is called, so that we
+ * can warn. We want to get rid of owner and replace string `ref`s with arrow
+ * functions, and as long as `this` and owner are the same, there will be no
+ * change in behavior.
+ * @param {*} source An annotation object (added by a transpiler or otherwise)
+ * indicating filename, line number, and/or other information.
+ * @param {*} owner
+ * @param {*} props
+ * @internal
*/
-function hyphenateStyleName(string) {
- return hyphenate(string).replace(msPattern, '-ms-');
-}
+var ReactElement = function (type, key, ref, self, source, owner, props) {
+ var element = {
+ // This tag allow us to uniquely identify this as a React Element
+ $$typeof: REACT_ELEMENT_TYPE,
-module.exports = hyphenateStyleName;
-},{"./hyphenate":176}],178:[function(require,module,exports){
+ // Built-in properties that belong on the element
+ type: type,
+ key: key,
+ ref: ref,
+ props: props,
+
+ // Record the component responsible for creating this element.
+ _owner: owner
+ };
+
+ if (process.env.NODE_ENV !== 'production') {
+ // The validation flag is currently mutative. We put it 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.
+ element._store = {};
+
+ // To make comparing ReactElements easier for testing purposes, we make
+ // the validation flag non-enumerable (where possible, which should
+ // include every environment we run tests in), so the test framework
+ // ignores it.
+ if (canDefineProperty) {
+ Object.defineProperty(element._store, 'validated', {
+ configurable: false,
+ enumerable: false,
+ writable: true,
+ value: false
+ });
+ // self and source are DEV only properties.
+ Object.defineProperty(element, '_self', {
+ configurable: false,
+ enumerable: false,
+ writable: false,
+ value: self
+ });
+ // Two elements created in two different places should be considered
+ // equal for testing purposes and therefore we hide it from enumeration.
+ Object.defineProperty(element, '_source', {
+ configurable: false,
+ enumerable: false,
+ writable: false,
+ value: source
+ });
+ } else {
+ element._store.validated = false;
+ element._self = self;
+ element._source = source;
+ }
+ if (Object.freeze) {
+ Object.freeze(element.props);
+ Object.freeze(element);
+ }
+ }
+
+ return element;
+};
+
+/**
+ * Create and return a new ReactElement of the given type.
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.createelement
+ */
+ReactElement.createElement = function (type, config, children) {
+ var propName;
+
+ // Reserved names are extracted
+ var props = {};
+
+ var key = null;
+ var ref = null;
+ var self = null;
+ var source = null;
+
+ if (config != null) {
+ if (hasValidRef(config)) {
+ ref = config.ref;
+ }
+ if (hasValidKey(config)) {
+ key = '' + config.key;
+ }
+
+ self = config.__self === undefined ? null : config.__self;
+ source = config.__source === undefined ? null : config.__source;
+ // Remaining properties are added to a new props object
+ for (propName in config) {
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
+ props[propName] = config[propName];
+ }
+ }
+ }
+
+ // 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];
+ }
+ if (process.env.NODE_ENV !== 'production') {
+ if (Object.freeze) {
+ Object.freeze(childArray);
+ }
+ }
+ props.children = childArray;
+ }
+
+ // Resolve default props
+ if (type && type.defaultProps) {
+ var defaultProps = type.defaultProps;
+ for (propName in defaultProps) {
+ if (props[propName] === undefined) {
+ props[propName] = defaultProps[propName];
+ }
+ }
+ }
+ if (process.env.NODE_ENV !== 'production') {
+ if (key || ref) {
+ if (typeof props.$$typeof === 'undefined' || props.$$typeof !== REACT_ELEMENT_TYPE) {
+ var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
+ if (key) {
+ defineKeyPropWarningGetter(props, displayName);
+ }
+ if (ref) {
+ defineRefPropWarningGetter(props, displayName);
+ }
+ }
+ }
+ }
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
+};
+
+/**
+ * Return a function that produces ReactElements of a given type.
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.createfactory
+ */
+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 elements. E.g. `<Foo />.type === Foo`.
+ // 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.
+ // Legacy hook TODO: Warn if this is accessed
+ factory.type = type;
+ return factory;
+};
+
+ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
+ var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
+
+ return newElement;
+};
+
+/**
+ * Clone and return a new ReactElement using element as the starting point.
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement
+ */
+ReactElement.cloneElement = function (element, config, children) {
+ var propName;
+
+ // Original props are copied
+ var props = _assign({}, element.props);
+
+ // Reserved names are extracted
+ var key = element.key;
+ var ref = element.ref;
+ // Self is preserved since the owner is preserved.
+ var self = element._self;
+ // Source is preserved since cloneElement is unlikely to be targeted by a
+ // transpiler, and the original source is probably a better indicator of the
+ // true owner.
+ var source = element._source;
+
+ // Owner will be preserved, unless ref is overridden
+ var owner = element._owner;
+
+ if (config != null) {
+ if (hasValidRef(config)) {
+ // Silently steal the ref from the parent.
+ ref = config.ref;
+ owner = ReactCurrentOwner.current;
+ }
+ if (hasValidKey(config)) {
+ key = '' + config.key;
+ }
+
+ // Remaining properties override existing props
+ var defaultProps;
+ if (element.type && element.type.defaultProps) {
+ defaultProps = element.type.defaultProps;
+ }
+ for (propName in config) {
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
+ if (config[propName] === undefined && defaultProps !== undefined) {
+ // Resolve default props
+ props[propName] = defaultProps[propName];
+ } else {
+ props[propName] = config[propName];
+ }
+ }
+ }
+ }
+
+ // 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;
+ }
+
+ return ReactElement(element.type, key, ref, self, source, owner, props);
+};
+
+/**
+ * Verifies the object is a ReactElement.
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.isvalidelement
+ * @param {?object} object
+ * @return {boolean} True if `object` is a valid component.
+ * @final
+ */
+ReactElement.isValidElement = function (object) {
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
+};
+
+module.exports = ReactElement;
+}).call(this,require('_process'))
+
+},{"./ReactCurrentOwner":192,"./ReactElementSymbol":195,"./canDefineProperty":203,"_process":43,"fbjs/lib/warning":25,"object-assign":209}],195:[function(require,module,exports){
+arguments[4][94][0].apply(exports,arguments)
+},{"dup":94}],196:[function(require,module,exports){
(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
@@ -31024,184 +31702,800 @@ module.exports = hyphenateStyleName;
*
*/
+/**
+ * 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 ReactCurrentOwner = require('./ReactCurrentOwner');
+var ReactComponentTreeHook = require('./ReactComponentTreeHook');
+var ReactElement = require('./ReactElement');
+
+var checkReactTypeSpec = require('./checkReactTypeSpec');
+
+var canDefineProperty = require('./canDefineProperty');
+var getIteratorFn = require('./getIteratorFn');
+var warning = require('fbjs/lib/warning');
+
+function getDeclarationErrorAddendum() {
+ if (ReactCurrentOwner.current) {
+ var name = ReactCurrentOwner.current.getName();
+ if (name) {
+ return ' Check the render method of `' + name + '`.';
+ }
+ }
+ return '';
+}
+
/**
- * Use invariant() to assert state which your program assumes to be true.
- *
- * Provide sprintf-style format (only %s is supported) and arguments
- * to provide information about what broke and what you were
- * expecting.
- *
- * The invariant message will be stripped in production, but the invariant
- * will remain to ensure logic does not differ in production.
+ * Warn if there's no key explicitly set on dynamic arrays of children or
+ * object keys are not valid. This allows us to keep track of children between
+ * updates.
*/
+var ownerHasKeyUseWarning = {};
-function invariant(condition, format, a, b, c, d, e, f) {
- if (process.env.NODE_ENV !== 'production') {
- if (format === undefined) {
- throw new Error('invariant requires an error message argument');
+function getCurrentComponentErrorInfo(parentType) {
+ var info = getDeclarationErrorAddendum();
+
+ if (!info) {
+ var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
+ if (parentName) {
+ info = ' Check the top-level render call using <' + parentName + '>.';
}
}
+ return info;
+}
- if (!condition) {
- var error;
- if (format === undefined) {
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
- } else {
- var args = [a, b, c, d, e, f];
- var argIndex = 0;
- error = new Error(format.replace(/%s/g, function () {
- return args[argIndex++];
- }));
- error.name = 'Invariant Violation';
+/**
+ * Warn if the element doesn't have an explicit key assigned to it.
+ * This element is in an array. The array could grow and shrink or be
+ * reordered. All children that haven't already been validated are required to
+ * have a "key" property assigned to it. Error statuses are cached so a warning
+ * will only be shown once.
+ *
+ * @internal
+ * @param {ReactElement} element Element that requires a key.
+ * @param {*} parentType element's parent's type.
+ */
+function validateExplicitKey(element, parentType) {
+ if (!element._store || element._store.validated || element.key != null) {
+ return;
+ }
+ element._store.validated = true;
+
+ var memoizer = ownerHasKeyUseWarning.uniqueKey || (ownerHasKeyUseWarning.uniqueKey = {});
+
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
+ if (memoizer[currentComponentErrorInfo]) {
+ return;
+ }
+ memoizer[currentComponentErrorInfo] = true;
+
+ // Usually the current owner is the offender, but if it accepts children as a
+ // property, it may be the creator of the child that's responsible for
+ // assigning it a key.
+ var childOwner = '';
+ if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
+ // Give the component that originally created this child.
+ childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
+ }
+
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.%s', currentComponentErrorInfo, childOwner, ReactComponentTreeHook.getCurrentStackAddendum(element)) : void 0;
+}
+
+/**
+ * Ensure that every element either is passed in a static location, in an
+ * array with an explicit keys property defined, or in an object literal
+ * with valid key property.
+ *
+ * @internal
+ * @param {ReactNode} node Statically passed child of any type.
+ * @param {*} parentType node's parent's type.
+ */
+function validateChildKeys(node, parentType) {
+ if (typeof node !== 'object') {
+ return;
+ }
+ if (Array.isArray(node)) {
+ for (var i = 0; i < node.length; i++) {
+ var child = node[i];
+ if (ReactElement.isValidElement(child)) {
+ validateExplicitKey(child, parentType);
+ }
+ }
+ } else if (ReactElement.isValidElement(node)) {
+ // This element was passed in a valid location.
+ if (node._store) {
+ node._store.validated = true;
}
+ } else if (node) {
+ var iteratorFn = getIteratorFn(node);
+ // Entry iterators provide implicit keys.
+ if (iteratorFn) {
+ if (iteratorFn !== node.entries) {
+ var iterator = iteratorFn.call(node);
+ var step;
+ while (!(step = iterator.next()).done) {
+ if (ReactElement.isValidElement(step.value)) {
+ validateExplicitKey(step.value, parentType);
+ }
+ }
+ }
+ }
+ }
+}
- error.framesToPop = 1; // we don't care about invariant's own frame
- throw error;
+/**
+ * Given an element, validate that its props follow the propTypes definition,
+ * provided by the type.
+ *
+ * @param {ReactElement} element
+ */
+function validatePropTypes(element) {
+ var componentClass = element.type;
+ if (typeof componentClass !== 'function') {
+ return;
+ }
+ var name = componentClass.displayName || componentClass.name;
+ if (componentClass.propTypes) {
+ checkReactTypeSpec(componentClass.propTypes, element.props, 'prop', name, element, null);
+ }
+ if (typeof componentClass.getDefaultProps === 'function') {
+ process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
}
}
-module.exports = invariant;
-}).call(this,require('_process'))
+var ReactElementValidator = {
-},{"_process":15}],179:[function(require,module,exports){
-'use strict';
+ createElement: function (type, props, children) {
+ var validType = typeof type === 'string' || typeof type === 'function';
+ // We warn in this case but don't throw. We expect the element creation to
+ // succeed and there will likely be errors in render.
+ if (!validType) {
+ if (typeof type !== 'function' && typeof type !== 'string') {
+ var info = '';
+ if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
+ info += ' You likely forgot to export your component from the file ' + 'it\'s defined in.';
+ }
+ info += getDeclarationErrorAddendum();
+ process.env.NODE_ENV !== 'production' ? warning(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', type == null ? type : typeof type, info) : void 0;
+ }
+ }
+
+ var element = ReactElement.createElement.apply(this, arguments);
+
+ // 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;
+ }
+
+ // Skip key warning if the type isn't valid since our key validation logic
+ // doesn't expect a non-string/function type and can throw confusing errors.
+ // We don't want exception behavior to differ between dev and prod.
+ // (Rendering will throw with a helpful message and as soon as the type is
+ // fixed, the key warnings will appear.)
+ if (validType) {
+ for (var i = 2; i < arguments.length; i++) {
+ validateChildKeys(arguments[i], type);
+ }
+ }
+
+ validatePropTypes(element);
+
+ return element;
+ },
+
+ createFactory: function (type) {
+ var validatedFactory = ReactElementValidator.createElement.bind(null, type);
+ // Legacy hook TODO: Warn if this is accessed
+ validatedFactory.type = type;
+
+ if (process.env.NODE_ENV !== 'production') {
+ if (canDefineProperty) {
+ Object.defineProperty(validatedFactory, 'type', {
+ enumerable: false,
+ get: function () {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : void 0;
+ Object.defineProperty(this, 'type', {
+ value: type
+ });
+ return type;
+ }
+ });
+ }
+ }
+
+ return validatedFactory;
+ },
+
+ cloneElement: function (element, props, children) {
+ var newElement = ReactElement.cloneElement.apply(this, arguments);
+ for (var i = 2; i < arguments.length; i++) {
+ validateChildKeys(arguments[i], newElement.type);
+ }
+ validatePropTypes(newElement);
+ return newElement;
+ }
+
+};
+module.exports = ReactElementValidator;
+}).call(this,require('_process'))
+
+},{"./ReactComponentTreeHook":191,"./ReactCurrentOwner":192,"./ReactElement":194,"./canDefineProperty":203,"./checkReactTypeSpec":204,"./getIteratorFn":205,"_process":43,"fbjs/lib/warning":25}],197:[function(require,module,exports){
+(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2015-present, 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
*/
+'use strict';
+
+var warning = require('fbjs/lib/warning');
+
+function warnNoop(publicInstance, callerName) {
+ if (process.env.NODE_ENV !== 'production') {
+ var constructor = publicInstance.constructor;
+ process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, constructor && (constructor.displayName || constructor.name) || 'ReactClass') : void 0;
+ }
+}
+
/**
- * @param {*} object The object to check.
- * @return {boolean} Whether or not the object is a DOM node.
+ * This is the abstract API for an update queue.
*/
-function isNode(object) {
- return !!(object && (typeof Node === 'function' ? object instanceof Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'));
-}
+var ReactNoopUpdateQueue = {
-module.exports = isNode;
-},{}],180:[function(require,module,exports){
-'use strict';
+ /**
+ * Checks whether or not this composite component is mounted.
+ * @param {ReactClass} publicInstance The instance we want to test.
+ * @return {boolean} True if mounted, false otherwise.
+ * @protected
+ * @final
+ */
+ isMounted: function (publicInstance) {
+ return false;
+ },
+ /**
+ * Enqueue a callback that will be executed after all the pending updates
+ * have processed.
+ *
+ * @param {ReactClass} publicInstance The instance to use as `this` context.
+ * @param {?function} callback Called after state is updated.
+ * @internal
+ */
+ enqueueCallback: function (publicInstance, callback) {},
+
+ /**
+ * Forces an update. This should only be invoked when it is known with
+ * certainty that we are **not** in a DOM transaction.
+ *
+ * You may want to call this when you know that some deeper aspect of the
+ * component's state has changed but `setState` was not called.
+ *
+ * This will not invoke `shouldComponentUpdate`, but it will invoke
+ * `componentWillUpdate` and `componentDidUpdate`.
+ *
+ * @param {ReactClass} publicInstance The instance that should rerender.
+ * @internal
+ */
+ enqueueForceUpdate: function (publicInstance) {
+ warnNoop(publicInstance, 'forceUpdate');
+ },
+
+ /**
+ * Replaces all of the state. Always use this or `setState` to mutate state.
+ * You should treat `this.state` as immutable.
+ *
+ * There is no guarantee that `this.state` will be immediately updated, so
+ * accessing `this.state` after calling this method may return the old value.
+ *
+ * @param {ReactClass} publicInstance The instance that should rerender.
+ * @param {object} completeState Next state.
+ * @internal
+ */
+ enqueueReplaceState: function (publicInstance, completeState) {
+ warnNoop(publicInstance, 'replaceState');
+ },
+
+ /**
+ * Sets a subset of the state. This only exists because _pendingState is
+ * internal. This provides a merging strategy that is not available to deep
+ * properties which is confusing. TODO: Expose pendingState or don't use it
+ * during the merge.
+ *
+ * @param {ReactClass} publicInstance The instance that should rerender.
+ * @param {object} partialState Next partial state to be merged with state.
+ * @internal
+ */
+ enqueueSetState: function (publicInstance, partialState) {
+ warnNoop(publicInstance, 'setState');
+ }
+};
+
+module.exports = ReactNoopUpdateQueue;
+}).call(this,require('_process'))
+
+},{"_process":43,"fbjs/lib/warning":25}],198:[function(require,module,exports){
+(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, 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
+ *
*/
-var isNode = require('./isNode');
+'use strict';
-/**
- * @param {*} object The object to check.
- * @return {boolean} Whether or not the object is a DOM text node.
- */
-function isTextNode(object) {
- return isNode(object) && object.nodeType == 3;
+var ReactPropTypeLocationNames = {};
+
+if (process.env.NODE_ENV !== 'production') {
+ ReactPropTypeLocationNames = {
+ prop: 'prop',
+ context: 'context',
+ childContext: 'child context'
+ };
}
-module.exports = isTextNode;
-},{"./isNode":179}],181:[function(require,module,exports){
+module.exports = ReactPropTypeLocationNames;
+}).call(this,require('_process'))
+
+},{"_process":43}],199:[function(require,module,exports){
(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, 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 static-only
*/
'use strict';
-var invariant = require('./invariant');
+var ReactElement = require('./ReactElement');
+var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
+var ReactPropTypesSecret = require('./ReactPropTypesSecret');
+
+var emptyFunction = require('fbjs/lib/emptyFunction');
+var getIteratorFn = require('./getIteratorFn');
+var warning = require('fbjs/lib/warning');
/**
- * Constructs an enumeration with keys equal to their value.
+ * Collection of methods that allow declaration and validation of props that are
+ * supplied to React components. Example usage:
*
- * For example:
+ * var Props = require('ReactPropTypes');
+ * var MyArticle = React.createClass({
+ * propTypes: {
+ * // An optional string prop named "description".
+ * description: Props.string,
*
- * var COLORS = keyMirror({blue: null, red: null});
- * var myColor = COLORS.blue;
- * var isColorValid = !!COLORS[myColor];
+ * // A required enum prop named "category".
+ * category: Props.oneOf(['News','Photos']).isRequired,
*
- * The last line could not be performed if the values of the generated enum were
- * not equal to their keys.
+ * // A prop named "dialog" that requires an instance of Dialog.
+ * dialog: Props.instanceOf(Dialog).isRequired
+ * },
+ * render: function() { ... }
+ * });
*
- * Input: {key1: val1, key2: val2}
- * Output: {key1: key1, key2: key2}
+ * A more formal specification of how these methods are used:
*
- * @param {object} obj
- * @return {object}
+ * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
+ * decl := ReactPropTypes.{type}(.isRequired)?
+ *
+ * Each and every declaration produces a function with the same signature. This
+ * allows the creation of custom validation functions. For example:
+ *
+ * var MyLink = React.createClass({
+ * propTypes: {
+ * // An optional string or URI prop named "href".
+ * href: function(props, propName, componentName) {
+ * var propValue = props[propName];
+ * if (propValue != null && typeof propValue !== 'string' &&
+ * !(propValue instanceof URI)) {
+ * return new Error(
+ * 'Expected a string or an URI for ' + propName + ' in ' +
+ * componentName
+ * );
+ * }
+ * }
+ * },
+ * render: function() {...}
+ * });
+ *
+ * @internal
*/
-var keyMirror = function keyMirror(obj) {
- var ret = {};
- var key;
- !(obj instanceof Object && !Array.isArray(obj)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'keyMirror(...): Argument must be an object.') : invariant(false) : void 0;
- for (key in obj) {
- if (!obj.hasOwnProperty(key)) {
- continue;
- }
- ret[key] = key;
- }
- return ret;
-};
-module.exports = keyMirror;
-}).call(this,require('_process'))
+var ANONYMOUS = '<<anonymous>>';
-},{"./invariant":178,"_process":15}],182:[function(require,module,exports){
-"use strict";
+var ReactPropTypes = {
+ array: createPrimitiveTypeChecker('array'),
+ bool: createPrimitiveTypeChecker('boolean'),
+ func: createPrimitiveTypeChecker('function'),
+ number: createPrimitiveTypeChecker('number'),
+ object: createPrimitiveTypeChecker('object'),
+ string: createPrimitiveTypeChecker('string'),
+ symbol: createPrimitiveTypeChecker('symbol'),
+
+ any: createAnyTypeChecker(),
+ arrayOf: createArrayOfTypeChecker,
+ element: createElementTypeChecker(),
+ instanceOf: createInstanceTypeChecker,
+ node: createNodeChecker(),
+ objectOf: createObjectOfTypeChecker,
+ oneOf: createEnumTypeChecker,
+ oneOfType: createUnionTypeChecker,
+ shape: createShapeTypeChecker
+};
/**
- * Copyright (c) 2013-present, 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.
- *
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
+/*eslint-disable no-self-compare*/
+function is(x, y) {
+ // SameValue algorithm
+ if (x === y) {
+ // Steps 1-5, 7-10
+ // Steps 6.b-6.e: +0 != -0
+ return x !== 0 || 1 / x === 1 / y;
+ } else {
+ // Step 6.a: NaN == NaN
+ return x !== x && y !== y;
+ }
+}
+/*eslint-enable no-self-compare*/
/**
- * Allows extraction of a minified key. Let's the build system minify keys
- * without losing the ability to dynamically use key strings as values
- * themselves. Pass in an object with a single key/val pair and it will return
- * you the string key of that single record. Suppose you want to grab the
- * value for a key 'className' inside of an object. Key/val minification may
- * have aliased that key to be 'xa12'. keyOf({className: null}) will return
- * 'xa12' in that case. Resolve keys you want to use once at startup time, then
- * reuse those resolutions.
+ * We use an Error-like object for backward compatibility as people may call
+ * PropTypes directly and inspect their output. However we don't use real
+ * Errors anymore. We don't inspect their stack anyway, and creating them
+ * is prohibitively expensive if they are created too often, such as what
+ * happens in oneOfType() for any type before the one that matched.
*/
-var keyOf = function keyOf(oneKeyObj) {
- var key;
- for (key in oneKeyObj) {
- if (!oneKeyObj.hasOwnProperty(key)) {
- continue;
+function PropTypeError(message) {
+ this.message = message;
+ this.stack = '';
+}
+// Make `instanceof Error` still work for returned errors.
+PropTypeError.prototype = Error.prototype;
+
+function createChainableTypeChecker(validate) {
+ if (process.env.NODE_ENV !== 'production') {
+ var manualPropTypeCallCache = {};
+ }
+ function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
+ componentName = componentName || ANONYMOUS;
+ propFullName = propFullName || propName;
+ if (process.env.NODE_ENV !== 'production') {
+ if (secret !== ReactPropTypesSecret && typeof console !== 'undefined') {
+ var cacheKey = componentName + ':' + propName;
+ if (!manualPropTypeCallCache[cacheKey]) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will not work in production with the next major version. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName) : void 0;
+ manualPropTypeCallCache[cacheKey] = true;
+ }
+ }
+ }
+ if (props[propName] == null) {
+ var locationName = ReactPropTypeLocationNames[location];
+ if (isRequired) {
+ if (props[propName] === null) {
+ return new PropTypeError('The ' + locationName + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
+ }
+ return new PropTypeError('The ' + locationName + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
+ }
+ return null;
+ } else {
+ return validate(props, propName, componentName, location, propFullName);
}
- return key;
}
- return null;
-};
-module.exports = keyOf;
-},{}],183:[function(require,module,exports){
+ var chainedCheckType = checkType.bind(null, false);
+ chainedCheckType.isRequired = checkType.bind(null, true);
+
+ return chainedCheckType;
+}
+
+function createPrimitiveTypeChecker(expectedType) {
+ function validate(props, propName, componentName, location, propFullName, secret) {
+ var propValue = props[propName];
+ var propType = getPropType(propValue);
+ if (propType !== expectedType) {
+ var locationName = ReactPropTypeLocationNames[location];
+ // `propValue` being instance of, say, date/regexp, pass the 'object'
+ // check, but we can offer a more precise error message here rather than
+ // 'of type `object`'.
+ var preciseType = getPreciseType(propValue);
+
+ return new PropTypeError('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
+ }
+ return null;
+ }
+ return createChainableTypeChecker(validate);
+}
+
+function createAnyTypeChecker() {
+ return createChainableTypeChecker(emptyFunction.thatReturns(null));
+}
+
+function createArrayOfTypeChecker(typeChecker) {
+ function validate(props, propName, componentName, location, propFullName) {
+ if (typeof typeChecker !== 'function') {
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
+ }
+ var propValue = props[propName];
+ if (!Array.isArray(propValue)) {
+ var locationName = ReactPropTypeLocationNames[location];
+ var propType = getPropType(propValue);
+ return new PropTypeError('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
+ }
+ for (var i = 0; i < propValue.length; i++) {
+ var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
+ if (error instanceof Error) {
+ return error;
+ }
+ }
+ return null;
+ }
+ return createChainableTypeChecker(validate);
+}
+
+function createElementTypeChecker() {
+ function validate(props, propName, componentName, location, propFullName) {
+ var propValue = props[propName];
+ if (!ReactElement.isValidElement(propValue)) {
+ var locationName = ReactPropTypeLocationNames[location];
+ var propType = getPropType(propValue);
+ return new PropTypeError('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
+ }
+ return null;
+ }
+ return createChainableTypeChecker(validate);
+}
+
+function createInstanceTypeChecker(expectedClass) {
+ function validate(props, propName, componentName, location, propFullName) {
+ if (!(props[propName] instanceof expectedClass)) {
+ var locationName = ReactPropTypeLocationNames[location];
+ var expectedClassName = expectedClass.name || ANONYMOUS;
+ var actualClassName = getClassName(props[propName]);
+ return new PropTypeError('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
+ }
+ return null;
+ }
+ return createChainableTypeChecker(validate);
+}
+
+function createEnumTypeChecker(expectedValues) {
+ if (!Array.isArray(expectedValues)) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
+ return emptyFunction.thatReturnsNull;
+ }
+
+ function validate(props, propName, componentName, location, propFullName) {
+ var propValue = props[propName];
+ for (var i = 0; i < expectedValues.length; i++) {
+ if (is(propValue, expectedValues[i])) {
+ return null;
+ }
+ }
+
+ var locationName = ReactPropTypeLocationNames[location];
+ var valuesString = JSON.stringify(expectedValues);
+ return new PropTypeError('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
+ }
+ return createChainableTypeChecker(validate);
+}
+
+function createObjectOfTypeChecker(typeChecker) {
+ function validate(props, propName, componentName, location, propFullName) {
+ if (typeof typeChecker !== 'function') {
+ return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
+ }
+ var propValue = props[propName];
+ var propType = getPropType(propValue);
+ if (propType !== 'object') {
+ var locationName = ReactPropTypeLocationNames[location];
+ return new PropTypeError('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
+ }
+ for (var key in propValue) {
+ if (propValue.hasOwnProperty(key)) {
+ var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
+ if (error instanceof Error) {
+ return error;
+ }
+ }
+ }
+ return null;
+ }
+ return createChainableTypeChecker(validate);
+}
+
+function createUnionTypeChecker(arrayOfTypeCheckers) {
+ if (!Array.isArray(arrayOfTypeCheckers)) {
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
+ return emptyFunction.thatReturnsNull;
+ }
+
+ function validate(props, propName, componentName, location, propFullName) {
+ for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
+ var checker = arrayOfTypeCheckers[i];
+ if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
+ return null;
+ }
+ }
+
+ var locationName = ReactPropTypeLocationNames[location];
+ return new PropTypeError('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
+ }
+ return createChainableTypeChecker(validate);
+}
+
+function createNodeChecker() {
+ function validate(props, propName, componentName, location, propFullName) {
+ if (!isNode(props[propName])) {
+ var locationName = ReactPropTypeLocationNames[location];
+ return new PropTypeError('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
+ }
+ return null;
+ }
+ return createChainableTypeChecker(validate);
+}
+
+function createShapeTypeChecker(shapeTypes) {
+ function validate(props, propName, componentName, location, propFullName) {
+ var propValue = props[propName];
+ var propType = getPropType(propValue);
+ if (propType !== 'object') {
+ var locationName = ReactPropTypeLocationNames[location];
+ return new PropTypeError('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
+ }
+ for (var key in shapeTypes) {
+ var checker = shapeTypes[key];
+ if (!checker) {
+ continue;
+ }
+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
+ if (error) {
+ return error;
+ }
+ }
+ return null;
+ }
+ return createChainableTypeChecker(validate);
+}
+
+function isNode(propValue) {
+ switch (typeof propValue) {
+ case 'number':
+ case 'string':
+ case 'undefined':
+ return true;
+ case 'boolean':
+ return !propValue;
+ case 'object':
+ if (Array.isArray(propValue)) {
+ return propValue.every(isNode);
+ }
+ if (propValue === null || ReactElement.isValidElement(propValue)) {
+ return true;
+ }
+
+ var iteratorFn = getIteratorFn(propValue);
+ if (iteratorFn) {
+ var iterator = iteratorFn.call(propValue);
+ var step;
+ if (iteratorFn !== propValue.entries) {
+ while (!(step = iterator.next()).done) {
+ if (!isNode(step.value)) {
+ return false;
+ }
+ }
+ } else {
+ // Iterator will provide entry [k,v] tuples rather than values.
+ while (!(step = iterator.next()).done) {
+ var entry = step.value;
+ if (entry) {
+ if (!isNode(entry[1])) {
+ return false;
+ }
+ }
+ }
+ }
+ } else {
+ return false;
+ }
+
+ return true;
+ default:
+ return false;
+ }
+}
+
+function isSymbol(propType, propValue) {
+ // Native Symbol.
+ if (propType === 'symbol') {
+ return true;
+ }
+
+ // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
+ if (propValue['@@toStringTag'] === 'Symbol') {
+ return true;
+ }
+
+ // Fallback for non-spec compliant Symbols which are polyfilled.
+ if (typeof Symbol === 'function' && propValue instanceof Symbol) {
+ return true;
+ }
+
+ return false;
+}
+
+// Equivalent of `typeof` but with special handling for array and regexp.
+function getPropType(propValue) {
+ var propType = typeof propValue;
+ if (Array.isArray(propValue)) {
+ return 'array';
+ }
+ if (propValue instanceof RegExp) {
+ // Old webkits (at least until Android 4.0) return 'function' rather than
+ // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
+ // passes PropTypes.object.
+ return 'object';
+ }
+ if (isSymbol(propType, propValue)) {
+ return 'symbol';
+ }
+ return propType;
+}
+
+// This handles more types than `getPropType`. Only used for error messages.
+// See `createPrimitiveTypeChecker`.
+function getPreciseType(propValue) {
+ var propType = getPropType(propValue);
+ if (propType === 'object') {
+ if (propValue instanceof Date) {
+ return 'date';
+ } else if (propValue instanceof RegExp) {
+ return 'regexp';
+ }
+ }
+ return propType;
+}
+
+// Returns class name of the object, if any.
+function getClassName(propValue) {
+ if (!propValue.constructor || !propValue.constructor.name) {
+ return ANONYMOUS;
+ }
+ return propValue.constructor.name;
+}
+
+module.exports = ReactPropTypes;
+}).call(this,require('_process'))
+
+},{"./ReactElement":194,"./ReactPropTypeLocationNames":198,"./ReactPropTypesSecret":200,"./getIteratorFn":205,"_process":43,"fbjs/lib/emptyFunction":10,"fbjs/lib/warning":25}],200:[function(require,module,exports){
+arguments[4][113][0].apply(exports,arguments)
+},{"dup":113}],201:[function(require,module,exports){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
@@ -31212,47 +32506,41 @@ module.exports = keyOf;
'use strict';
-var hasOwnProperty = Object.prototype.hasOwnProperty;
+var _assign = require('object-assign');
+
+var ReactComponent = require('./ReactComponent');
+var ReactNoopUpdateQueue = require('./ReactNoopUpdateQueue');
+
+var emptyObject = require('fbjs/lib/emptyObject');
/**
- * 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:
- *
- * - the property value
- * - the property name
- * - the object being traversed
- *
- * 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.
- *
- * @grep function objectMap()
- * @grep function objMap()
- *
- * @param {?object} object
- * @param {function} callback
- * @param {*} context
- * @return {?object}
+ * Base class helpers for the updating state of a component.
*/
-function mapObject(object, callback, context) {
- if (!object) {
- return null;
- }
- var result = {};
- for (var name in object) {
- if (hasOwnProperty.call(object, name)) {
- result[name] = callback.call(context, object[name], name, object);
- }
- }
- return result;
+function ReactPureComponent(props, context, updater) {
+ // Duplicated from ReactComponent.
+ this.props = props;
+ this.context = context;
+ this.refs = emptyObject;
+ // We initialize the default updater but the real one gets injected by the
+ // renderer.
+ this.updater = updater || ReactNoopUpdateQueue;
}
-module.exports = mapObject;
-},{}],184:[function(require,module,exports){
+function ComponentDummy() {}
+ComponentDummy.prototype = ReactComponent.prototype;
+ReactPureComponent.prototype = new ComponentDummy();
+ReactPureComponent.prototype.constructor = ReactPureComponent;
+// Avoid an extra prototype jump for these methods.
+_assign(ReactPureComponent.prototype, ReactComponent.prototype);
+ReactPureComponent.prototype.isPureReactComponent = true;
+
+module.exports = ReactPureComponent;
+},{"./ReactComponent":190,"./ReactNoopUpdateQueue":197,"fbjs/lib/emptyObject":11,"object-assign":209}],202:[function(require,module,exports){
+arguments[4][121][0].apply(exports,arguments)
+},{"dup":121}],203:[function(require,module,exports){
+(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
@@ -31260,224 +32548,654 @@ module.exports = mapObject;
* of patent rights can be found in the PATENTS file in the same directory.
*
*
- * @typechecks static-only
*/
'use strict';
-/**
- * Memoizes the return value of a function that accepts one string argument.
- */
-
-function memoizeStringOnly(callback) {
- var cache = {};
- return function (string) {
- if (!cache.hasOwnProperty(string)) {
- cache[string] = callback.call(this, string);
- }
- return cache[string];
- };
+var canDefineProperty = false;
+if (process.env.NODE_ENV !== 'production') {
+ try {
+ // $FlowFixMe https://github.com/facebook/flow/issues/285
+ Object.defineProperty({}, 'x', { get: function () {} });
+ canDefineProperty = true;
+ } catch (x) {
+ // IE will fail on defineProperty
+ }
}
-module.exports = memoizeStringOnly;
-},{}],185:[function(require,module,exports){
+module.exports = canDefineProperty;
+}).call(this,require('_process'))
+
+},{"_process":43}],204:[function(require,module,exports){
+(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, 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
*/
'use strict';
-var ExecutionEnvironment = require('./ExecutionEnvironment');
+var _prodInvariant = require('./reactProdInvariant');
-var performance;
+var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
+var ReactPropTypesSecret = require('./ReactPropTypesSecret');
-if (ExecutionEnvironment.canUseDOM) {
- performance = window.performance || window.msPerformance || window.webkitPerformance;
+var invariant = require('fbjs/lib/invariant');
+var warning = require('fbjs/lib/warning');
+
+var ReactComponentTreeHook;
+
+if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') {
+ // Temporary hack.
+ // Inline requires don't work well with Jest:
+ // https://github.com/facebook/react/issues/7240
+ // Remove the inline requires when we don't need them anymore:
+ // https://github.com/facebook/react/pull/7178
+ ReactComponentTreeHook = require('./ReactComponentTreeHook');
}
-module.exports = performance || {};
-},{"./ExecutionEnvironment":164}],186:[function(require,module,exports){
-'use strict';
+var loggedTypeFailures = {};
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Assert that the values match with the type specs.
+ * Error messages are memorized and will only be shown once.
+ *
+ * @param {object} typeSpecs Map of name to a ReactPropType
+ * @param {object} values Runtime values that need to be type-checked
+ * @param {string} location e.g. "prop", "context", "child context"
+ * @param {string} componentName Name of the component for error messages.
+ * @param {?object} element The React element that is being type-checked
+ * @param {?number} debugID The React component instance that is being type-checked
+ * @private
+ */
+function checkReactTypeSpec(typeSpecs, values, location, componentName, element, debugID) {
+ for (var typeSpecName in typeSpecs) {
+ if (typeSpecs.hasOwnProperty(typeSpecName)) {
+ var error;
+ // Prop type validation may throw. In case they do, we don't want to
+ // fail the render phase where it didn't fail before. So we log it.
+ // After these have been cleaned up, we'll let them throw.
+ try {
+ // This is intentionally an invariant that gets caught. It's the same
+ // behavior as without this statement except with a better message.
+ !(typeof typeSpecs[typeSpecName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : _prodInvariant('84', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : void 0;
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
+ } catch (ex) {
+ error = ex;
+ }
+ process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName, typeof error) : void 0;
+ if (error instanceof Error && !(error.message in loggedTypeFailures)) {
+ // Only monitor this failure once because there tends to be a lot of the
+ // same error.
+ loggedTypeFailures[error.message] = true;
+
+ var componentStackInfo = '';
+
+ if (process.env.NODE_ENV !== 'production') {
+ if (!ReactComponentTreeHook) {
+ ReactComponentTreeHook = require('./ReactComponentTreeHook');
+ }
+ if (debugID !== null) {
+ componentStackInfo = ReactComponentTreeHook.getStackAddendumByID(debugID);
+ } else if (element !== null) {
+ componentStackInfo = ReactComponentTreeHook.getCurrentStackAddendum(element);
+ }
+ }
+
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Failed %s type: %s%s', location, error.message, componentStackInfo) : void 0;
+ }
+ }
+ }
+}
+
+module.exports = checkReactTypeSpec;
+}).call(this,require('_process'))
+
+},{"./ReactComponentTreeHook":191,"./ReactPropTypeLocationNames":198,"./ReactPropTypesSecret":200,"./reactProdInvariant":207,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25}],205:[function(require,module,exports){
+arguments[4][154][0].apply(exports,arguments)
+},{"dup":154}],206:[function(require,module,exports){
+(function (process){
+/**
+ * Copyright 2013-present, 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
*/
+'use strict';
-var performance = require('./performance');
+var _prodInvariant = require('./reactProdInvariant');
-var performanceNow;
+var ReactElement = require('./ReactElement');
+
+var invariant = require('fbjs/lib/invariant');
/**
- * Detect if we can use `window.performance.now()` and gracefully fallback to
- * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
- * because of Facebook's testing infrastructure.
+ * Returns the first child in a collection of children and verifies that there
+ * is only one child in the collection.
+ *
+ * See https://facebook.github.io/react/docs/top-level-api.html#react.children.only
+ *
+ * The current implementation of this function assumes that a single child gets
+ * passed without a wrapper, but the purpose of this helper function is to
+ * abstract away the particular structure of children.
+ *
+ * @param {?object} children Child collection structure.
+ * @return {ReactElement} The first and only `ReactElement` contained in the
+ * structure.
*/
-if (performance.now) {
- performanceNow = function performanceNow() {
- return performance.now();
- };
-} else {
- performanceNow = function performanceNow() {
- return Date.now();
- };
+function onlyChild(children) {
+ !ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'React.Children.only expected to receive a single React element child.') : _prodInvariant('143') : void 0;
+ return children;
}
-module.exports = performanceNow;
-},{"./performance":185}],187:[function(require,module,exports){
+module.exports = onlyChild;
+}).call(this,require('_process'))
+
+},{"./ReactElement":194,"./reactProdInvariant":207,"_process":43,"fbjs/lib/invariant":18}],207:[function(require,module,exports){
+arguments[4][163][0].apply(exports,arguments)
+},{"dup":163}],208:[function(require,module,exports){
+(function (process){
/**
- * Copyright (c) 2013-present, Facebook, Inc.
+ * Copyright 2013-present, 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
- *
*/
-/*eslint-disable no-self-compare */
-
'use strict';
-var hasOwnProperty = Object.prototype.hasOwnProperty;
+var _prodInvariant = require('./reactProdInvariant');
+
+var ReactCurrentOwner = require('./ReactCurrentOwner');
+var REACT_ELEMENT_TYPE = require('./ReactElementSymbol');
+
+var getIteratorFn = require('./getIteratorFn');
+var invariant = require('fbjs/lib/invariant');
+var KeyEscapeUtils = require('./KeyEscapeUtils');
+var warning = require('fbjs/lib/warning');
+
+var SEPARATOR = '.';
+var SUBSEPARATOR = ':';
/**
- * inlined Object.is polyfill to avoid requiring consumers ship their own
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
+ * This is inlined from ReactElement since this file is shared between
+ * isomorphic and renderers. We could extract this to a
+ *
*/
-function is(x, y) {
- // SameValue algorithm
- if (x === y) {
- // Steps 1-5, 7-10
- // Steps 6.b-6.e: +0 != -0
- return x !== 0 || 1 / x === 1 / y;
- } else {
- // Step 6.a: NaN == NaN
- return x !== x && y !== y;
+
+/**
+ * TODO: Test that a single child and an array with one item have the same key
+ * pattern.
+ */
+
+var didWarnAboutMaps = false;
+
+/**
+ * Generate a key string that identifies a component within a set.
+ *
+ * @param {*} component A component that could contain a manual key.
+ * @param {number} index Index that is used if a manual key is not provided.
+ * @return {string}
+ */
+function getComponentKey(component, index) {
+ // Do some typechecking here since we call this blindly. We want to ensure
+ // that we don't block potential future ES APIs.
+ if (component && typeof component === 'object' && component.key != null) {
+ // Explicit key
+ return KeyEscapeUtils.escape(component.key);
}
+ // Implicit key determined by the index in the set
+ return index.toString(36);
}
/**
- * Performs equality by iterating through keys on an object and returning false
- * when any key has values which are not strictly equal between the arguments.
- * Returns true when the values of all keys are strictly equal.
+ * @param {?*} children Children tree container.
+ * @param {!string} nameSoFar Name of the key path so far.
+ * @param {!function} callback Callback to invoke with each child found.
+ * @param {?*} traverseContext Used to pass information throughout the traversal
+ * process.
+ * @return {!number} The number of children in this subtree.
*/
-function shallowEqual(objA, objB) {
- if (is(objA, objB)) {
- return true;
- }
+function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
+ var type = typeof children;
- if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
- return false;
+ if (type === 'undefined' || type === 'boolean') {
+ // All of the above are perceived as null.
+ children = null;
}
- var keysA = Object.keys(objA);
- var keysB = Object.keys(objB);
-
- if (keysA.length !== keysB.length) {
- return false;
+ if (children === null || type === 'string' || type === 'number' ||
+ // The following is inlined from ReactElement. This means we can optimize
+ // some checks. React Fiber also inlines this logic for similar purposes.
+ type === 'object' && children.$$typeof === REACT_ELEMENT_TYPE) {
+ callback(traverseContext, children,
+ // If it's the only child, treat the name as if it was wrapped in an array
+ // so that it's consistent if the number of children grows.
+ nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
+ return 1;
}
- // Test for A's keys different from B.
- for (var i = 0; i < keysA.length; i++) {
- if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
- return false;
+ var child;
+ var nextName;
+ var subtreeCount = 0; // Count of children found in the current subtree.
+ var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
+
+ if (Array.isArray(children)) {
+ for (var i = 0; i < children.length; i++) {
+ child = children[i];
+ nextName = nextNamePrefix + getComponentKey(child, i);
+ subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
+ }
+ } else {
+ var iteratorFn = getIteratorFn(children);
+ if (iteratorFn) {
+ var iterator = iteratorFn.call(children);
+ var step;
+ if (iteratorFn !== children.entries) {
+ var ii = 0;
+ while (!(step = iterator.next()).done) {
+ child = step.value;
+ nextName = nextNamePrefix + getComponentKey(child, ii++);
+ subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
+ }
+ } else {
+ if (process.env.NODE_ENV !== 'production') {
+ var mapsAsChildrenAddendum = '';
+ if (ReactCurrentOwner.current) {
+ var mapsAsChildrenOwnerName = ReactCurrentOwner.current.getName();
+ if (mapsAsChildrenOwnerName) {
+ mapsAsChildrenAddendum = ' Check the render method of `' + mapsAsChildrenOwnerName + '`.';
+ }
+ }
+ process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.%s', mapsAsChildrenAddendum) : void 0;
+ didWarnAboutMaps = true;
+ }
+ // Iterator will provide entry [k,v] tuples rather than values.
+ while (!(step = iterator.next()).done) {
+ var entry = step.value;
+ if (entry) {
+ child = entry[1];
+ nextName = nextNamePrefix + KeyEscapeUtils.escape(entry[0]) + SUBSEPARATOR + getComponentKey(child, 0);
+ subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
+ }
+ }
+ }
+ } else if (type === 'object') {
+ var addendum = '';
+ if (process.env.NODE_ENV !== 'production') {
+ addendum = ' If you meant to render a collection of children, use an array ' + 'instead or wrap the object using createFragment(object) from the ' + 'React add-ons.';
+ if (children._isReactElement) {
+ addendum = ' It looks like you\'re using an element created by a different ' + 'version of React. Make sure to use only one copy of React.';
+ }
+ if (ReactCurrentOwner.current) {
+ var name = ReactCurrentOwner.current.getName();
+ if (name) {
+ addendum += ' Check the render method of `' + name + '`.';
+ }
+ }
+ }
+ var childrenString = String(children);
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : _prodInvariant('31', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : void 0;
}
}
- return true;
+ return subtreeCount;
}
-module.exports = shallowEqual;
-},{}],188:[function(require,module,exports){
-(function (process){
/**
- * Copyright 2014-2015, Facebook, Inc.
- * All rights reserved.
+ * Traverses children that are typically specified as `props.children`, but
+ * might also be specified through attributes:
*
- * 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.
+ * - `traverseAllChildren(this.props.children, ...)`
+ * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
*
+ * The `traverseContext` is an optional argument that is passed through the
+ * entire traversal. It can be used to store accumulations or anything else that
+ * the callback might find relevant.
+ *
+ * @param {?*} children Children tree object.
+ * @param {!function} callback To invoke upon traversing each child.
+ * @param {?*} traverseContext Context for traversal.
+ * @return {!number} The number of children in this subtree.
*/
+function traverseAllChildren(children, callback, traverseContext) {
+ if (children == null) {
+ return 0;
+ }
+ return traverseAllChildrenImpl(children, '', callback, traverseContext);
+}
+
+module.exports = traverseAllChildren;
+}).call(this,require('_process'))
+
+},{"./KeyEscapeUtils":185,"./ReactCurrentOwner":192,"./ReactElementSymbol":195,"./getIteratorFn":205,"./reactProdInvariant":207,"_process":43,"fbjs/lib/invariant":18,"fbjs/lib/warning":25}],209:[function(require,module,exports){
+arguments[4][170][0].apply(exports,arguments)
+},{"dup":170}],210:[function(require,module,exports){
'use strict';
-var emptyFunction = require('./emptyFunction');
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
+
+exports.printBuffer = printBuffer;
+
+var _helpers = require('./helpers');
+
+var _diff = require('./diff');
+
+var _diff2 = _interopRequireDefault(_diff);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
/**
- * Similar to invariant but only logs a warning if the condition is not met.
- * This can be used to log issues in development environments in critical
- * paths. Removing the logging code for production environments will keep the
- * same logic and follow the same code paths.
+ * Get log level string based on supplied params
+ *
+ * @param {string | function | object} level - console[level]
+ * @param {object} action - selected action
+ * @param {array} payload - selected payload
+ * @param {string} type - log entry type
+ *
+ * @returns {string} level
*/
+function getLogLevel(level, action, payload, type) {
+ switch (typeof level === 'undefined' ? 'undefined' : _typeof(level)) {
+ case 'object':
+ return typeof level[type] === 'function' ? level[type].apply(level, _toConsumableArray(payload)) : level[type];
+ case 'function':
+ return level(action);
+ default:
+ return level;
+ }
+}
-var warning = emptyFunction;
+function defaultTitleFormatter(options) {
+ var timestamp = options.timestamp,
+ duration = options.duration;
-if (process.env.NODE_ENV !== 'production') {
- warning = function warning(condition, format) {
- for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
- args[_key - 2] = arguments[_key];
+
+ return function (action, time, took) {
+ var parts = ['action'];
+
+ if (timestamp) parts.push('@ ' + time);
+ parts.push(String(action.type));
+ if (duration) parts.push('(in ' + took.toFixed(2) + ' ms)');
+
+ return parts.join(' ');
+ };
+}
+
+function printBuffer(buffer, options) {
+ var logger = options.logger,
+ actionTransformer = options.actionTransformer,
+ _options$titleFormatt = options.titleFormatter,
+ titleFormatter = _options$titleFormatt === undefined ? defaultTitleFormatter(options) : _options$titleFormatt,
+ collapsed = options.collapsed,
+ colors = options.colors,
+ level = options.level,
+ diff = options.diff;
+
+
+ buffer.forEach(function (logEntry, key) {
+ var started = logEntry.started,
+ startedTime = logEntry.startedTime,
+ action = logEntry.action,
+ prevState = logEntry.prevState,
+ error = logEntry.error;
+ var took = logEntry.took,
+ nextState = logEntry.nextState;
+
+ var nextEntry = buffer[key + 1];
+
+ if (nextEntry) {
+ nextState = nextEntry.prevState;
+ took = nextEntry.started - started;
}
- if (format === undefined) {
- throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
+ // Message
+ var formattedAction = actionTransformer(action);
+ var isCollapsed = typeof collapsed === 'function' ? collapsed(function () {
+ return nextState;
+ }, action, logEntry) : collapsed;
+
+ var formattedTime = (0, _helpers.formatTime)(startedTime);
+ var titleCSS = colors.title ? 'color: ' + colors.title(formattedAction) + ';' : null;
+ var title = titleFormatter(formattedAction, formattedTime, took);
+
+ // Render
+ try {
+ if (isCollapsed) {
+ if (colors.title) logger.groupCollapsed('%c ' + title, titleCSS);else logger.groupCollapsed(title);
+ } else {
+ if (colors.title) logger.group('%c ' + title, titleCSS);else logger.group(title);
+ }
+ } catch (e) {
+ logger.log(title);
}
- if (format.indexOf('Failed Composite propType: ') === 0) {
- return; // Ignore CompositeComponent proptype check.
+ var prevStateLevel = getLogLevel(level, formattedAction, [prevState], 'prevState');
+ var actionLevel = getLogLevel(level, formattedAction, [formattedAction], 'action');
+ var errorLevel = getLogLevel(level, formattedAction, [error, prevState], 'error');
+ var nextStateLevel = getLogLevel(level, formattedAction, [nextState], 'nextState');
+
+ if (prevStateLevel) {
+ if (colors.prevState) logger[prevStateLevel]('%c prev state', 'color: ' + colors.prevState(prevState) + '; font-weight: bold', prevState);else logger[prevStateLevel]('prev state', prevState);
}
- if (!condition) {
- var argIndex = 0;
- var message = 'Warning: ' + format.replace(/%s/g, function () {
- return args[argIndex++];
- });
- if (typeof console !== 'undefined') {
- console.error(message);
- }
- try {
- // --- Welcome to debugging React ---
- // This error was thrown as a convenience so that you can use this stack
- // to find the callsite that caused this warning to fire.
- throw new Error(message);
- } catch (x) {}
+ if (actionLevel) {
+ if (colors.action) logger[actionLevel]('%c action', 'color: ' + colors.action(formattedAction) + '; font-weight: bold', formattedAction);else logger[actionLevel]('action', formattedAction);
}
- };
+
+ if (error && errorLevel) {
+ if (colors.error) logger[errorLevel]('%c error', 'color: ' + colors.error(error, prevState) + '; font-weight: bold', error);else logger[errorLevel]('error', error);
+ }
+
+ if (nextStateLevel) {
+ if (colors.nextState) logger[nextStateLevel]('%c next state', 'color: ' + colors.nextState(nextState) + '; font-weight: bold', nextState);else logger[nextStateLevel]('next state', nextState);
+ }
+
+ if (diff) {
+ (0, _diff2.default)(prevState, nextState, logger, isCollapsed);
+ }
+
+ try {
+ logger.groupEnd();
+ } catch (e) {
+ logger.log('\u2014\u2014 log end \u2014\u2014');
+ }
+ });
}
+},{"./diff":212,"./helpers":213}],211:[function(require,module,exports){
+"use strict";
-module.exports = warning;
-}).call(this,require('_process'))
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = {
+ level: "log",
+ logger: console,
+ logErrors: true,
+ collapsed: undefined,
+ predicate: undefined,
+ duration: false,
+ timestamp: true,
+ stateTransformer: function stateTransformer(state) {
+ return state;
+ },
+ actionTransformer: function actionTransformer(action) {
+ return action;
+ },
+ errorTransformer: function errorTransformer(error) {
+ return error;
+ },
+ colors: {
+ title: function title() {
+ return "inherit";
+ },
+ prevState: function prevState() {
+ return "#9E9E9E";
+ },
+ action: function action() {
+ return "#03A9F4";
+ },
+ nextState: function nextState() {
+ return "#4CAF50";
+ },
+ error: function error() {
+ return "#F20404";
+ }
+ },
+ diff: false,
+ diffPredicate: undefined,
+
+ // Deprecated options
+ transformer: undefined
+};
+module.exports = exports["default"];
+},{}],212:[function(require,module,exports){
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = diffLogger;
+
+var _deepDiff = require('deep-diff');
+
+var _deepDiff2 = _interopRequireDefault(_deepDiff);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
+
+// https://github.com/flitbit/diff#differences
+var dictionary = {
+ 'E': {
+ color: '#2196F3',
+ text: 'CHANGED:'
+ },
+ 'N': {
+ color: '#4CAF50',
+ text: 'ADDED:'
+ },
+ 'D': {
+ color: '#F44336',
+ text: 'DELETED:'
+ },
+ 'A': {
+ color: '#2196F3',
+ text: 'ARRAY:'
+ }
+};
+
+function style(kind) {
+ return 'color: ' + dictionary[kind].color + '; font-weight: bold';
+}
+
+function render(diff) {
+ var kind = diff.kind,
+ path = diff.path,
+ lhs = diff.lhs,
+ rhs = diff.rhs,
+ index = diff.index,
+ item = diff.item;
+
+
+ switch (kind) {
+ case 'E':
+ return [path.join('.'), lhs, '\u2192', rhs];
+ case 'N':
+ return [path.join('.'), rhs];
+ case 'D':
+ return [path.join('.')];
+ case 'A':
+ return [path.join('.') + '[' + index + ']', item];
+ default:
+ return [];
+ }
+}
+
+function diffLogger(prevState, newState, logger, isCollapsed) {
+ var diff = (0, _deepDiff2.default)(prevState, newState);
+
+ try {
+ if (isCollapsed) {
+ logger.groupCollapsed('diff');
+ } else {
+ logger.group('diff');
+ }
+ } catch (e) {
+ logger.log('diff');
+ }
+
+ if (diff) {
+ diff.forEach(function (elem) {
+ var kind = elem.kind;
+
+ var output = render(elem);
+
+ logger.log.apply(logger, ['%c ' + dictionary[kind].text, style(kind)].concat(_toConsumableArray(output)));
+ });
+ } else {
+ logger.log('\u2014\u2014 no diff \u2014\u2014');
+ }
+
+ try {
+ logger.groupEnd();
+ } catch (e) {
+ logger.log('\u2014\u2014 diff end \u2014\u2014 ');
+ }
+}
+module.exports = exports['default'];
+},{"deep-diff":2}],213:[function(require,module,exports){
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+var repeat = exports.repeat = function repeat(str, times) {
+ return new Array(times + 1).join(str);
+};
-},{"./emptyFunction":170,"_process":15}],189:[function(require,module,exports){
+var pad = exports.pad = function pad(num, maxLength) {
+ return repeat("0", maxLength - num.toString().length) + num;
+};
+
+var formatTime = exports.formatTime = function formatTime(time) {
+ return pad(time.getHours(), 2) + ":" + pad(time.getMinutes(), 2) + ":" + pad(time.getSeconds(), 2) + "." + pad(time.getMilliseconds(), 3);
+};
+
+// Use performance API if it's available in order to get better precision
+var timer = exports.timer = typeof performance !== "undefined" && performance !== null && typeof performance.now === "function" ? performance : Date;
+},{}],214:[function(require,module,exports){
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-exports["default"] = applyMiddleware;
+exports['default'] = applyMiddleware;
var _compose = require('./compose');
var _compose2 = _interopRequireDefault(_compose);
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* Creates a store enhancer that applies middleware to the dispatch method
@@ -31501,8 +33219,8 @@ function applyMiddleware() {
}
return function (createStore) {
- return function (reducer, initialState, enhancer) {
- var store = createStore(reducer, initialState, enhancer);
+ return function (reducer, preloadedState, enhancer) {
+ var store = createStore(reducer, preloadedState, enhancer);
var _dispatch = store.dispatch;
var chain = [];
@@ -31515,7 +33233,7 @@ function applyMiddleware() {
chain = middlewares.map(function (middleware) {
return middleware(middlewareAPI);
});
- _dispatch = _compose2["default"].apply(undefined, chain)(store.dispatch);
+ _dispatch = _compose2['default'].apply(undefined, chain)(store.dispatch);
return _extends({}, store, {
dispatch: _dispatch
@@ -31523,11 +33241,11 @@ function applyMiddleware() {
};
};
}
-},{"./compose":192}],190:[function(require,module,exports){
+},{"./compose":217}],215:[function(require,module,exports){
'use strict';
exports.__esModule = true;
-exports["default"] = bindActionCreators;
+exports['default'] = bindActionCreators;
function bindActionCreator(actionCreator, dispatch) {
return function () {
return dispatch(actionCreator.apply(undefined, arguments));
@@ -31575,12 +33293,12 @@ function bindActionCreators(actionCreators, dispatch) {
}
return boundActionCreators;
}
-},{}],191:[function(require,module,exports){
+},{}],216:[function(require,module,exports){
(function (process){
'use strict';
exports.__esModule = true;
-exports["default"] = combineReducers;
+exports['default'] = combineReducers;
var _createStore = require('./createStore');
@@ -31592,7 +33310,7 @@ var _warning = require('./utils/warning');
var _warning2 = _interopRequireDefault(_warning);
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function getUndefinedStateErrorMessage(key, action) {
var actionType = action && action.type;
@@ -31601,20 +33319,24 @@ function getUndefinedStateErrorMessage(key, action) {
return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state.';
}
-function getUnexpectedStateShapeWarningMessage(inputState, reducers, action) {
+function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
var reducerKeys = Object.keys(reducers);
- var argumentName = action && action.type === _createStore.ActionTypes.INIT ? 'initialState argument passed to createStore' : 'previous state received by the reducer';
+ var argumentName = action && action.type === _createStore.ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
if (reducerKeys.length === 0) {
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
}
- if (!(0, _isPlainObject2["default"])(inputState)) {
+ if (!(0, _isPlainObject2['default'])(inputState)) {
return 'The ' + argumentName + ' has unexpected type of "' + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"');
}
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
- return !reducers.hasOwnProperty(key);
+ return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
+ });
+
+ unexpectedKeys.forEach(function (key) {
+ unexpectedKeyCache[key] = true;
});
if (unexpectedKeys.length > 0) {
@@ -31659,12 +33381,23 @@ function combineReducers(reducers) {
var finalReducers = {};
for (var i = 0; i < reducerKeys.length; i++) {
var key = reducerKeys[i];
+
+ if (process.env.NODE_ENV !== 'production') {
+ if (typeof reducers[key] === 'undefined') {
+ (0, _warning2['default'])('No reducer provided for key "' + key + '"');
+ }
+ }
+
if (typeof reducers[key] === 'function') {
finalReducers[key] = reducers[key];
}
}
var finalReducerKeys = Object.keys(finalReducers);
+ if (process.env.NODE_ENV !== 'production') {
+ var unexpectedKeyCache = {};
+ }
+
var sanityError;
try {
assertReducerSanity(finalReducers);
@@ -31681,9 +33414,9 @@ function combineReducers(reducers) {
}
if (process.env.NODE_ENV !== 'production') {
- var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action);
+ var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
if (warningMessage) {
- (0, _warning2["default"])(warningMessage);
+ (0, _warning2['default'])(warningMessage);
}
}
@@ -31706,7 +33439,7 @@ function combineReducers(reducers) {
}
}).call(this,require('_process'))
-},{"./createStore":193,"./utils/warning":194,"_process":15,"lodash/isPlainObject":13}],192:[function(require,module,exports){
+},{"./createStore":218,"./utils/warning":219,"_process":43,"lodash/isPlainObject":42}],217:[function(require,module,exports){
"use strict";
exports.__esModule = true;
@@ -31731,28 +33464,26 @@ function compose() {
return function (arg) {
return arg;
};
- } else {
- var _ret = function () {
- var last = funcs[funcs.length - 1];
- var rest = funcs.slice(0, -1);
- return {
- v: function v() {
- return rest.reduceRight(function (composed, f) {
- return f(composed);
- }, last.apply(undefined, arguments));
- }
- };
- }();
+ }
- if (typeof _ret === "object") return _ret.v;
+ if (funcs.length === 1) {
+ return funcs[0];
}
+
+ var last = funcs[funcs.length - 1];
+ var rest = funcs.slice(0, -1);
+ return function () {
+ return rest.reduceRight(function (composed, f) {
+ return f(composed);
+ }, last.apply(undefined, arguments));
+ };
}
-},{}],193:[function(require,module,exports){
+},{}],218:[function(require,module,exports){
'use strict';
exports.__esModule = true;
exports.ActionTypes = undefined;
-exports["default"] = createStore;
+exports['default'] = createStore;
var _isPlainObject = require('lodash/isPlainObject');
@@ -31762,7 +33493,7 @@ var _symbolObservable = require('symbol-observable');
var _symbolObservable2 = _interopRequireDefault(_symbolObservable);
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/**
* These are private action types reserved by Redux.
@@ -31785,7 +33516,7 @@ var ActionTypes = exports.ActionTypes = {
* @param {Function} reducer A function that returns the next state tree, given
* the current state tree and the action to handle.
*
- * @param {any} [initialState] The initial state. You may optionally specify it
+ * @param {any} [preloadedState] The initial state. You may optionally specify it
* to hydrate the state from the server in universal apps, or to restore a
* previously serialized user session.
* If you use `combineReducers` to produce the root reducer function, this must be
@@ -31799,12 +33530,12 @@ var ActionTypes = exports.ActionTypes = {
* @returns {Store} A Redux store that lets you read the state, dispatch actions
* and subscribe to changes.
*/
-function createStore(reducer, initialState, enhancer) {
+function createStore(reducer, preloadedState, enhancer) {
var _ref2;
- if (typeof initialState === 'function' && typeof enhancer === 'undefined') {
- enhancer = initialState;
- initialState = undefined;
+ if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
+ enhancer = preloadedState;
+ preloadedState = undefined;
}
if (typeof enhancer !== 'undefined') {
@@ -31812,7 +33543,7 @@ function createStore(reducer, initialState, enhancer) {
throw new Error('Expected the enhancer to be a function.');
}
- return enhancer(createStore)(reducer, initialState);
+ return enhancer(createStore)(reducer, preloadedState);
}
if (typeof reducer !== 'function') {
@@ -31820,7 +33551,7 @@ function createStore(reducer, initialState, enhancer) {
}
var currentReducer = reducer;
- var currentState = initialState;
+ var currentState = preloadedState;
var currentListeners = [];
var nextListeners = currentListeners;
var isDispatching = false;
@@ -31912,7 +33643,7 @@ function createStore(reducer, initialState, enhancer) {
* return something else (for example, a Promise you can await).
*/
function dispatch(action) {
- if (!(0, _isPlainObject2["default"])(action)) {
+ if (!(0, _isPlainObject2['default'])(action)) {
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
}
@@ -31977,7 +33708,6 @@ function createStore(reducer, initialState, enhancer) {
* be used to unsubscribe the observable from the store, and prevent further
* emission of values from the observable.
*/
-
subscribe: function subscribe(observer) {
if (typeof observer !== 'object') {
throw new TypeError('Expected the observer to be an object.');
@@ -31993,7 +33723,7 @@ function createStore(reducer, initialState, enhancer) {
var unsubscribe = outerSubscribe(observeState);
return { unsubscribe: unsubscribe };
}
- }, _ref[_symbolObservable2["default"]] = function () {
+ }, _ref[_symbolObservable2['default']] = function () {
return this;
}, _ref;
}
@@ -32008,13 +33738,13 @@ function createStore(reducer, initialState, enhancer) {
subscribe: subscribe,
getState: getState,
replaceReducer: replaceReducer
- }, _ref2[_symbolObservable2["default"]] = observable, _ref2;
+ }, _ref2[_symbolObservable2['default']] = observable, _ref2;
}
-},{"lodash/isPlainObject":13,"symbol-observable":196}],194:[function(require,module,exports){
+},{"lodash/isPlainObject":42,"symbol-observable":220}],219:[function(require,module,exports){
'use strict';
exports.__esModule = true;
-exports["default"] = warning;
+exports['default'] = warning;
/**
* Prints a warning in the console if it exists.
*
@@ -32036,266 +33766,59 @@ function warning(message) {
} catch (e) {}
/* eslint-enable no-empty */
}
-},{}],195:[function(require,module,exports){
-/**
- * lodash 3.1.2 (Custom Build) <https://lodash.com/>
- * Build: `lodash modern modularize exports="npm" -o ./`
- * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
- * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
- * Available under MIT license <https://lodash.com/license>
- */
-var getNative = require('lodash._getnative'),
- isArguments = require('lodash.isarguments'),
- isArray = require('lodash.isarray');
-
-/** Used to detect unsigned integer values. */
-var reIsUint = /^\d+$/;
-
-/** Used for native method references. */
-var objectProto = Object.prototype;
-
-/** Used to check objects for own properties. */
-var hasOwnProperty = objectProto.hasOwnProperty;
-
-/* Native method references for those with the same name as other `lodash` methods. */
-var nativeKeys = getNative(Object, 'keys');
-
-/**
- * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
- * of an array-like value.
- */
-var MAX_SAFE_INTEGER = 9007199254740991;
-
-/**
- * The base implementation of `_.property` without support for deep paths.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new function.
- */
-function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
- };
-}
-
-/**
- * Gets the "length" property value of `object`.
- *
- * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
- * that affects Safari on at least iOS 8.1-8.3 ARM64.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {*} Returns the "length" value.
- */
-var getLength = baseProperty('length');
-
-/**
- * Checks if `value` is array-like.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
- */
-function isArrayLike(value) {
- return value != null && isLength(getLength(value));
-}
+},{}],220:[function(require,module,exports){
+module.exports = require('./lib/index');
-/**
- * Checks if `value` is a valid array-like index.
- *
- * @private
- * @param {*} value The value to check.
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
- */
-function isIndex(value, length) {
- value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
- length = length == null ? MAX_SAFE_INTEGER : length;
- return value > -1 && value % 1 == 0 && value < length;
-}
-
-/**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
- */
-function isLength(value) {
- return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
-}
-
-/**
- * A fallback implementation of `Object.keys` which creates an array of the
- * own enumerable property names of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
-function shimKeys(object) {
- var props = keysIn(object),
- propsLength = props.length,
- length = propsLength && object.length;
-
- var allowIndexes = !!length && isLength(length) &&
- (isArray(object) || isArguments(object));
+},{"./lib/index":221}],221:[function(require,module,exports){
+(function (global){
+'use strict';
- var index = -1,
- result = [];
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
- while (++index < propsLength) {
- var key = props[index];
- if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
- result.push(key);
- }
- }
- return result;
-}
+var _ponyfill = require('./ponyfill');
-/**
- * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
- * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(1);
- * // => false
- */
-function isObject(value) {
- // Avoid a V8 JIT bug in Chrome 19-20.
- // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
- var type = typeof value;
- return !!value && (type == 'object' || type == 'function');
-}
+var _ponyfill2 = _interopRequireDefault(_ponyfill);
-/**
- * Creates an array of the own enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects. See the
- * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
- * for more details.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keys(new Foo);
- * // => ['a', 'b'] (iteration order is not guaranteed)
- *
- * _.keys('hi');
- * // => ['0', '1']
- */
-var keys = !nativeKeys ? shimKeys : function(object) {
- var Ctor = object == null ? undefined : object.constructor;
- if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
- (typeof object != 'function' && isArrayLike(object))) {
- return shimKeys(object);
- }
- return isObject(object) ? nativeKeys(object) : [];
-};
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
-/**
- * Creates an array of the own and inherited enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keysIn(new Foo);
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
- */
-function keysIn(object) {
- if (object == null) {
- return [];
- }
- if (!isObject(object)) {
- object = Object(object);
- }
- var length = object.length;
- length = (length && isLength(length) &&
- (isArray(object) || isArguments(object)) && length) || 0;
+var root; /* global window */
- var Ctor = object.constructor,
- index = -1,
- isProto = typeof Ctor == 'function' && Ctor.prototype === object,
- result = Array(length),
- skipIndexes = length > 0;
- while (++index < length) {
- result[index] = (index + '');
- }
- for (var key in object) {
- if (!(skipIndexes && isIndex(key, length)) &&
- !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
- result.push(key);
- }
- }
- return result;
+if (typeof self !== 'undefined') {
+ root = self;
+} else if (typeof window !== 'undefined') {
+ root = window;
+} else if (typeof global !== 'undefined') {
+ root = global;
+} else if (typeof module !== 'undefined') {
+ root = module;
+} else {
+ root = Function('return this')();
}
-module.exports = keys;
-
-},{"lodash._getnative":6,"lodash.isarguments":8,"lodash.isarray":9}],196:[function(require,module,exports){
-(function (global){
-/* global window */
-'use strict';
-
-module.exports = require('./ponyfill')(global || window || this);
-
+var result = (0, _ponyfill2['default'])(root);
+exports['default'] = result;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-},{"./ponyfill":197}],197:[function(require,module,exports){
+},{"./ponyfill":222}],222:[function(require,module,exports){
'use strict';
-module.exports = function symbolObservablePonyfill(root) {
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports['default'] = symbolObservablePonyfill;
+function symbolObservablePonyfill(root) {
var result;
- var Symbol = root.Symbol;
+ var _Symbol = root.Symbol;
- if (typeof Symbol === 'function') {
- if (Symbol.observable) {
- result = Symbol.observable;
+ if (typeof _Symbol === 'function') {
+ if (_Symbol.observable) {
+ result = _Symbol.observable;
} else {
- result = Symbol('observable');
- Symbol.observable = result;
+ result = _Symbol('observable');
+ _Symbol.observable = result;
}
} else {
result = '@@observable';
@@ -32303,7 +33826,6 @@ module.exports = function symbolObservablePonyfill(root) {
return result;
};
-
},{}],"classnames":[function(require,module,exports){
/*!
Copyright (c) 2016 Jed Watson.
@@ -32354,24 +33876,12 @@ module.exports = function symbolObservablePonyfill(root) {
}
}());
-},{}],"flux":[function(require,module,exports){
-/**
- * Copyright (c) 2014-2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
-
-module.exports.Dispatcher = require('./lib/Dispatcher');
-
-},{"./lib/Dispatcher":3}],"lodash":[function(require,module,exports){
+},{}],"lodash":[function(require,module,exports){
(function (global){
/**
* @license
- * lodash <https://lodash.com/>
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
+ * Lodash <https://lodash.com/>
+ * Copyright JS Foundation and other contributors <https://js.foundation/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
@@ -32382,42 +33892,51 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var undefined;
/** Used as the semantic version number. */
- var VERSION = '4.13.1';
+ var VERSION = '4.17.4';
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
- /** Used as the `TypeError` message for "Functions" methods. */
- var FUNC_ERROR_TEXT = 'Expected a function';
+ /** Error message constants. */
+ var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.',
+ FUNC_ERROR_TEXT = 'Expected a function';
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
+ /** Used as the maximum memoize cache size. */
+ var MAX_MEMOIZE_SIZE = 500;
+
/** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__';
- /** Used to compose bitmasks for wrapper metadata. */
- var BIND_FLAG = 1,
- BIND_KEY_FLAG = 2,
- CURRY_BOUND_FLAG = 4,
- CURRY_FLAG = 8,
- CURRY_RIGHT_FLAG = 16,
- PARTIAL_FLAG = 32,
- PARTIAL_RIGHT_FLAG = 64,
- ARY_FLAG = 128,
- REARG_FLAG = 256,
- FLIP_FLAG = 512;
-
- /** Used to compose bitmasks for comparison styles. */
- var UNORDERED_COMPARE_FLAG = 1,
- PARTIAL_COMPARE_FLAG = 2;
+ /** Used to compose bitmasks for cloning. */
+ var CLONE_DEEP_FLAG = 1,
+ CLONE_FLAT_FLAG = 2,
+ CLONE_SYMBOLS_FLAG = 4;
+
+ /** Used to compose bitmasks for value comparisons. */
+ var COMPARE_PARTIAL_FLAG = 1,
+ COMPARE_UNORDERED_FLAG = 2;
+
+ /** Used to compose bitmasks for function metadata. */
+ var WRAP_BIND_FLAG = 1,
+ WRAP_BIND_KEY_FLAG = 2,
+ WRAP_CURRY_BOUND_FLAG = 4,
+ WRAP_CURRY_FLAG = 8,
+ WRAP_CURRY_RIGHT_FLAG = 16,
+ WRAP_PARTIAL_FLAG = 32,
+ WRAP_PARTIAL_RIGHT_FLAG = 64,
+ WRAP_ARY_FLAG = 128,
+ WRAP_REARG_FLAG = 256,
+ WRAP_FLIP_FLAG = 512;
/** Used as default options for `_.truncate`. */
var DEFAULT_TRUNC_LENGTH = 30,
DEFAULT_TRUNC_OMISSION = '...';
/** Used to detect hot functions by number of calls within a span of milliseconds. */
- var HOT_COUNT = 150,
+ var HOT_COUNT = 800,
HOT_SPAN = 16;
/** Used to indicate the type of lazy iteratees. */
@@ -32436,22 +33955,40 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1,
HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
+ /** Used to associate wrap methods with their bit flags. */
+ var wrapFlags = [
+ ['ary', WRAP_ARY_FLAG],
+ ['bind', WRAP_BIND_FLAG],
+ ['bindKey', WRAP_BIND_KEY_FLAG],
+ ['curry', WRAP_CURRY_FLAG],
+ ['curryRight', WRAP_CURRY_RIGHT_FLAG],
+ ['flip', WRAP_FLIP_FLAG],
+ ['partial', WRAP_PARTIAL_FLAG],
+ ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
+ ['rearg', WRAP_REARG_FLAG]
+ ];
+
/** `Object#toString` result references. */
var argsTag = '[object Arguments]',
arrayTag = '[object Array]',
+ asyncTag = '[object AsyncFunction]',
boolTag = '[object Boolean]',
dateTag = '[object Date]',
+ domExcTag = '[object DOMException]',
errorTag = '[object Error]',
funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
mapTag = '[object Map]',
numberTag = '[object Number]',
+ nullTag = '[object Null]',
objectTag = '[object Object]',
promiseTag = '[object Promise]',
+ proxyTag = '[object Proxy]',
regexpTag = '[object RegExp]',
setTag = '[object Set]',
stringTag = '[object String]',
symbolTag = '[object Symbol]',
+ undefinedTag = '[object Undefined]',
weakMapTag = '[object WeakMap]',
weakSetTag = '[object WeakSet]';
@@ -32473,8 +34010,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
/** Used to match HTML entities and HTML characters. */
- var reEscapedHtml = /&(?:amp|lt|gt|quot|#39|#96);/g,
- reUnescapedHtml = /[&<>"'`]/g,
+ var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g,
+ reUnescapedHtml = /[&<>"']/g,
reHasEscapedHtml = RegExp(reEscapedHtml.source),
reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
@@ -32486,11 +34023,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/,
- rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g;
+ reLeadingDot = /^\./,
+ rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/**
* Used to match `RegExp`
- * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns).
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g,
reHasRegExpChar = RegExp(reRegExpChar.source);
@@ -32500,24 +34038,26 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
reTrimStart = /^\s+/,
reTrimEnd = /\s+$/;
- /** Used to match non-compound words composed of alphanumeric characters. */
- var reBasicWord = /[a-zA-Z0-9]+/g;
+ /** Used to match wrap detail comments. */
+ var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
+ reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
+ reSplitDetails = /,? & /;
+
+ /** Used to match words composed of alphanumeric characters. */
+ var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
/**
* Used to match
- * [ES template delimiters](http://ecma-international.org/ecma-262/6.0/#sec-template-literal-lexical-components).
+ * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
*/
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
/** Used to match `RegExp` flags from their coerced string values. */
var reFlags = /\w*$/;
- /** Used to detect hexadecimal string values. */
- var reHasHexPrefix = /^0x/i;
-
/** Used to detect bad signed hexadecimal string values. */
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
@@ -32533,8 +34073,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/** Used to detect unsigned integer values. */
var reIsUint = /^(?:0|[1-9]\d*)$/;
- /** Used to match latin-1 supplementary letters (excluding mathematical operators). */
- var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g;
+ /** Used to match Latin Unicode letters (excluding mathematical operators). */
+ var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
/** Used to ensure capturing order of template delimiters. */
var reNoMatch = /($^)/;
@@ -32544,8 +34084,10 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
- rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
- rsComboSymbolsRange = '\\u20d0-\\u20f0',
+ rsComboMarksRange = '\\u0300-\\u036f',
+ reComboHalfMarksRange = '\\ufe20-\\ufe2f',
+ rsComboSymbolsRange = '\\u20d0-\\u20ff',
+ rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange,
rsDingbatRange = '\\u2700-\\u27bf',
rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
rsMathOpRange = '\\xac\\xb1\\xd7\\xf7',
@@ -32560,7 +34102,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var rsApos = "['\u2019]",
rsAstral = '[' + rsAstralRange + ']',
rsBreak = '[' + rsBreakRange + ']',
- rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
+ rsCombo = '[' + rsComboRange + ']',
rsDigits = '\\d+',
rsDingbat = '[' + rsDingbatRange + ']',
rsLower = '[' + rsLowerRange + ']',
@@ -32574,13 +34116,15 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
rsZWJ = '\\u200d';
/** Used to compose unicode regexes. */
- var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
- rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
- rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
- rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
+ var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')',
+ rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')',
+ rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
+ rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
reOptMod = rsModifier + '?',
rsOptVar = '[' + rsVarRange + ']?',
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
+ rsOrdLower = '\\d*(?:(?:1st|2nd|3rd|(?![123])\\dth)\\b)',
+ rsOrdUpper = '\\d*(?:(?:1ST|2ND|3RD|(?![123])\\dTH)\\b)',
rsSeq = rsOptVar + reOptMod + rsOptJoin,
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq,
rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
@@ -32595,31 +34139,33 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var reComboMark = RegExp(rsCombo, 'g');
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
- var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
+ var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
/** Used to match complex or compound words. */
- var reComplexWord = RegExp([
- rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
- rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
- rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
- rsUpper + '+' + rsOptUpperContr,
+ var reUnicodeWord = RegExp([
+ rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
+ rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')',
+ rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower,
+ rsUpper + '+' + rsOptContrUpper,
+ rsOrdUpper,
+ rsOrdLower,
rsDigits,
rsEmoji
].join('|'), 'g');
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
- var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
+ var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
/** Used to detect strings that need a more robust regexp to match words. */
- var reHasComplexWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
+ var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
/** Used to assign default `context` object properties. */
var contextProps = [
'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array',
'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object',
- 'Promise', 'Reflect', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError',
- 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
- '_', 'isFinite', 'parseInt', 'setTimeout'
+ 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array',
+ 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap',
+ '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout'
];
/** Used to make template sourceURLs easier to identify. */
@@ -32657,16 +34203,17 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
cloneableTags[errorTag] = cloneableTags[funcTag] =
cloneableTags[weakMapTag] = false;
- /** Used to map latin-1 supplementary letters to basic latin letters. */
+ /** Used to map Latin Unicode letters to basic Latin letters. */
var deburredLetters = {
+ // Latin-1 Supplement block.
'\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A',
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
'\xc7': 'C', '\xe7': 'c',
'\xd0': 'D', '\xf0': 'd',
'\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E',
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
- '\xcC': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
- '\xeC': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
+ '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I',
+ '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
'\xd1': 'N', '\xf1': 'n',
'\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O',
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
@@ -32675,7 +34222,43 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
'\xdd': 'Y', '\xfd': 'y', '\xff': 'y',
'\xc6': 'Ae', '\xe6': 'ae',
'\xde': 'Th', '\xfe': 'th',
- '\xdf': 'ss'
+ '\xdf': 'ss',
+ // Latin Extended-A block.
+ '\u0100': 'A', '\u0102': 'A', '\u0104': 'A',
+ '\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
+ '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C',
+ '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
+ '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd',
+ '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E',
+ '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
+ '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G',
+ '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
+ '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h',
+ '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I',
+ '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
+ '\u0134': 'J', '\u0135': 'j',
+ '\u0136': 'K', '\u0137': 'k', '\u0138': 'k',
+ '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L',
+ '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
+ '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N',
+ '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
+ '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
+ '\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
+ '\u0154': 'R', '\u0156': 'R', '\u0158': 'R',
+ '\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
+ '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S',
+ '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
+ '\u0162': 'T', '\u0164': 'T', '\u0166': 'T',
+ '\u0163': 't', '\u0165': 't', '\u0167': 't',
+ '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U',
+ '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
+ '\u0174': 'W', '\u0175': 'w',
+ '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y',
+ '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z',
+ '\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
+ '\u0132': 'IJ', '\u0133': 'ij',
+ '\u0152': 'Oe', '\u0153': 'oe',
+ '\u0149': "'n", '\u017f': 's'
};
/** Used to map characters to HTML entities. */
@@ -32684,8 +34267,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
- "'": '&#39;',
- '`': '&#96;'
+ "'": '&#39;'
};
/** Used to map HTML entities to characters. */
@@ -32694,8 +34276,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
'&lt;': '<',
'&gt;': '>',
'&quot;': '"',
- '&#39;': "'",
- '&#96;': '`'
+ '&#39;': "'"
};
/** Used to escape characters for inclusion in compiled string literals. */
@@ -32712,26 +34293,41 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var freeParseFloat = parseFloat,
freeParseInt = parseInt;
+ /** Detect free variable `global` from Node.js. */
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+
+ /** Detect free variable `self`. */
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+ /** Used as a reference to the global object. */
+ var root = freeGlobal || freeSelf || Function('return this')();
+
/** Detect free variable `exports`. */
- var freeExports = typeof exports == 'object' && exports;
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
- var freeModule = freeExports && typeof module == 'object' && module;
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports;
- /** Detect free variable `global` from Node.js. */
- var freeGlobal = checkGlobal(typeof global == 'object' && global);
+ /** Detect free variable `process` from Node.js. */
+ var freeProcess = moduleExports && freeGlobal.process;
- /** Detect free variable `self`. */
- var freeSelf = checkGlobal(typeof self == 'object' && self);
-
- /** Detect `this` as the global object. */
- var thisGlobal = checkGlobal(typeof this == 'object' && this);
+ /** Used to access faster Node.js helpers. */
+ var nodeUtil = (function() {
+ try {
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
+ } catch (e) {}
+ }());
- /** Used as a reference to the global object. */
- var root = freeGlobal || freeSelf || thisGlobal || Function('return this')();
+ /* Node.js helper references. */
+ var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer,
+ nodeIsDate = nodeUtil && nodeUtil.isDate,
+ nodeIsMap = nodeUtil && nodeUtil.isMap,
+ nodeIsRegExp = nodeUtil && nodeUtil.isRegExp,
+ nodeIsSet = nodeUtil && nodeUtil.isSet,
+ nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
/*--------------------------------------------------------------------------*/
@@ -32744,7 +34340,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Object} Returns `map`.
*/
function addMapEntry(map, pair) {
- // Don't return `Map#set` because it doesn't return the map instance in IE 11.
+ // Don't return `map.set` because it's not chainable in IE 11.
map.set(pair[0], pair[1]);
return map;
}
@@ -32758,6 +34354,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Object} Returns `set`.
*/
function addSetEntry(set, value) {
+ // Don't return `set.add` because it's not chainable in IE 11.
set.add(value);
return set;
}
@@ -32773,8 +34370,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
- var length = args.length;
- switch (length) {
+ switch (args.length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
@@ -32795,7 +34391,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function arrayAggregator(array, setter, iteratee, accumulator) {
var index = -1,
- length = array ? array.length : 0;
+ length = array == null ? 0 : array.length;
while (++index < length) {
var value = array[index];
@@ -32815,7 +34411,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function arrayEach(array, iteratee) {
var index = -1,
- length = array ? array.length : 0;
+ length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {
@@ -32835,7 +34431,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Array} Returns `array`.
*/
function arrayEachRight(array, iteratee) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
while (length--) {
if (iteratee(array[length], length, array) === false) {
@@ -32857,7 +34453,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function arrayEvery(array, predicate) {
var index = -1,
- length = array ? array.length : 0;
+ length = array == null ? 0 : array.length;
while (++index < length) {
if (!predicate(array[index], index, array)) {
@@ -32878,7 +34474,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function arrayFilter(array, predicate) {
var index = -1,
- length = array ? array.length : 0,
+ length = array == null ? 0 : array.length,
resIndex = 0,
result = [];
@@ -32896,12 +34492,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* specifying an index to search from.
*
* @private
- * @param {Array} [array] The array to search.
+ * @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludes(array, value) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
return !!length && baseIndexOf(array, value, 0) > -1;
}
@@ -32909,14 +34505,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* This function is like `arrayIncludes` except that it accepts a comparator.
*
* @private
- * @param {Array} [array] The array to search.
+ * @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @param {Function} comparator The comparator invoked per element.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludesWith(array, value, comparator) {
var index = -1,
- length = array ? array.length : 0;
+ length = array == null ? 0 : array.length;
while (++index < length) {
if (comparator(value, array[index])) {
@@ -32937,7 +34533,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function arrayMap(array, iteratee) {
var index = -1,
- length = array ? array.length : 0,
+ length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {
@@ -32979,7 +34575,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function arrayReduce(array, iteratee, accumulator, initAccum) {
var index = -1,
- length = array ? array.length : 0;
+ length = array == null ? 0 : array.length;
if (initAccum && length) {
accumulator = array[++index];
@@ -33003,7 +34599,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {*} Returns the accumulated value.
*/
function arrayReduceRight(array, iteratee, accumulator, initAccum) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (initAccum && length) {
accumulator = array[--length];
}
@@ -33025,7 +34621,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function arraySome(array, predicate) {
var index = -1,
- length = array ? array.length : 0;
+ length = array == null ? 0 : array.length;
while (++index < length) {
if (predicate(array[index], index, array)) {
@@ -33036,12 +34632,43 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * Gets the size of an ASCII `string`.
+ *
+ * @private
+ * @param {string} string The string inspect.
+ * @returns {number} Returns the string size.
+ */
+ var asciiSize = baseProperty('length');
+
+ /**
+ * Converts an ASCII `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+ function asciiToArray(string) {
+ return string.split('');
+ }
+
+ /**
+ * Splits an ASCII `string` into an array of its words.
+ *
+ * @private
+ * @param {string} The string to inspect.
+ * @returns {Array} Returns the words of `string`.
+ */
+ function asciiWords(string) {
+ return string.match(reAsciiWord) || [];
+ }
+
+ /**
* The base implementation of methods like `_.findKey` and `_.findLastKey`,
* without support for iteratee shorthands, which iterates over `collection`
* using `eachFunc`.
*
* @private
- * @param {Array|Object} collection The collection to search.
+ * @param {Array|Object} collection The collection to inspect.
* @param {Function} predicate The function invoked per iteration.
* @param {Function} eachFunc The function to iterate over `collection`.
* @returns {*} Returns the found element or its key, else `undefined`.
@@ -33062,7 +34689,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* support for iteratee shorthands.
*
* @private
- * @param {Array} array The array to search.
+ * @param {Array} array The array to inspect.
* @param {Function} predicate The function invoked per iteration.
* @param {number} fromIndex The index to search from.
* @param {boolean} [fromRight] Specify iterating from right to left.
@@ -33084,31 +34711,22 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
*
* @private
- * @param {Array} array The array to search.
+ * @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseIndexOf(array, value, fromIndex) {
- if (value !== value) {
- return indexOfNaN(array, fromIndex);
- }
- var index = fromIndex - 1,
- length = array.length;
-
- while (++index < length) {
- if (array[index] === value) {
- return index;
- }
- }
- return -1;
+ return value === value
+ ? strictIndexOf(array, value, fromIndex)
+ : baseFindIndex(array, baseIsNaN, fromIndex);
}
/**
* This function is like `baseIndexOf` except that it accepts a comparator.
*
* @private
- * @param {Array} array The array to search.
+ * @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @param {Function} comparator The comparator invoked per element.
@@ -33127,6 +34745,17 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * The base implementation of `_.isNaN` without support for number objects.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
+ */
+ function baseIsNaN(value) {
+ return value !== value;
+ }
+
+ /**
* The base implementation of `_.mean` and `_.meanBy` without support for
* iteratee shorthands.
*
@@ -33136,11 +34765,37 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {number} Returns the mean.
*/
function baseMean(array, iteratee) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
return length ? (baseSum(array, iteratee) / length) : NAN;
}
/**
+ * The base implementation of `_.property` without support for deep paths.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+ function baseProperty(key) {
+ return function(object) {
+ return object == null ? undefined : object[key];
+ };
+ }
+
+ /**
+ * The base implementation of `_.propertyOf` without support for deep paths.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Function} Returns the new accessor function.
+ */
+ function basePropertyOf(object) {
+ return function(key) {
+ return object == null ? undefined : object[key];
+ };
+ }
+
+ /**
* The base implementation of `_.reduce` and `_.reduceRight`, without support
* for iteratee shorthands, which iterates over `collection` using `eachFunc`.
*
@@ -33240,7 +34895,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * The base implementation of `_.unary` without support for storing wrapper metadata.
+ * The base implementation of `_.unary` without support for storing metadata.
*
* @private
* @param {Function} func The function to cap arguments for.
@@ -33269,7 +34924,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * Checks if a cache value for `key` exists.
+ * Checks if a `cache` value for `key` exists.
*
* @private
* @param {Object} cache The cache to query.
@@ -33314,17 +34969,6 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * Checks if `value` is a global object.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {null|Object} Returns `value` if it's a global object, else `null`.
- */
- function checkGlobal(value) {
- return (value && value.Object === Object) ? value : null;
- }
-
- /**
* Gets the number of `placeholder` occurrences in `array`.
*
* @private
@@ -33338,22 +34982,21 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
while (length--) {
if (array[length] === placeholder) {
- result++;
+ ++result;
}
}
return result;
}
/**
- * Used by `_.deburr` to convert latin-1 supplementary letters to basic latin letters.
+ * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A
+ * letters to basic Latin letters.
*
* @private
* @param {string} letter The matched letter to deburr.
* @returns {string} Returns the deburred letter.
*/
- function deburrLetter(letter) {
- return deburredLetters[letter];
- }
+ var deburrLetter = basePropertyOf(deburredLetters);
/**
* Used by `_.escape` to convert characters to HTML entities.
@@ -33362,9 +35005,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {string} chr The matched character to escape.
* @returns {string} Returns the escaped character.
*/
- function escapeHtmlChar(chr) {
- return htmlEscapes[chr];
- }
+ var escapeHtmlChar = basePropertyOf(htmlEscapes);
/**
* Used by `_.template` to escape characters for inclusion in compiled string literals.
@@ -33390,44 +35031,25 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * Gets the index at which the first occurrence of `NaN` is found in `array`.
+ * Checks if `string` contains Unicode symbols.
*
* @private
- * @param {Array} array The array to search.
- * @param {number} fromIndex The index to search from.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {number} Returns the index of the matched `NaN`, else `-1`.
+ * @param {string} string The string to inspect.
+ * @returns {boolean} Returns `true` if a symbol is found, else `false`.
*/
- function indexOfNaN(array, fromIndex, fromRight) {
- var length = array.length,
- index = fromIndex + (fromRight ? 1 : -1);
-
- while ((fromRight ? index-- : ++index < length)) {
- var other = array[index];
- if (other !== other) {
- return index;
- }
- }
- return -1;
+ function hasUnicode(string) {
+ return reHasUnicode.test(string);
}
/**
- * Checks if `value` is a host object in IE < 9.
+ * Checks if `string` contains a word composed of Unicode symbols.
*
* @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
+ * @param {string} string The string to inspect.
+ * @returns {boolean} Returns `true` if a word is found, else `false`.
*/
- function isHostObject(value) {
- // Many host objects are `Object` objects that can coerce to strings
- // despite having improperly defined `toString` methods.
- var result = false;
- if (value != null && typeof value.toString != 'function') {
- try {
- result = !!(value + '');
- } catch (e) {}
- }
- return result;
+ function hasUnicodeWord(string) {
+ return reHasUnicodeWord.test(string);
}
/**
@@ -33465,6 +35087,20 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * Creates a unary function that invokes `func` with its argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+ function overArg(func, transform) {
+ return function(arg) {
+ return func(transform(arg));
+ };
+ }
+
+ /**
* Replaces all `placeholder` elements in `array` with an internal placeholder
* and returns an array of their indexes.
*
@@ -33524,6 +35160,48 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * A specialized version of `_.indexOf` which performs strict equality
+ * comparisons of values, i.e. `===`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+ function strictIndexOf(array, value, fromIndex) {
+ var index = fromIndex - 1,
+ length = array.length;
+
+ while (++index < length) {
+ if (array[index] === value) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * A specialized version of `_.lastIndexOf` which performs strict equality
+ * comparisons of values, i.e. `===`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+ function strictLastIndexOf(array, value, fromIndex) {
+ var index = fromIndex + 1;
+ while (index--) {
+ if (array[index] === value) {
+ return index;
+ }
+ }
+ return index;
+ }
+
+ /**
* Gets the number of symbols in `string`.
*
* @private
@@ -33531,14 +35209,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {number} Returns the string size.
*/
function stringSize(string) {
- if (!(string && reHasComplexSymbol.test(string))) {
- return string.length;
- }
- var result = reComplexSymbol.lastIndex = 0;
- while (reComplexSymbol.test(string)) {
- result++;
- }
- return result;
+ return hasUnicode(string)
+ ? unicodeSize(string)
+ : asciiSize(string);
}
/**
@@ -33549,7 +35222,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Array} Returns the converted array.
*/
function stringToArray(string) {
- return string.match(reComplexSymbol);
+ return hasUnicode(string)
+ ? unicodeToArray(string)
+ : asciiToArray(string);
}
/**
@@ -33559,8 +35234,43 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {string} chr The matched character to unescape.
* @returns {string} Returns the unescaped character.
*/
- function unescapeHtmlChar(chr) {
- return htmlUnescapes[chr];
+ var unescapeHtmlChar = basePropertyOf(htmlUnescapes);
+
+ /**
+ * Gets the size of a Unicode `string`.
+ *
+ * @private
+ * @param {string} string The string inspect.
+ * @returns {number} Returns the string size.
+ */
+ function unicodeSize(string) {
+ var result = reUnicode.lastIndex = 0;
+ while (reUnicode.test(string)) {
+ ++result;
+ }
+ return result;
+ }
+
+ /**
+ * Converts a Unicode `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+ function unicodeToArray(string) {
+ return string.match(reUnicode) || [];
+ }
+
+ /**
+ * Splits a Unicode `string` into an array of its words.
+ *
+ * @private
+ * @param {string} The string to inspect.
+ * @returns {Array} Returns the words of `string`.
+ */
+ function unicodeWords(string) {
+ return string.match(reUnicodeWord) || [];
}
/*--------------------------------------------------------------------------*/
@@ -33591,42 +35301,33 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* lodash.isFunction(lodash.bar);
* // => true
*
- * // Use `context` to stub `Date#getTime` use in `_.now`.
- * var stubbed = _.runInContext({
- * 'Date': function() {
- * return { 'getTime': stubGetTime };
- * }
- * });
- *
* // Create a suped-up `defer` in Node.js.
* var defer = _.runInContext({ 'setTimeout': setImmediate }).defer;
*/
- function runInContext(context) {
- context = context ? _.defaults({}, context, _.pick(root, contextProps)) : root;
+ var runInContext = (function runInContext(context) {
+ context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps));
/** Built-in constructor references. */
- var Date = context.Date,
+ var Array = context.Array,
+ Date = context.Date,
Error = context.Error,
+ Function = context.Function,
Math = context.Math,
+ Object = context.Object,
RegExp = context.RegExp,
+ String = context.String,
TypeError = context.TypeError;
/** Used for built-in method references. */
- var arrayProto = context.Array.prototype,
- objectProto = context.Object.prototype,
- stringProto = context.String.prototype;
+ var arrayProto = Array.prototype,
+ funcProto = Function.prototype,
+ objectProto = Object.prototype;
/** Used to detect overreaching core-js shims. */
var coreJsData = context['__core-js_shared__'];
- /** Used to detect methods masquerading as native. */
- var maskSrcKey = (function() {
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
- return uid ? ('Symbol(src)_1.' + uid) : '';
- }());
-
/** Used to resolve the decompiled source of functions. */
- var funcToString = context.Function.prototype.toString;
+ var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
@@ -33634,15 +35335,21 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/** Used to generate unique IDs. */
var idCounter = 0;
- /** Used to infer the `Object` constructor. */
- var objectCtorString = funcToString.call(Object);
+ /** Used to detect methods masquerading as native. */
+ var maskSrcKey = (function() {
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
+ return uid ? ('Symbol(src)_1.' + uid) : '';
+ }());
/**
* Used to resolve the
- * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
- var objectToString = objectProto.toString;
+ var nativeObjectToString = objectProto.toString;
+
+ /** Used to infer the `Object` constructor. */
+ var objectCtorString = funcToString.call(Object);
/** Used to restore the original `_` reference in `_.noConflict`. */
var oldDash = root._;
@@ -33655,33 +35362,44 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/** Built-in value references. */
var Buffer = moduleExports ? context.Buffer : undefined,
- Reflect = context.Reflect,
Symbol = context.Symbol,
Uint8Array = context.Uint8Array,
- enumerate = Reflect ? Reflect.enumerate : undefined,
- getOwnPropertySymbols = Object.getOwnPropertySymbols,
- iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined,
+ allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
+ getPrototype = overArg(Object.getPrototypeOf, Object),
objectCreate = Object.create,
propertyIsEnumerable = objectProto.propertyIsEnumerable,
- splice = arrayProto.splice;
+ splice = arrayProto.splice,
+ spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined,
+ symIterator = Symbol ? Symbol.iterator : undefined,
+ symToStringTag = Symbol ? Symbol.toStringTag : undefined;
- /** Built-in method references that are mockable. */
- var setTimeout = function(func, wait) { return context.setTimeout.call(root, func, wait); };
+ var defineProperty = (function() {
+ try {
+ var func = getNative(Object, 'defineProperty');
+ func({}, '', {});
+ return func;
+ } catch (e) {}
+ }());
+
+ /** Mocked built-ins. */
+ var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout,
+ ctxNow = Date && Date.now !== root.Date.now && Date.now,
+ ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeCeil = Math.ceil,
nativeFloor = Math.floor,
- nativeGetPrototype = Object.getPrototypeOf,
+ nativeGetSymbols = Object.getOwnPropertySymbols,
+ nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
nativeIsFinite = context.isFinite,
nativeJoin = arrayProto.join,
- nativeKeys = Object.keys,
+ nativeKeys = overArg(Object.keys, Object),
nativeMax = Math.max,
nativeMin = Math.min,
+ nativeNow = Date.now,
nativeParseInt = context.parseInt,
nativeRandom = Math.random,
- nativeReplace = stringProto.replace,
- nativeReverse = arrayProto.reverse,
- nativeSplit = stringProto.split;
+ nativeReverse = arrayProto.reverse;
/* Built-in method references that are verified to be native. */
var DataView = getNative(context, 'DataView'),
@@ -33694,9 +35412,6 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/** Used to store function metadata. */
var metaMap = WeakMap && new WeakMap;
- /** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
- var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf');
-
/** Used to lookup unminified function names. */
var realNames = {};
@@ -33732,9 +35447,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* Shortcut fusion is an optimization to merge iteratee calls; this avoids
* the creation of intermediate arrays and can greatly reduce the number of
* iteratee executions. Sections of a chain sequence qualify for shortcut
- * fusion if the section is applied to an array of at least `200` elements
- * and any iteratees accept only one argument. The heuristic for whether a
- * section qualifies for shortcut fusion is subject to change.
+ * fusion if the section is applied to an array and iteratees accept only
+ * one argument. The heuristic for whether a section qualifies for shortcut
+ * fusion is subject to change.
*
* Chaining is supported in custom builds as long as the `_#value` method is
* directly or indirectly included in the build.
@@ -33780,16 +35495,16 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* The wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
- * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `divide`, `each`,
- * `eachRight`, `endsWith`, `eq`, `escape`, `escapeRegExp`, `every`, `find`,
- * `findIndex`, `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `first`,
- * `floor`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`,
- * `forOwnRight`, `get`, `gt`, `gte`, `has`, `hasIn`, `head`, `identity`,
- * `includes`, `indexOf`, `inRange`, `invoke`, `isArguments`, `isArray`,
- * `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`,
- * `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`,
- * `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMap`,
- * `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
+ * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
+ * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
+ * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
+ * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
+ * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
+ * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
+ * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
+ * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
+ * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
+ * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
* `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
* `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
* `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
@@ -33844,6 +35559,30 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * The base implementation of `_.create` without support for assigning
+ * properties to the created object.
+ *
+ * @private
+ * @param {Object} proto The object to inherit from.
+ * @returns {Object} Returns the new object.
+ */
+ var baseCreate = (function() {
+ function object() {}
+ return function(proto) {
+ if (!isObject(proto)) {
+ return {};
+ }
+ if (objectCreate) {
+ return objectCreate(proto);
+ }
+ object.prototype = proto;
+ var result = new object;
+ object.prototype = undefined;
+ return result;
+ };
+ }());
+
+ /**
* The function whose prototype chain sequence wrappers inherit from.
*
* @private
@@ -33869,8 +35608,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* By default, the template delimiters used by lodash are like those in
- * embedded Ruby (ERB). Change the following template settings to use
- * alternative delimiters.
+ * embedded Ruby (ERB) as well as ES2015 template strings. Change the
+ * following template settings to use alternative delimiters.
*
* @static
* @memberOf _
@@ -34017,8 +35756,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
resIndex = 0,
takeCount = nativeMin(length, this.__takeCount__);
- if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
- (arrLength == length && takeCount == length)) {
+ if (!isArr || (!isRight && arrLength == length && takeCount == length)) {
return baseWrapperValue(array, this.__actions__);
}
var result = [];
@@ -34066,7 +35804,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function Hash(entries) {
var index = -1,
- length = entries ? entries.length : 0;
+ length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
@@ -34084,6 +35822,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
+ this.size = 0;
}
/**
@@ -34097,7 +35836,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function hashDelete(key) {
- return this.has(key) && delete this.__data__[key];
+ var result = this.has(key) && delete this.__data__[key];
+ this.size -= result ? 1 : 0;
+ return result;
}
/**
@@ -34129,7 +35870,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function hashHas(key) {
var data = this.__data__;
- return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
+ return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
}
/**
@@ -34144,6 +35885,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function hashSet(key, value) {
var data = this.__data__;
+ this.size += this.has(key) ? 0 : 1;
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
return this;
}
@@ -34166,7 +35908,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function ListCache(entries) {
var index = -1,
- length = entries ? entries.length : 0;
+ length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
@@ -34184,6 +35926,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function listCacheClear() {
this.__data__ = [];
+ this.size = 0;
}
/**
@@ -34208,6 +35951,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
} else {
splice.call(data, index, 1);
}
+ --this.size;
return true;
}
@@ -34255,6 +35999,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
index = assocIndexOf(data, key);
if (index < 0) {
+ ++this.size;
data.push([key, value]);
} else {
data[index][1] = value;
@@ -34280,7 +36025,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function MapCache(entries) {
var index = -1,
- length = entries ? entries.length : 0;
+ length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
@@ -34297,6 +36042,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf MapCache
*/
function mapCacheClear() {
+ this.size = 0;
this.__data__ = {
'hash': new Hash,
'map': new (Map || ListCache),
@@ -34314,7 +36060,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
- return getMapData(this, key)['delete'](key);
+ var result = getMapData(this, key)['delete'](key);
+ this.size -= result ? 1 : 0;
+ return result;
}
/**
@@ -34354,7 +36102,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
- getMapData(this, key).set(key, value);
+ var data = getMapData(this, key),
+ size = data.size;
+
+ data.set(key, value);
+ this.size += data.size == size ? 0 : 1;
return this;
}
@@ -34377,7 +36129,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function SetCache(values) {
var index = -1,
- length = values ? values.length : 0;
+ length = values == null ? 0 : values.length;
this.__data__ = new MapCache;
while (++index < length) {
@@ -34427,7 +36179,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {Array} [entries] The key-value pairs to cache.
*/
function Stack(entries) {
- this.__data__ = new ListCache(entries);
+ var data = this.__data__ = new ListCache(entries);
+ this.size = data.size;
}
/**
@@ -34439,6 +36192,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function stackClear() {
this.__data__ = new ListCache;
+ this.size = 0;
}
/**
@@ -34451,7 +36205,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function stackDelete(key) {
- return this.__data__['delete'](key);
+ var data = this.__data__,
+ result = data['delete'](key);
+
+ this.size = data.size;
+ return result;
}
/**
@@ -34491,11 +36249,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Object} Returns the stack cache instance.
*/
function stackSet(key, value) {
- var cache = this.__data__;
- if (cache instanceof ListCache && cache.__data__.length == LARGE_ARRAY_SIZE) {
- cache = this.__data__ = new MapCache(cache.__data__);
+ var data = this.__data__;
+ if (data instanceof ListCache) {
+ var pairs = data.__data__;
+ if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
+ pairs.push([key, value]);
+ this.size = ++data.size;
+ return this;
+ }
+ data = this.__data__ = new MapCache(pairs);
}
- cache.set(key, value);
+ data.set(key, value);
+ this.size = data.size;
return this;
}
@@ -34509,21 +36274,73 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/*------------------------------------------------------------------------*/
/**
- * Used by `_.defaults` to customize its `_.assignIn` use.
+ * Creates an array of the enumerable property names of the array-like `value`.
*
* @private
- * @param {*} objValue The destination value.
- * @param {*} srcValue The source value.
- * @param {string} key The key of the property to assign.
- * @param {Object} object The parent object of `objValue`.
- * @returns {*} Returns the value to assign.
+ * @param {*} value The value to query.
+ * @param {boolean} inherited Specify returning inherited property names.
+ * @returns {Array} Returns the array of property names.
*/
- function assignInDefaults(objValue, srcValue, key, object) {
- if (objValue === undefined ||
- (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
- return srcValue;
+ function arrayLikeKeys(value, inherited) {
+ var isArr = isArray(value),
+ isArg = !isArr && isArguments(value),
+ isBuff = !isArr && !isArg && isBuffer(value),
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
+ skipIndexes = isArr || isArg || isBuff || isType,
+ result = skipIndexes ? baseTimes(value.length, String) : [],
+ length = result.length;
+
+ for (var key in value) {
+ if ((inherited || hasOwnProperty.call(value, key)) &&
+ !(skipIndexes && (
+ // Safari 9 has enumerable `arguments.length` in strict mode.
+ key == 'length' ||
+ // Node.js 0.10 has enumerable non-index properties on buffers.
+ (isBuff && (key == 'offset' || key == 'parent')) ||
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
+ // Skip index properties.
+ isIndex(key, length)
+ ))) {
+ result.push(key);
+ }
}
- return objValue;
+ return result;
+ }
+
+ /**
+ * A specialized version of `_.sample` for arrays.
+ *
+ * @private
+ * @param {Array} array The array to sample.
+ * @returns {*} Returns the random element.
+ */
+ function arraySample(array) {
+ var length = array.length;
+ return length ? array[baseRandom(0, length - 1)] : undefined;
+ }
+
+ /**
+ * A specialized version of `_.sampleSize` for arrays.
+ *
+ * @private
+ * @param {Array} array The array to sample.
+ * @param {number} n The number of elements to sample.
+ * @returns {Array} Returns the random elements.
+ */
+ function arraySampleSize(array, n) {
+ return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length));
+ }
+
+ /**
+ * A specialized version of `_.shuffle` for arrays.
+ *
+ * @private
+ * @param {Array} array The array to shuffle.
+ * @returns {Array} Returns the new shuffled array.
+ */
+ function arrayShuffle(array) {
+ return shuffleSelf(copyArray(array));
}
/**
@@ -34537,14 +36354,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function assignMergeValue(object, key, value) {
if ((value !== undefined && !eq(object[key], value)) ||
- (typeof key == 'number' && value === undefined && !(key in object))) {
- object[key] = value;
+ (value === undefined && !(key in object))) {
+ baseAssignValue(object, key, value);
}
}
/**
* Assigns `value` to `key` of `object` if the existing value is not equivalent
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @private
@@ -34556,7 +36373,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var objValue = object[key];
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
(value === undefined && !(key in object))) {
- object[key] = value;
+ baseAssignValue(object, key, value);
}
}
@@ -34564,7 +36381,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
- * @param {Array} array The array to search.
+ * @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
@@ -34610,27 +36427,62 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * The base implementation of `_.assignIn` without support for multiple sources
+ * or `customizer` functions.
+ *
+ * @private
+ * @param {Object} object The destination object.
+ * @param {Object} source The source object.
+ * @returns {Object} Returns `object`.
+ */
+ function baseAssignIn(object, source) {
+ return object && copyObject(source, keysIn(source), object);
+ }
+
+ /**
+ * The base implementation of `assignValue` and `assignMergeValue` without
+ * value checks.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+ function baseAssignValue(object, key, value) {
+ if (key == '__proto__' && defineProperty) {
+ defineProperty(object, key, {
+ 'configurable': true,
+ 'enumerable': true,
+ 'value': value,
+ 'writable': true
+ });
+ } else {
+ object[key] = value;
+ }
+ }
+
+ /**
* The base implementation of `_.at` without support for individual paths.
*
* @private
* @param {Object} object The object to iterate over.
- * @param {string[]} paths The property paths of elements to pick.
+ * @param {string[]} paths The property paths to pick.
* @returns {Array} Returns the picked elements.
*/
function baseAt(object, paths) {
var index = -1,
- isNil = object == null,
length = paths.length,
- result = Array(length);
+ result = Array(length),
+ skip = object == null;
while (++index < length) {
- result[index] = isNil ? undefined : get(object, paths[index]);
+ result[index] = skip ? undefined : get(object, paths[index]);
}
return result;
}
/**
- * The base implementation of `_.clamp` which doesn't coerce arguments to numbers.
+ * The base implementation of `_.clamp` which doesn't coerce arguments.
*
* @private
* @param {number} number The number to clamp.
@@ -34656,16 +36508,22 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {*} value The value to clone.
- * @param {boolean} [isDeep] Specify a deep clone.
- * @param {boolean} [isFull] Specify a clone including symbols.
+ * @param {boolean} bitmask The bitmask flags.
+ * 1 - Deep clone
+ * 2 - Flatten inherited properties
+ * 4 - Clone symbols
* @param {Function} [customizer] The function to customize cloning.
* @param {string} [key] The key of `value`.
* @param {Object} [object] The parent object of `value`.
* @param {Object} [stack] Tracks traversed objects and their clone counterparts.
* @returns {*} Returns the cloned value.
*/
- function baseClone(value, isDeep, isFull, customizer, key, object, stack) {
- var result;
+ function baseClone(value, bitmask, customizer, key, object, stack) {
+ var result,
+ isDeep = bitmask & CLONE_DEEP_FLAG,
+ isFlat = bitmask & CLONE_FLAT_FLAG,
+ isFull = bitmask & CLONE_SYMBOLS_FLAG;
+
if (customizer) {
result = object ? customizer(value, key, object, stack) : customizer(value);
}
@@ -34689,12 +36547,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
return cloneBuffer(value, isDeep);
}
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
- if (isHostObject(value)) {
- return object ? value : {};
- }
- result = initCloneObject(isFunc ? {} : value);
+ result = (isFlat || isFunc) ? {} : initCloneObject(value);
if (!isDeep) {
- return copySymbols(value, baseAssign(result, value));
+ return isFlat
+ ? copySymbolsIn(value, baseAssignIn(result, value))
+ : copySymbols(value, baseAssign(result, value));
}
} else {
if (!cloneableTags[tag]) {
@@ -34711,16 +36568,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
stack.set(value, result);
- if (!isArr) {
- var props = isFull ? getAllKeys(value) : keys(value);
- }
- // Recursively populate clone (susceptible to call stack limits).
+ var keysFunc = isFull
+ ? (isFlat ? getAllKeysIn : getAllKeys)
+ : (isFlat ? keysIn : keys);
+
+ var props = isArr ? undefined : keysFunc(value);
arrayEach(props || value, function(subValue, key) {
if (props) {
key = subValue;
subValue = value[key];
}
- assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack));
+ // Recursively populate clone (susceptible to call stack limits).
+ assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
});
return result;
}
@@ -34733,49 +36592,47 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Function} Returns the new spec function.
*/
function baseConforms(source) {
- var props = keys(source),
- length = props.length;
-
+ var props = keys(source);
return function(object) {
- if (object == null) {
- return !length;
- }
- var index = length;
- while (index--) {
- var key = props[index],
- predicate = source[key],
- value = object[key];
-
- if ((value === undefined &&
- !(key in Object(object))) || !predicate(value)) {
- return false;
- }
- }
- return true;
+ return baseConformsTo(object, source, props);
};
}
/**
- * The base implementation of `_.create` without support for assigning
- * properties to the created object.
+ * The base implementation of `_.conformsTo` which accepts `props` to check.
*
* @private
- * @param {Object} prototype The object to inherit from.
- * @returns {Object} Returns the new object.
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property predicates to conform to.
+ * @returns {boolean} Returns `true` if `object` conforms, else `false`.
*/
- function baseCreate(proto) {
- return isObject(proto) ? objectCreate(proto) : {};
+ function baseConformsTo(object, source, props) {
+ var length = props.length;
+ if (object == null) {
+ return !length;
+ }
+ object = Object(object);
+ while (length--) {
+ var key = props[length],
+ predicate = source[key],
+ value = object[key];
+
+ if ((value === undefined && !(key in object)) || !predicate(value)) {
+ return false;
+ }
+ }
+ return true;
}
/**
- * The base implementation of `_.delay` and `_.defer` which accepts an array
- * of `func` arguments.
+ * The base implementation of `_.delay` and `_.defer` which accepts `args`
+ * to provide to `func`.
*
* @private
* @param {Function} func The function to delay.
* @param {number} wait The number of milliseconds to delay invocation.
- * @param {Object} args The arguments to provide to `func`.
- * @returns {number} Returns the timer id.
+ * @param {Array} args The arguments to provide to `func`.
+ * @returns {number|Object} Returns the timer id or timeout object.
*/
function baseDelay(func, wait, args) {
if (typeof func != 'function') {
@@ -34821,7 +36678,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
outer:
while (++index < length) {
var value = array[index],
- computed = iteratee ? iteratee(value) : value;
+ computed = iteratee == null ? value : iteratee(value);
value = (comparator || value !== 0) ? value : 0;
if (isCommon && computed === computed) {
@@ -35060,7 +36917,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
- path = isKey(path, object) ? [path] : castPath(path);
+ path = castPath(path, object);
var index = 0,
length = path.length;
@@ -35088,7 +36945,23 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * The base implementation of `_.gt` which doesn't coerce arguments to numbers.
+ * The base implementation of `getTag` without fallbacks for buggy environments.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the `toStringTag`.
+ */
+ function baseGetTag(value) {
+ if (value == null) {
+ return value === undefined ? undefinedTag : nullTag;
+ }
+ return (symToStringTag && symToStringTag in Object(value))
+ ? getRawTag(value)
+ : objectToString(value);
+ }
+
+ /**
+ * The base implementation of `_.gt` which doesn't coerce arguments.
*
* @private
* @param {*} value The value to compare.
@@ -35109,12 +36982,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {boolean} Returns `true` if `key` exists, else `false`.
*/
function baseHas(object, key) {
- // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`,
- // that are composed entirely of index properties, return `false` for
- // `hasOwnProperty` checks of them.
- return object != null &&
- (hasOwnProperty.call(object, key) ||
- (typeof object == 'object' && key in object && getPrototype(object) === null));
+ return object != null && hasOwnProperty.call(object, key);
}
/**
@@ -35130,7 +36998,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * The base implementation of `_.inRange` which doesn't coerce arguments to numbers.
+ * The base implementation of `_.inRange` which doesn't coerce arguments.
*
* @private
* @param {number} number The number to check.
@@ -35234,38 +37102,67 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {*} Returns the result of the invoked method.
*/
function baseInvoke(object, path, args) {
- if (!isKey(path, object)) {
- path = castPath(path);
- object = parent(object, path);
- path = last(path);
- }
- var func = object == null ? object : object[toKey(path)];
+ path = castPath(path, object);
+ object = parent(object, path);
+ var func = object == null ? object : object[toKey(last(path))];
return func == null ? undefined : apply(func, object, args);
}
/**
+ * The base implementation of `_.isArguments`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ */
+ function baseIsArguments(value) {
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
+ }
+
+ /**
+ * The base implementation of `_.isArrayBuffer` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
+ */
+ function baseIsArrayBuffer(value) {
+ return isObjectLike(value) && baseGetTag(value) == arrayBufferTag;
+ }
+
+ /**
+ * The base implementation of `_.isDate` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
+ */
+ function baseIsDate(value) {
+ return isObjectLike(value) && baseGetTag(value) == dateTag;
+ }
+
+ /**
* The base implementation of `_.isEqual` which supports partial comparisons
* and tracks traversed objects.
*
* @private
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
+ * @param {boolean} bitmask The bitmask flags.
+ * 1 - Unordered comparison
+ * 2 - Partial comparison
* @param {Function} [customizer] The function to customize comparisons.
- * @param {boolean} [bitmask] The bitmask of comparison flags.
- * The bitmask may be composed of the following flags:
- * 1 - Unordered comparison
- * 2 - Partial comparison
* @param {Object} [stack] Tracks traversed `value` and `other` objects.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
*/
- function baseIsEqual(value, other, customizer, bitmask, stack) {
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
if (value === other) {
return true;
}
- if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
+ if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
return value !== value && other !== other;
}
- return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack);
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
}
/**
@@ -35276,38 +37173,39 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @private
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
+ * @param {Function} customizer The function to customize comparisons.
* @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} [customizer] The function to customize comparisons.
- * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
* @param {Object} [stack] Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
- function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) {
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
var objIsArr = isArray(object),
othIsArr = isArray(other),
- objTag = arrayTag,
- othTag = arrayTag;
+ objTag = objIsArr ? arrayTag : getTag(object),
+ othTag = othIsArr ? arrayTag : getTag(other);
- if (!objIsArr) {
- objTag = getTag(object);
- objTag = objTag == argsTag ? objectTag : objTag;
- }
- if (!othIsArr) {
- othTag = getTag(other);
- othTag = othTag == argsTag ? objectTag : othTag;
- }
- var objIsObj = objTag == objectTag && !isHostObject(object),
- othIsObj = othTag == objectTag && !isHostObject(other),
+ objTag = objTag == argsTag ? objectTag : objTag;
+ othTag = othTag == argsTag ? objectTag : othTag;
+
+ var objIsObj = objTag == objectTag,
+ othIsObj = othTag == objectTag,
isSameTag = objTag == othTag;
+ if (isSameTag && isBuffer(object)) {
+ if (!isBuffer(other)) {
+ return false;
+ }
+ objIsArr = true;
+ objIsObj = false;
+ }
if (isSameTag && !objIsObj) {
stack || (stack = new Stack);
return (objIsArr || isTypedArray(object))
- ? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
- : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
+ ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
+ : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
}
- if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
@@ -35316,14 +37214,25 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
othUnwrapped = othIsWrapped ? other.value() : other;
stack || (stack = new Stack);
- return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack);
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
}
}
if (!isSameTag) {
return false;
}
stack || (stack = new Stack);
- return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
+ }
+
+ /**
+ * The base implementation of `_.isMap` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
+ */
+ function baseIsMap(value) {
+ return isObjectLike(value) && getTag(value) == mapTag;
}
/**
@@ -35370,7 +37279,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var result = customizer(objValue, srcValue, key, object, source, stack);
}
if (!(result === undefined
- ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack)
+ ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack)
: result
)) {
return false;
@@ -35392,11 +37301,45 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
if (!isObject(value) || isMasked(value)) {
return false;
}
- var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
/**
+ * The base implementation of `_.isRegExp` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
+ */
+ function baseIsRegExp(value) {
+ return isObjectLike(value) && baseGetTag(value) == regexpTag;
+ }
+
+ /**
+ * The base implementation of `_.isSet` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
+ */
+ function baseIsSet(value) {
+ return isObjectLike(value) && getTag(value) == setTag;
+ }
+
+ /**
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ */
+ function baseIsTypedArray(value) {
+ return isObjectLike(value) &&
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
+ }
+
+ /**
* The base implementation of `_.iteratee`.
*
* @private
@@ -35421,44 +37364,49 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * The base implementation of `_.keys` which doesn't skip the constructor
- * property of prototypes or treat sparse arrays as dense.
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeys(object) {
- return nativeKeys(Object(object));
+ if (!isPrototype(object)) {
+ return nativeKeys(object);
+ }
+ var result = [];
+ for (var key in Object(object)) {
+ if (hasOwnProperty.call(object, key) && key != 'constructor') {
+ result.push(key);
+ }
+ }
+ return result;
}
/**
- * The base implementation of `_.keysIn` which doesn't skip the constructor
- * property of prototypes or treat sparse arrays as dense.
+ * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeysIn(object) {
- object = object == null ? object : Object(object);
+ if (!isObject(object)) {
+ return nativeKeysIn(object);
+ }
+ var isProto = isPrototype(object),
+ result = [];
- var result = [];
for (var key in object) {
- result.push(key);
+ if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
+ result.push(key);
+ }
}
return result;
}
- // Fallback for IE < 9 with es6-shim.
- if (enumerate && !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf')) {
- baseKeysIn = function(object) {
- return iteratorToArray(enumerate(object));
- };
- }
-
/**
- * The base implementation of `_.lt` which doesn't coerce arguments to numbers.
+ * The base implementation of `_.lt` which doesn't coerce arguments.
*
* @private
* @param {*} value The value to compare.
@@ -35521,7 +37469,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var objValue = get(object, path);
return (objValue === undefined && objValue === srcValue)
? hasIn(object, path)
- : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG);
+ : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
};
}
@@ -35540,14 +37488,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
if (object === source) {
return;
}
- if (!(isArray(source) || isTypedArray(source))) {
- var props = keysIn(source);
- }
- arrayEach(props || source, function(srcValue, key) {
- if (props) {
- key = srcValue;
- srcValue = source[key];
- }
+ baseFor(source, function(srcValue, key) {
if (isObject(srcValue)) {
stack || (stack = new Stack);
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
@@ -35562,7 +37503,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
assignMergeValue(object, key, newValue);
}
- });
+ }, keysIn);
}
/**
@@ -35596,47 +37537,54 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var isCommon = newValue === undefined;
if (isCommon) {
+ var isArr = isArray(srcValue),
+ isBuff = !isArr && isBuffer(srcValue),
+ isTyped = !isArr && !isBuff && isTypedArray(srcValue);
+
newValue = srcValue;
- if (isArray(srcValue) || isTypedArray(srcValue)) {
+ if (isArr || isBuff || isTyped) {
if (isArray(objValue)) {
newValue = objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
- else {
+ else if (isBuff) {
isCommon = false;
- newValue = baseClone(srcValue, true);
+ newValue = cloneBuffer(srcValue, true);
+ }
+ else if (isTyped) {
+ isCommon = false;
+ newValue = cloneTypedArray(srcValue, true);
+ }
+ else {
+ newValue = [];
}
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
+ newValue = objValue;
if (isArguments(objValue)) {
newValue = toPlainObject(objValue);
}
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
- isCommon = false;
- newValue = baseClone(srcValue, true);
- }
- else {
- newValue = objValue;
+ newValue = initCloneObject(srcValue);
}
}
else {
isCommon = false;
}
}
- stack.set(srcValue, newValue);
-
if (isCommon) {
// Recursively merge objects and arrays (susceptible to call stack limits).
+ stack.set(srcValue, newValue);
mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
+ stack['delete'](srcValue);
}
- stack['delete'](srcValue);
assignMergeValue(object, key, newValue);
}
/**
- * The base implementation of `_.nth` which doesn't coerce `n` to an integer.
+ * The base implementation of `_.nth` which doesn't coerce arguments.
*
* @private
* @param {Array} array The array to query.
@@ -35683,17 +37631,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {Object} object The source object.
- * @param {string[]} props The property identifiers to pick.
+ * @param {string[]} paths The property paths to pick.
* @returns {Object} Returns the new object.
*/
- function basePick(object, props) {
- object = Object(object);
- return arrayReduce(props, function(result, key) {
- if (key in object) {
- result[key] = object[key];
- }
- return result;
- }, {});
+ function basePick(object, paths) {
+ return basePickBy(object, paths, function(value, path) {
+ return hasIn(object, path);
+ });
}
/**
@@ -35701,40 +37645,27 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {Object} object The source object.
+ * @param {string[]} paths The property paths to pick.
* @param {Function} predicate The function invoked per property.
* @returns {Object} Returns the new object.
*/
- function basePickBy(object, predicate) {
+ function basePickBy(object, paths, predicate) {
var index = -1,
- props = getAllKeysIn(object),
- length = props.length,
+ length = paths.length,
result = {};
while (++index < length) {
- var key = props[index],
- value = object[key];
+ var path = paths[index],
+ value = baseGet(object, path);
- if (predicate(value, key)) {
- result[key] = value;
+ if (predicate(value, path)) {
+ baseSet(result, castPath(path, object), value);
}
}
return result;
}
/**
- * The base implementation of `_.property` without support for deep paths.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new accessor function.
- */
- function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
- };
- }
-
- /**
* A specialized version of `baseProperty` which supports deep paths.
*
* @private
@@ -35804,17 +37735,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var previous = index;
if (isIndex(index)) {
splice.call(array, index, 1);
- }
- else if (!isKey(index, array)) {
- var path = castPath(index),
- object = parent(array, path);
-
- if (object != null) {
- delete object[toKey(last(path))];
- }
- }
- else {
- delete array[toKey(index)];
+ } else {
+ baseUnset(array, index);
}
}
}
@@ -35836,7 +37758,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* The base implementation of `_.range` and `_.rangeRight` which doesn't
- * coerce arguments to numbers.
+ * coerce arguments.
*
* @private
* @param {number} start The start of the range.
@@ -35886,17 +37808,56 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * The base implementation of `_.rest` which doesn't validate or coerce arguments.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @returns {Function} Returns the new function.
+ */
+ function baseRest(func, start) {
+ return setToString(overRest(func, start, identity), func + '');
+ }
+
+ /**
+ * The base implementation of `_.sample`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to sample.
+ * @returns {*} Returns the random element.
+ */
+ function baseSample(collection) {
+ return arraySample(values(collection));
+ }
+
+ /**
+ * The base implementation of `_.sampleSize` without param guards.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to sample.
+ * @param {number} n The number of elements to sample.
+ * @returns {Array} Returns the random elements.
+ */
+ function baseSampleSize(collection, n) {
+ var array = values(collection);
+ return shuffleSelf(array, baseClamp(n, 0, array.length));
+ }
+
+ /**
* The base implementation of `_.set`.
*
* @private
- * @param {Object} object The object to query.
+ * @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to set.
* @param {*} value The value to set.
* @param {Function} [customizer] The function to customize path creation.
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
- path = isKey(path, object) ? [path] : castPath(path);
+ if (!isObject(object)) {
+ return object;
+ }
+ path = castPath(path, object);
var index = -1,
length = path.length,
@@ -35904,27 +37865,26 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
nested = object;
while (nested != null && ++index < length) {
- var key = toKey(path[index]);
- if (isObject(nested)) {
- var newValue = value;
- if (index != lastIndex) {
- var objValue = nested[key];
- newValue = customizer ? customizer(objValue, key, nested) : undefined;
- if (newValue === undefined) {
- newValue = objValue == null
- ? (isIndex(path[index + 1]) ? [] : {})
- : objValue;
- }
+ var key = toKey(path[index]),
+ newValue = value;
+
+ if (index != lastIndex) {
+ var objValue = nested[key];
+ newValue = customizer ? customizer(objValue, key, nested) : undefined;
+ if (newValue === undefined) {
+ newValue = isObject(objValue)
+ ? objValue
+ : (isIndex(path[index + 1]) ? [] : {});
}
- assignValue(nested, key, newValue);
}
+ assignValue(nested, key, newValue);
nested = nested[key];
}
return object;
}
/**
- * The base implementation of `setData` without support for hot loop detection.
+ * The base implementation of `setData` without support for hot loop shorting.
*
* @private
* @param {Function} func The function to associate metadata with.
@@ -35937,6 +37897,34 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
};
/**
+ * The base implementation of `setToString` without support for hot loop shorting.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+ var baseSetToString = !defineProperty ? identity : function(func, string) {
+ return defineProperty(func, 'toString', {
+ 'configurable': true,
+ 'enumerable': false,
+ 'value': constant(string),
+ 'writable': true
+ });
+ };
+
+ /**
+ * The base implementation of `_.shuffle`.
+ *
+ * @private
+ * @param {Array|Object} collection The collection to shuffle.
+ * @returns {Array} Returns the new shuffled array.
+ */
+ function baseShuffle(collection) {
+ return shuffleSelf(values(collection));
+ }
+
+ /**
* The base implementation of `_.slice` without an iteratee call guard.
*
* @private
@@ -35999,7 +37987,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function baseSortedIndex(array, value, retHighest) {
var low = 0,
- high = array ? array.length : low;
+ high = array == null ? low : array.length;
if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
while (low < high) {
@@ -36035,7 +38023,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
value = iteratee(value);
var low = 0,
- high = array ? array.length : 0,
+ high = array == null ? 0 : array.length,
valIsNaN = value !== value,
valIsNull = value === null,
valIsSymbol = isSymbol(value),
@@ -36129,6 +38117,10 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
if (typeof value == 'string') {
return value;
}
+ if (isArray(value)) {
+ // Recursively convert values (susceptible to call stack limits).
+ return arrayMap(value, baseToString) + '';
+ }
if (isSymbol(value)) {
return symbolToString ? symbolToString.call(value) : '';
}
@@ -36202,22 +38194,20 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {Object} object The object to modify.
- * @param {Array|string} path The path of the property to unset.
+ * @param {Array|string} path The property path to unset.
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
- path = isKey(path, object) ? [path] : castPath(path);
+ path = castPath(path, object);
object = parent(object, path);
-
- var key = toKey(last(path));
- return !(object != null && baseHas(object, key)) || delete object[key];
+ return object == null || delete object[toKey(last(path))];
}
/**
* The base implementation of `_.update`.
*
* @private
- * @param {Object} object The object to query.
+ * @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to update.
* @param {Function} updater The function to produce the updated value.
* @param {Function} [customizer] The function to customize path creation.
@@ -36281,18 +38271,24 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Array} Returns the new array of values.
*/
function baseXor(arrays, iteratee, comparator) {
+ var length = arrays.length;
+ if (length < 2) {
+ return length ? baseUniq(arrays[0]) : [];
+ }
var index = -1,
- length = arrays.length;
+ result = Array(length);
while (++index < length) {
- var result = result
- ? arrayPush(
- baseDifference(result, arrays[index], iteratee, comparator),
- baseDifference(arrays[index], result, iteratee, comparator)
- )
- : arrays[index];
+ var array = arrays[index],
+ othIndex = -1;
+
+ while (++othIndex < length) {
+ if (othIndex != index) {
+ result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator);
+ }
+ }
}
- return (result && result.length) ? baseUniq(result, iteratee, comparator) : [];
+ return baseUniq(baseFlatten(result, 1), iteratee, comparator);
}
/**
@@ -36344,13 +38340,28 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {*} value The value to inspect.
+ * @param {Object} [object] The object to query keys on.
* @returns {Array} Returns the cast property path array.
*/
- function castPath(value) {
- return isArray(value) ? value : stringToPath(value);
+ function castPath(value, object) {
+ if (isArray(value)) {
+ return value;
+ }
+ return isKey(value, object) ? [value] : stringToPath(toString(value));
}
/**
+ * A `baseRest` alias which can be replaced with `identity` by module
+ * replacement plugins.
+ *
+ * @private
+ * @type {Function}
+ * @param {Function} func The function to apply a rest parameter to.
+ * @returns {Function} Returns the new function.
+ */
+ var castRest = baseRest;
+
+ /**
* Casts `array` to a slice if it's needed.
*
* @private
@@ -36366,6 +38377,16 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout).
+ *
+ * @private
+ * @param {number|Object} id The timer id or timeout object of the timer to clear.
+ */
+ var clearTimeout = ctxClearTimeout || function(id) {
+ return root.clearTimeout(id);
+ };
+
+ /**
* Creates a clone of `buffer`.
*
* @private
@@ -36377,7 +38398,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
if (isDeep) {
return buffer.slice();
}
- var result = new buffer.constructor(buffer.length);
+ var length = buffer.length,
+ result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
+
buffer.copy(result);
return result;
}
@@ -36418,7 +38441,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Object} Returns the cloned map.
*/
function cloneMap(map, isDeep, cloneFunc) {
- var array = isDeep ? cloneFunc(mapToArray(map), true) : mapToArray(map);
+ var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
return arrayReduce(array, addMapEntry, new map.constructor);
}
@@ -36445,7 +38468,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Object} Returns the cloned set.
*/
function cloneSet(set, isDeep, cloneFunc) {
- var array = isDeep ? cloneFunc(setToArray(set), true) : setToArray(set);
+ var array = isDeep ? cloneFunc(setToArray(set), CLONE_DEEP_FLAG) : setToArray(set);
return arrayReduce(array, addSetEntry, new set.constructor);
}
@@ -36654,6 +38677,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Object} Returns `object`.
*/
function copyObject(source, props, object, customizer) {
+ var isNew = !object;
object || (object = {});
var index = -1,
@@ -36664,15 +38688,22 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
- : source[key];
+ : undefined;
- assignValue(object, key, newValue);
+ if (newValue === undefined) {
+ newValue = source[key];
+ }
+ if (isNew) {
+ baseAssignValue(object, key, newValue);
+ } else {
+ assignValue(object, key, newValue);
+ }
}
return object;
}
/**
- * Copies own symbol properties of `source` to `object`.
+ * Copies own symbols of `source` to `object`.
*
* @private
* @param {Object} source The object to copy symbols from.
@@ -36684,6 +38715,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * Copies own and inherited symbols of `source` to `object`.
+ *
+ * @private
+ * @param {Object} source The object to copy symbols from.
+ * @param {Object} [object={}] The object to copy symbols to.
+ * @returns {Object} Returns `object`.
+ */
+ function copySymbolsIn(source, object) {
+ return copyObject(source, getSymbolsIn(source), object);
+ }
+
+ /**
* Creates a function like `_.groupBy`.
*
* @private
@@ -36696,7 +38739,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var func = isArray(collection) ? arrayAggregator : baseAggregator,
accumulator = initializer ? initializer() : {};
- return func(collection, setter, getIteratee(iteratee), accumulator);
+ return func(collection, setter, getIteratee(iteratee, 2), accumulator);
};
}
@@ -36708,7 +38751,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Function} Returns the new assigner function.
*/
function createAssigner(assigner) {
- return rest(function(object, sources) {
+ return baseRest(function(object, sources) {
var index = -1,
length = sources.length,
customizer = length > 1 ? sources[length - 1] : undefined,
@@ -36792,14 +38835,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {Function} func The function to wrap.
- * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
- * for more details.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @param {*} [thisArg] The `this` binding of `func`.
* @returns {Function} Returns the new wrapped function.
*/
- function createBaseWrapper(func, bitmask, thisArg) {
- var isBind = bitmask & BIND_FLAG,
- Ctor = createCtorWrapper(func);
+ function createBind(func, bitmask, thisArg) {
+ var isBind = bitmask & WRAP_BIND_FLAG,
+ Ctor = createCtor(func);
function wrapper() {
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
@@ -36819,7 +38861,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
return function(string) {
string = toString(string);
- var strSymbols = reHasComplexSymbol.test(string)
+ var strSymbols = hasUnicode(string)
? stringToArray(string)
: undefined;
@@ -36856,10 +38898,10 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {Function} Ctor The constructor to wrap.
* @returns {Function} Returns the new wrapped function.
*/
- function createCtorWrapper(Ctor) {
+ function createCtor(Ctor) {
return function() {
// Use a `switch` statement to work with class constructors. See
- // http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
+ // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
// for more details.
var args = arguments;
switch (args.length) {
@@ -36886,13 +38928,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {Function} func The function to wrap.
- * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
- * for more details.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @param {number} arity The arity of `func`.
* @returns {Function} Returns the new wrapped function.
*/
- function createCurryWrapper(func, bitmask, arity) {
- var Ctor = createCtorWrapper(func);
+ function createCurry(func, bitmask, arity) {
+ var Ctor = createCtor(func);
function wrapper() {
var length = arguments.length,
@@ -36909,8 +38950,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
length -= holders.length;
if (length < arity) {
- return createRecurryWrapper(
- func, bitmask, createHybridWrapper, wrapper.placeholder, undefined,
+ return createRecurry(
+ func, bitmask, createHybrid, wrapper.placeholder, undefined,
args, holders, undefined, undefined, arity - length);
}
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
@@ -36929,18 +38970,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
function createFind(findIndexFunc) {
return function(collection, predicate, fromIndex) {
var iterable = Object(collection);
- predicate = getIteratee(predicate, 3);
if (!isArrayLike(collection)) {
- var props = keys(collection);
+ var iteratee = getIteratee(predicate, 3);
+ collection = keys(collection);
+ predicate = function(key) { return iteratee(iterable[key], key, iterable); };
}
- var index = findIndexFunc(props || collection, function(value, key) {
- if (props) {
- key = value;
- value = iterable[key];
- }
- return predicate(value, key, iterable);
- }, fromIndex);
- return index > -1 ? collection[props ? props[index] : index] : undefined;
+ var index = findIndexFunc(collection, predicate, fromIndex);
+ return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
};
}
@@ -36952,9 +38988,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Function} Returns the new flow function.
*/
function createFlow(fromRight) {
- return rest(function(funcs) {
- funcs = baseFlatten(funcs, 1);
-
+ return flatRest(function(funcs) {
var length = funcs.length,
index = length,
prereq = LodashWrapper.prototype.thru;
@@ -36979,7 +39013,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
data = funcName == 'wrapper' ? getData(func) : undefined;
if (data && isLaziable(data[0]) &&
- data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&
+ data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) &&
!data[4].length && data[9] == 1
) {
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
@@ -36993,8 +39027,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var args = arguments,
value = args[0];
- if (wrapper && args.length == 1 &&
- isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
+ if (wrapper && args.length == 1 && isArray(value)) {
return wrapper.plant(value).value();
}
var index = 0,
@@ -37014,8 +39047,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {Function|string} func The function or method name to wrap.
- * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
- * for more details.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to prepend to those provided to
* the new function.
@@ -37028,13 +39060,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new wrapped function.
*/
- function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
- var isAry = bitmask & ARY_FLAG,
- isBind = bitmask & BIND_FLAG,
- isBindKey = bitmask & BIND_KEY_FLAG,
- isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG),
- isFlip = bitmask & FLIP_FLAG,
- Ctor = isBindKey ? undefined : createCtorWrapper(func);
+ function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
+ var isAry = bitmask & WRAP_ARY_FLAG,
+ isBind = bitmask & WRAP_BIND_FLAG,
+ isBindKey = bitmask & WRAP_BIND_KEY_FLAG,
+ isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG),
+ isFlip = bitmask & WRAP_FLIP_FLAG,
+ Ctor = isBindKey ? undefined : createCtor(func);
function wrapper() {
var length = arguments.length,
@@ -37057,8 +39089,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
length -= holdersCount;
if (isCurried && length < arity) {
var newHolders = replaceHolders(args, placeholder);
- return createRecurryWrapper(
- func, bitmask, createHybridWrapper, wrapper.placeholder, thisArg,
+ return createRecurry(
+ func, bitmask, createHybrid, wrapper.placeholder, thisArg,
args, newHolders, argPos, ary, arity - length
);
}
@@ -37075,7 +39107,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
args.length = ary;
}
if (this && this !== root && this instanceof wrapper) {
- fn = Ctor || createCtorWrapper(fn);
+ fn = Ctor || createCtor(fn);
}
return fn.apply(thisBinding, args);
}
@@ -37101,13 +39133,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {Function} operator The function to perform the operation.
+ * @param {number} [defaultValue] The value used for `undefined` arguments.
* @returns {Function} Returns the new mathematical operation function.
*/
- function createMathOperation(operator) {
+ function createMathOperation(operator, defaultValue) {
return function(value, other) {
var result;
if (value === undefined && other === undefined) {
- return 0;
+ return defaultValue;
}
if (value !== undefined) {
result = value;
@@ -37137,12 +39170,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Function} Returns the new over function.
*/
function createOver(arrayFunc) {
- return rest(function(iteratees) {
- iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
- ? arrayMap(iteratees[0], baseUnary(getIteratee()))
- : arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseUnary(getIteratee()));
-
- return rest(function(args) {
+ return flatRest(function(iteratees) {
+ iteratees = arrayMap(iteratees, baseUnary(getIteratee()));
+ return baseRest(function(args) {
var thisArg = this;
return arrayFunc(iteratees, function(iteratee) {
return apply(iteratee, thisArg, args);
@@ -37168,7 +39198,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
return charsLength ? baseRepeat(chars, length) : chars;
}
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
- return reHasComplexSymbol.test(chars)
+ return hasUnicode(chars)
? castSlice(stringToArray(result), 0, length).join('')
: result.slice(0, length);
}
@@ -37179,16 +39209,15 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {Function} func The function to wrap.
- * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
- * for more details.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} partials The arguments to prepend to those provided to
* the new function.
* @returns {Function} Returns the new wrapped function.
*/
- function createPartialWrapper(func, bitmask, thisArg, partials) {
- var isBind = bitmask & BIND_FLAG,
- Ctor = createCtorWrapper(func);
+ function createPartial(func, bitmask, thisArg, partials) {
+ var isBind = bitmask & WRAP_BIND_FLAG,
+ Ctor = createCtor(func);
function wrapper() {
var argsIndex = -1,
@@ -37222,15 +39251,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
end = step = undefined;
}
// Ensure the sign of `-0` is preserved.
- start = toNumber(start);
- start = start === start ? start : 0;
+ start = toFinite(start);
if (end === undefined) {
end = start;
start = 0;
} else {
- end = toNumber(end) || 0;
+ end = toFinite(end);
}
- step = step === undefined ? (start < end ? 1 : -1) : (toNumber(step) || 0);
+ step = step === undefined ? (start < end ? 1 : -1) : toFinite(step);
return baseRange(start, end, step, fromRight);
};
}
@@ -37257,8 +39285,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {Function} func The function to wrap.
- * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper`
- * for more details.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
* @param {Function} wrapFunc The function to create the `func` wrapper.
* @param {*} placeholder The placeholder value.
* @param {*} [thisArg] The `this` binding of `func`.
@@ -37270,18 +39297,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new wrapped function.
*/
- function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
- var isCurry = bitmask & CURRY_FLAG,
+ function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
+ var isCurry = bitmask & WRAP_CURRY_FLAG,
newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders,
newPartials = isCurry ? partials : undefined,
newPartialsRight = isCurry ? undefined : partials;
- bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
- bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
+ bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG);
+ bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
- if (!(bitmask & CURRY_BOUND_FLAG)) {
- bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
+ if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
+ bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
}
var newData = [
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
@@ -37293,7 +39320,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
setData(result, newData);
}
result.placeholder = placeholder;
- return result;
+ return setWrapToString(result, func, bitmask);
}
/**
@@ -37307,7 +39334,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var func = Math[methodName];
return function(number, precision) {
number = toNumber(number);
- precision = nativeMin(toInteger(precision), 292);
+ precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
if (precision) {
// Shift with exponential notation to avoid floating-point issues.
// See [MDN](https://mdn.io/round#Examples) for more details.
@@ -37322,7 +39349,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * Creates a set of `values`.
+ * Creates a set object of `values`.
*
* @private
* @param {Array} values The values to add to the set.
@@ -37358,18 +39385,17 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* @private
* @param {Function|string} func The function or method name to wrap.
- * @param {number} bitmask The bitmask of wrapper flags.
- * The bitmask may be composed of the following flags:
- * 1 - `_.bind`
- * 2 - `_.bindKey`
- * 4 - `_.curry` or `_.curryRight` of a bound function
- * 8 - `_.curry`
- * 16 - `_.curryRight`
- * 32 - `_.partial`
- * 64 - `_.partialRight`
- * 128 - `_.rearg`
- * 256 - `_.ary`
- * 512 - `_.flip`
+ * @param {number} bitmask The bitmask flags.
+ * 1 - `_.bind`
+ * 2 - `_.bindKey`
+ * 4 - `_.curry` or `_.curryRight` of a bound function
+ * 8 - `_.curry`
+ * 16 - `_.curryRight`
+ * 32 - `_.partial`
+ * 64 - `_.partialRight`
+ * 128 - `_.rearg`
+ * 256 - `_.ary`
+ * 512 - `_.flip`
* @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to be partially applied.
* @param {Array} [holders] The `partials` placeholder indexes.
@@ -37378,21 +39404,21 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {number} [arity] The arity of `func`.
* @returns {Function} Returns the new wrapped function.
*/
- function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
- var isBindKey = bitmask & BIND_KEY_FLAG;
+ function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
+ var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
if (!isBindKey && typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
var length = partials ? partials.length : 0;
if (!length) {
- bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
+ bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
partials = holders = undefined;
}
ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0);
arity = arity === undefined ? arity : toInteger(arity);
length -= holders ? holders.length : 0;
- if (bitmask & PARTIAL_RIGHT_FLAG) {
+ if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
var partialsRight = partials,
holdersRight = holders;
@@ -37413,24 +39439,81 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
thisArg = newData[2];
partials = newData[3];
holders = newData[4];
- arity = newData[9] = newData[9] == null
+ arity = newData[9] = newData[9] === undefined
? (isBindKey ? 0 : func.length)
: nativeMax(newData[9] - length, 0);
- if (!arity && bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG)) {
- bitmask &= ~(CURRY_FLAG | CURRY_RIGHT_FLAG);
+ if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
+ bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
}
- if (!bitmask || bitmask == BIND_FLAG) {
- var result = createBaseWrapper(func, bitmask, thisArg);
- } else if (bitmask == CURRY_FLAG || bitmask == CURRY_RIGHT_FLAG) {
- result = createCurryWrapper(func, bitmask, arity);
- } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !holders.length) {
- result = createPartialWrapper(func, bitmask, thisArg, partials);
+ if (!bitmask || bitmask == WRAP_BIND_FLAG) {
+ var result = createBind(func, bitmask, thisArg);
+ } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
+ result = createCurry(func, bitmask, arity);
+ } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
+ result = createPartial(func, bitmask, thisArg, partials);
} else {
- result = createHybridWrapper.apply(undefined, newData);
+ result = createHybrid.apply(undefined, newData);
}
var setter = data ? baseSetData : setData;
- return setter(result, newData);
+ return setWrapToString(setter(result, newData), func, bitmask);
+ }
+
+ /**
+ * Used by `_.defaults` to customize its `_.assignIn` use to assign properties
+ * of source objects to the destination object for all destination properties
+ * that resolve to `undefined`.
+ *
+ * @private
+ * @param {*} objValue The destination value.
+ * @param {*} srcValue The source value.
+ * @param {string} key The key of the property to assign.
+ * @param {Object} object The parent object of `objValue`.
+ * @returns {*} Returns the value to assign.
+ */
+ function customDefaultsAssignIn(objValue, srcValue, key, object) {
+ if (objValue === undefined ||
+ (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) {
+ return srcValue;
+ }
+ return objValue;
+ }
+
+ /**
+ * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source
+ * objects into destination objects that are passed thru.
+ *
+ * @private
+ * @param {*} objValue The destination value.
+ * @param {*} srcValue The source value.
+ * @param {string} key The key of the property to merge.
+ * @param {Object} object The parent object of `objValue`.
+ * @param {Object} source The parent object of `srcValue`.
+ * @param {Object} [stack] Tracks traversed source values and their merged
+ * counterparts.
+ * @returns {*} Returns the value to assign.
+ */
+ function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
+ if (isObject(objValue) && isObject(srcValue)) {
+ // Recursively merge objects and arrays (susceptible to call stack limits).
+ stack.set(srcValue, objValue);
+ baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack);
+ stack['delete'](srcValue);
+ }
+ return objValue;
+ }
+
+ /**
+ * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain
+ * objects.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @param {string} key The key of the property to inspect.
+ * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`.
+ */
+ function customOmitClone(value) {
+ return isPlainObject(value) ? undefined : value;
}
/**
@@ -37440,15 +39523,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @private
* @param {Array} array The array to compare.
* @param {Array} other The other array to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
- * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
+ * @param {Function} equalFunc The function to determine equivalents of values.
* @param {Object} stack Tracks traversed `array` and `other` objects.
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
*/
- function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
arrLength = array.length,
othLength = other.length;
@@ -37457,14 +39539,15 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
// Assume cyclic values are equal.
var stacked = stack.get(array);
- if (stacked) {
+ if (stacked && stack.get(other)) {
return stacked == other;
}
var index = -1,
result = true,
- seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined;
+ seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
stack.set(array, other);
+ stack.set(other, array);
// Ignore non-index properties.
while (++index < arrLength) {
@@ -37486,9 +39569,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
// Recursively compare arrays (susceptible to call stack limits).
if (seen) {
if (!arraySome(other, function(othValue, othIndex) {
- if (!seen.has(othIndex) &&
- (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) {
- return seen.add(othIndex);
+ if (!cacheHas(seen, othIndex) &&
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
+ return seen.push(othIndex);
}
})) {
result = false;
@@ -37496,13 +39579,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
} else if (!(
arrValue === othValue ||
- equalFunc(arrValue, othValue, customizer, bitmask, stack)
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
)) {
result = false;
break;
}
}
stack['delete'](array);
+ stack['delete'](other);
return result;
}
@@ -37517,14 +39601,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
* @param {string} tag The `toStringTag` of the objects to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
- * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
+ * @param {Function} equalFunc The function to determine equivalents of values.
* @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
- function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
switch (tag) {
case dataViewTag:
if ((object.byteLength != other.byteLength) ||
@@ -37543,22 +39626,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
case boolTag:
case dateTag:
- // Coerce dates and booleans to numbers, dates to milliseconds and
- // booleans to `1` or `0` treating invalid dates coerced to `NaN` as
- // not equal.
- return +object == +other;
+ case numberTag:
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
+ // Invalid dates are coerced to `NaN`.
+ return eq(+object, +other);
case errorTag:
return object.name == other.name && object.message == other.message;
- case numberTag:
- // Treat `NaN` vs. `NaN` as equal.
- return (object != +object) ? other != +other : object == +other;
-
case regexpTag:
case stringTag:
// Coerce regexes to strings and treat strings, primitives and objects,
- // as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
// for more details.
return object == (other + '');
@@ -37566,7 +39645,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var convert = mapToArray;
case setTag:
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
convert || (convert = setToArray);
if (object.size != other.size && !isPartial) {
@@ -37577,11 +39656,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
if (stacked) {
return stacked == other;
}
- bitmask |= UNORDERED_COMPARE_FLAG;
- stack.set(object, other);
+ bitmask |= COMPARE_UNORDERED_FLAG;
// Recursively compare objects (susceptible to call stack limits).
- return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack);
+ stack.set(object, other);
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
+ stack['delete'](object);
+ return result;
case symbolTag:
if (symbolValueOf) {
@@ -37598,18 +39679,17 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @private
* @param {Object} object The object to compare.
* @param {Object} other The other object to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
* @param {Function} customizer The function to customize comparisons.
- * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual`
- * for more details.
+ * @param {Function} equalFunc The function to determine equivalents of values.
* @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/
- function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {
- var isPartial = bitmask & PARTIAL_COMPARE_FLAG,
- objProps = keys(object),
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
+ objProps = getAllKeys(object),
objLength = objProps.length,
- othProps = keys(other),
+ othProps = getAllKeys(other),
othLength = othProps.length;
if (objLength != othLength && !isPartial) {
@@ -37618,17 +39698,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var index = objLength;
while (index--) {
var key = objProps[index];
- if (!(isPartial ? key in other : baseHas(other, key))) {
+ if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
return false;
}
}
// Assume cyclic values are equal.
var stacked = stack.get(object);
- if (stacked) {
+ if (stacked && stack.get(other)) {
return stacked == other;
}
var result = true;
stack.set(object, other);
+ stack.set(other, object);
var skipCtor = isPartial;
while (++index < objLength) {
@@ -37643,7 +39724,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
// Recursively compare objects (susceptible to call stack limits).
if (!(compared === undefined
- ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack))
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
: compared
)) {
result = false;
@@ -37664,10 +39745,22 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
}
stack['delete'](object);
+ stack['delete'](other);
return result;
}
/**
+ * A specialized version of `baseRest` which flattens the rest array.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @returns {Function} Returns the new function.
+ */
+ function flatRest(func) {
+ return setToString(overRest(func, undefined, flatten), func + '');
+ }
+
+ /**
* Creates an array of own enumerable property names and symbols of `object`.
*
* @private
@@ -37753,19 +39846,6 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * Gets the "length" property value of `object`.
- *
- * **Note:** This function is used to avoid a
- * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects
- * Safari on at least iOS 8.1-8.3 ARM64.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {*} Returns the "length" value.
- */
- var getLength = baseProperty('length');
-
- /**
* Gets the data for `map`.
*
* @private
@@ -37814,43 +39894,57 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * Gets the `[[Prototype]]` of `value`.
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
- * @returns {null|Object} Returns the `[[Prototype]]`.
+ * @returns {string} Returns the raw `toStringTag`.
*/
- function getPrototype(value) {
- return nativeGetPrototype(Object(value));
+ function getRawTag(value) {
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
+ tag = value[symToStringTag];
+
+ try {
+ value[symToStringTag] = undefined;
+ var unmasked = true;
+ } catch (e) {}
+
+ var result = nativeObjectToString.call(value);
+ if (unmasked) {
+ if (isOwn) {
+ value[symToStringTag] = tag;
+ } else {
+ delete value[symToStringTag];
+ }
+ }
+ return result;
}
/**
- * Creates an array of the own enumerable symbol properties of `object`.
+ * Creates an array of the own enumerable symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
- function getSymbols(object) {
- // Coerce `object` to an object to avoid non-object errors in V8.
- // See https://bugs.chromium.org/p/v8/issues/detail?id=3443 for more details.
- return getOwnPropertySymbols(Object(object));
- }
-
- // Fallback for IE < 11.
- if (!getOwnPropertySymbols) {
- getSymbols = stubArray;
- }
+ var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
+ if (object == null) {
+ return [];
+ }
+ object = Object(object);
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
+ return propertyIsEnumerable.call(object, symbol);
+ });
+ };
/**
- * Creates an array of the own and inherited enumerable symbol properties
- * of `object`.
+ * Creates an array of the own and inherited enumerable symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
- var getSymbolsIn = !getOwnPropertySymbols ? getSymbols : function(object) {
+ var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
var result = [];
while (object) {
arrayPush(result, getSymbols(object));
@@ -37866,21 +39960,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
- function getTag(value) {
- return objectToString.call(value);
- }
+ var getTag = baseGetTag;
- // Fallback for data views, maps, sets, and weak maps in IE 11,
- // for data views in Edge, and promises in Node.js.
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
(Map && getTag(new Map) != mapTag) ||
(Promise && getTag(Promise.resolve()) != promiseTag) ||
(Set && getTag(new Set) != setTag) ||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
getTag = function(value) {
- var result = objectToString.call(value),
+ var result = baseGetTag(value),
Ctor = result == objectTag ? value.constructor : undefined,
- ctorString = Ctor ? toSource(Ctor) : undefined;
+ ctorString = Ctor ? toSource(Ctor) : '';
if (ctorString) {
switch (ctorString) {
@@ -37924,6 +40015,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * Extracts wrapper details from the `source` body comment.
+ *
+ * @private
+ * @param {string} source The source to inspect.
+ * @returns {Array} Returns the wrapper details.
+ */
+ function getWrapDetails(source) {
+ var match = source.match(reWrapDetails);
+ return match ? match[1].split(reSplitDetails) : [];
+ }
+
+ /**
* Checks if `path` exists on `object`.
*
* @private
@@ -37933,11 +40036,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
- path = isKey(path, object) ? [path] : castPath(path);
+ path = castPath(path, object);
- var result,
- index = -1,
- length = path.length;
+ var index = -1,
+ length = path.length,
+ result = false;
while (++index < length) {
var key = toKey(path[index]);
@@ -37946,12 +40049,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
object = object[key];
}
- if (result) {
+ if (result || ++index != length) {
return result;
}
- var length = object ? object.length : 0;
+ length = object == null ? 0 : object.length;
return !!length && isLength(length) && isIndex(key, length) &&
- (isArray(object) || isString(object) || isArguments(object));
+ (isArray(object) || isArguments(object));
}
/**
@@ -38036,20 +40139,22 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * Creates an array of index keys for `object` values of arrays,
- * `arguments` objects, and strings, otherwise `null` is returned.
+ * Inserts wrapper `details` in a comment at the top of the `source` body.
*
* @private
- * @param {Object} object The object to query.
- * @returns {Array|null} Returns index keys, else `null`.
+ * @param {string} source The source to modify.
+ * @returns {Array} details The details to insert.
+ * @returns {string} Returns the modified source.
*/
- function indexKeys(object) {
- var length = object ? object.length : undefined;
- if (isLength(length) &&
- (isArray(object) || isString(object) || isArguments(object))) {
- return baseTimes(length, String);
+ function insertWrapDetails(source, details) {
+ var length = details.length;
+ if (!length) {
+ return source;
}
- return null;
+ var lastIndex = length - 1;
+ details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex];
+ details = details.join(length > 2 ? ', ' : ' ');
+ return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n');
}
/**
@@ -38060,19 +40165,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/
function isFlattenable(value) {
- return isArray(value) || isArguments(value);
- }
-
- /**
- * Checks if `value` is a flattenable array and not a `_.matchesProperty`
- * iteratee shorthand.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
- */
- function isFlattenableIteratee(value) {
- return isArray(value) && !(value.length == 2 && !isFunction(value[0]));
+ return isArray(value) || isArguments(value) ||
+ !!(spreadableSymbol && value && value[spreadableSymbol]);
}
/**
@@ -38237,6 +40331,26 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * A specialized version of `_.memoize` which clears the memoized function's
+ * cache when it exceeds `MAX_MEMOIZE_SIZE`.
+ *
+ * @private
+ * @param {Function} func The function to have its output memoized.
+ * @returns {Function} Returns the new memoized function.
+ */
+ function memoizeCapped(func) {
+ var result = memoize(func, function(key) {
+ if (cache.size === MAX_MEMOIZE_SIZE) {
+ cache.clear();
+ }
+ return key;
+ });
+
+ var cache = result.cache;
+ return result;
+ }
+
+ /**
* Merges the function metadata of `source` into `data`.
*
* Merging metadata reduces the number of wrappers used to invoke a function.
@@ -38256,22 +40370,22 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var bitmask = data[1],
srcBitmask = source[1],
newBitmask = bitmask | srcBitmask,
- isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG);
+ isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
var isCombo =
- ((srcBitmask == ARY_FLAG) && (bitmask == CURRY_FLAG)) ||
- ((srcBitmask == ARY_FLAG) && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
- ((srcBitmask == (ARY_FLAG | REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
+ ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) ||
+ ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) ||
+ ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG));
// Exit early if metadata can't be merged.
if (!(isCommon || isCombo)) {
return data;
}
// Use source `thisArg` if available.
- if (srcBitmask & BIND_FLAG) {
+ if (srcBitmask & WRAP_BIND_FLAG) {
data[2] = source[2];
// Set when currying a bound function.
- newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG;
+ newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
}
// Compose partial arguments.
var value = source[3];
@@ -38293,7 +40407,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
data[7] = value;
}
// Use source `ary` if it's smaller.
- if (srcBitmask & ARY_FLAG) {
+ if (srcBitmask & WRAP_ARY_FLAG) {
data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
}
// Use source `arity` if one is not provided.
@@ -38308,23 +40422,63 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * Used by `_.defaultsDeep` to customize its `_.merge` use.
+ * This function is like
+ * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * except that it includes inherited enumerable properties.
*
* @private
- * @param {*} objValue The destination value.
- * @param {*} srcValue The source value.
- * @param {string} key The key of the property to merge.
- * @param {Object} object The parent object of `objValue`.
- * @param {Object} source The parent object of `srcValue`.
- * @param {Object} [stack] Tracks traversed source values and their merged
- * counterparts.
- * @returns {*} Returns the value to assign.
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
*/
- function mergeDefaults(objValue, srcValue, key, object, source, stack) {
- if (isObject(objValue) && isObject(srcValue)) {
- baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue));
+ function nativeKeysIn(object) {
+ var result = [];
+ if (object != null) {
+ for (var key in Object(object)) {
+ result.push(key);
+ }
}
- return objValue;
+ return result;
+ }
+
+ /**
+ * Converts `value` to a string using `Object.prototype.toString`.
+ *
+ * @private
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ */
+ function objectToString(value) {
+ return nativeObjectToString.call(value);
+ }
+
+ /**
+ * A specialized version of `baseRest` which transforms the rest array.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @param {Function} transform The rest array transform.
+ * @returns {Function} Returns the new function.
+ */
+ function overRest(func, start, transform) {
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
+ return function() {
+ var args = arguments,
+ index = -1,
+ length = nativeMax(args.length - start, 0),
+ array = Array(length);
+
+ while (++index < length) {
+ array[index] = args[start + index];
+ }
+ index = -1;
+ var otherArgs = Array(start + 1);
+ while (++index < start) {
+ otherArgs[index] = args[index];
+ }
+ otherArgs[start] = transform(array);
+ return apply(func, this, otherArgs);
+ };
}
/**
@@ -38336,7 +40490,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {*} Returns the parent value.
*/
function parent(object, path) {
- return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
+ return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
}
/**
@@ -38375,25 +40529,98 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {*} data The metadata.
* @returns {Function} Returns `func`.
*/
- var setData = (function() {
+ var setData = shortOut(baseSetData);
+
+ /**
+ * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout).
+ *
+ * @private
+ * @param {Function} func The function to delay.
+ * @param {number} wait The number of milliseconds to delay invocation.
+ * @returns {number|Object} Returns the timer id or timeout object.
+ */
+ var setTimeout = ctxSetTimeout || function(func, wait) {
+ return root.setTimeout(func, wait);
+ };
+
+ /**
+ * Sets the `toString` method of `func` to return `string`.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+ var setToString = shortOut(baseSetToString);
+
+ /**
+ * Sets the `toString` method of `wrapper` to mimic the source of `reference`
+ * with wrapper details in a comment at the top of the source body.
+ *
+ * @private
+ * @param {Function} wrapper The function to modify.
+ * @param {Function} reference The reference function.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @returns {Function} Returns `wrapper`.
+ */
+ function setWrapToString(wrapper, reference, bitmask) {
+ var source = (reference + '');
+ return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
+ }
+
+ /**
+ * Creates a function that'll short out and invoke `identity` instead
+ * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
+ * milliseconds.
+ *
+ * @private
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new shortable function.
+ */
+ function shortOut(func) {
var count = 0,
lastCalled = 0;
- return function(key, value) {
- var stamp = now(),
+ return function() {
+ var stamp = nativeNow(),
remaining = HOT_SPAN - (stamp - lastCalled);
lastCalled = stamp;
if (remaining > 0) {
if (++count >= HOT_COUNT) {
- return key;
+ return arguments[0];
}
} else {
count = 0;
}
- return baseSetData(key, value);
+ return func.apply(undefined, arguments);
};
- }());
+ }
+
+ /**
+ * A specialized version of `_.shuffle` which mutates and sets the size of `array`.
+ *
+ * @private
+ * @param {Array} array The array to shuffle.
+ * @param {number} [size=array.length] The size of `array`.
+ * @returns {Array} Returns `array`.
+ */
+ function shuffleSelf(array, size) {
+ var index = -1,
+ length = array.length,
+ lastIndex = length - 1;
+
+ size = size === undefined ? length : size;
+ while (++index < size) {
+ var rand = baseRandom(index, lastIndex),
+ value = array[rand];
+
+ array[rand] = array[index];
+ array[index] = value;
+ }
+ array.length = size;
+ return array;
+ }
/**
* Converts `string` to a property path array.
@@ -38402,9 +40629,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
- var stringToPath = memoize(function(string) {
+ var stringToPath = memoizeCapped(function(string) {
var result = [];
- toString(string).replace(rePropName, function(match, number, quote, string) {
+ if (reLeadingDot.test(string)) {
+ result.push('');
+ }
+ string.replace(rePropName, function(match, number, quote, string) {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
});
return result;
@@ -38429,7 +40659,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* Converts `func` to its source code.
*
* @private
- * @param {Function} func The function to process.
+ * @param {Function} func The function to convert.
* @returns {string} Returns the source code.
*/
function toSource(func) {
@@ -38445,6 +40675,24 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * Updates wrapper `details` based on `bitmask` flags.
+ *
+ * @private
+ * @returns {Array} details The details to modify.
+ * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
+ * @returns {Array} Returns `details`.
+ */
+ function updateWrapDetails(details, bitmask) {
+ arrayEach(wrapFlags, function(pair) {
+ var value = '_.' + pair[0];
+ if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
+ details.push(value);
+ }
+ });
+ return details.sort();
+ }
+
+ /**
* Creates a clone of `wrapper`.
*
* @private
@@ -38491,7 +40739,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
} else {
size = nativeMax(toInteger(size), 0);
}
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (!length || size < 1) {
return [];
}
@@ -38522,7 +40770,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function compact(array) {
var index = -1,
- length = array ? array.length : 0,
+ length = array == null ? 0 : array.length,
resIndex = 0,
result = [];
@@ -38558,24 +40806,27 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [1]
*/
function concat() {
- var length = arguments.length,
- args = Array(length ? length - 1 : 0),
+ var length = arguments.length;
+ if (!length) {
+ return [];
+ }
+ var args = Array(length - 1),
array = arguments[0],
index = length;
while (index--) {
args[index - 1] = arguments[index];
}
- return length
- ? arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1))
- : [];
+ return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1));
}
/**
- * Creates an array of unique `array` values not included in the other given
- * arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
- * for equality comparisons. The order of result values is determined by the
- * order they occur in the first array.
+ * Creates an array of `array` values not included in the other given arrays
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons. The order and references of result values are
+ * determined by the first array.
+ *
+ * **Note:** Unlike `_.pullAll`, this method returns a new array.
*
* @static
* @memberOf _
@@ -38590,7 +40841,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.difference([2, 1], [2, 3]);
* // => [1]
*/
- var difference = rest(function(array, values) {
+ var difference = baseRest(function(array, values) {
return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
: [];
@@ -38599,8 +40850,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* This method is like `_.difference` except that it accepts `iteratee` which
* is invoked for each element of `array` and `values` to generate the criterion
- * by which they're compared. Result values are chosen from the first array.
- * The iteratee is invoked with one argument: (value).
+ * by which they're compared. The order and references of result values are
+ * determined by the first array. The iteratee is invoked with one argument:
+ * (value).
+ *
+ * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
*
* @static
* @memberOf _
@@ -38608,8 +40862,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @category Array
* @param {Array} array The array to inspect.
* @param {...Array} [values] The values to exclude.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new array of filtered values.
* @example
*
@@ -38620,21 +40873,23 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
* // => [{ 'x': 2 }]
*/
- var differenceBy = rest(function(array, values) {
+ var differenceBy = baseRest(function(array, values) {
var iteratee = last(values);
if (isArrayLikeObject(iteratee)) {
iteratee = undefined;
}
return isArrayLikeObject(array)
- ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee))
+ ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2))
: [];
});
/**
* This method is like `_.difference` except that it accepts `comparator`
- * which is invoked to compare elements of `array` to `values`. Result values
- * are chosen from the first array. The comparator is invoked with two arguments:
- * (arrVal, othVal).
+ * which is invoked to compare elements of `array` to `values`. The order and
+ * references of result values are determined by the first array. The comparator
+ * is invoked with two arguments: (arrVal, othVal).
+ *
+ * **Note:** Unlike `_.pullAllWith`, this method returns a new array.
*
* @static
* @memberOf _
@@ -38651,7 +40906,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
* // => [{ 'x': 2, 'y': 1 }]
*/
- var differenceWith = rest(function(array, values) {
+ var differenceWith = baseRest(function(array, values) {
var comparator = last(values);
if (isArrayLikeObject(comparator)) {
comparator = undefined;
@@ -38687,7 +40942,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [1, 2, 3]
*/
function drop(array, n, guard) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
@@ -38721,7 +40976,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [1, 2, 3]
*/
function dropRight(array, n, guard) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
@@ -38740,8 +40995,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
@@ -38782,8 +41036,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
@@ -38844,7 +41097,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [4, '*', '*', 10]
*/
function fill(array, value, start, end) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
@@ -38863,9 +41116,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 1.1.0
* @category Array
- * @param {Array} array The array to search.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Array} array The array to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=0] The index to search from.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
@@ -38892,7 +41144,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 2
*/
function findIndex(array, predicate, fromIndex) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
@@ -38911,9 +41163,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 2.0.0
* @category Array
- * @param {Array} array The array to search.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Array} array The array to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=array.length-1] The index to search from.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
@@ -38940,7 +41191,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 0
*/
function findLastIndex(array, predicate, fromIndex) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
@@ -38969,7 +41220,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [1, 2, [3, [4]], 5]
*/
function flatten(array) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
return length ? baseFlatten(array, 1) : [];
}
@@ -38988,7 +41239,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [1, 2, 3, 4, 5]
*/
function flattenDeep(array) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
return length ? baseFlatten(array, INFINITY) : [];
}
@@ -39013,7 +41264,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [1, 2, 3, [4], 5]
*/
function flattenDepth(array, depth) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
@@ -39033,12 +41284,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Object} Returns the new object.
* @example
*
- * _.fromPairs([['fred', 30], ['barney', 40]]);
- * // => { 'fred': 30, 'barney': 40 }
+ * _.fromPairs([['a', 1], ['b', 2]]);
+ * // => { 'a': 1, 'b': 2 }
*/
function fromPairs(pairs) {
var index = -1,
- length = pairs ? pairs.length : 0,
+ length = pairs == null ? 0 : pairs.length,
result = {};
while (++index < length) {
@@ -39072,7 +41323,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* Gets the index at which the first occurrence of `value` is found in `array`
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons. If `fromIndex` is negative, it's used as the
* offset from the end of `array`.
*
@@ -39080,7 +41331,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 0.1.0
* @category Array
- * @param {Array} array The array to search.
+ * @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} [fromIndex=0] The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
@@ -39094,7 +41345,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 3
*/
function indexOf(array, value, fromIndex) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
@@ -39120,14 +41371,15 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [1, 2]
*/
function initial(array) {
- return dropRight(array, 1);
+ var length = array == null ? 0 : array.length;
+ return length ? baseSlice(array, 0, -1) : [];
}
/**
* Creates an array of unique values that are included in all given arrays
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
- * for equality comparisons. The order of result values is determined by the
- * order they occur in the first array.
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons. The order and references of result values are
+ * determined by the first array.
*
* @static
* @memberOf _
@@ -39140,7 +41392,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.intersection([2, 1], [2, 3]);
* // => [2]
*/
- var intersection = rest(function(arrays) {
+ var intersection = baseRest(function(arrays) {
var mapped = arrayMap(arrays, castArrayLikeObject);
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped)
@@ -39150,16 +41402,16 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* This method is like `_.intersection` except that it accepts `iteratee`
* which is invoked for each element of each `arrays` to generate the criterion
- * by which they're compared. Result values are chosen from the first array.
- * The iteratee is invoked with one argument: (value).
+ * by which they're compared. The order and references of result values are
+ * determined by the first array. The iteratee is invoked with one argument:
+ * (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new array of intersecting values.
* @example
*
@@ -39170,7 +41422,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }]
*/
- var intersectionBy = rest(function(arrays) {
+ var intersectionBy = baseRest(function(arrays) {
var iteratee = last(arrays),
mapped = arrayMap(arrays, castArrayLikeObject);
@@ -39180,15 +41432,15 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
mapped.pop();
}
return (mapped.length && mapped[0] === arrays[0])
- ? baseIntersection(mapped, getIteratee(iteratee))
+ ? baseIntersection(mapped, getIteratee(iteratee, 2))
: [];
});
/**
* This method is like `_.intersection` except that it accepts `comparator`
- * which is invoked to compare elements of `arrays`. Result values are chosen
- * from the first array. The comparator is invoked with two arguments:
- * (arrVal, othVal).
+ * which is invoked to compare elements of `arrays`. The order and references
+ * of result values are determined by the first array. The comparator is
+ * invoked with two arguments: (arrVal, othVal).
*
* @static
* @memberOf _
@@ -39205,13 +41457,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.intersectionWith(objects, others, _.isEqual);
* // => [{ 'x': 1, 'y': 2 }]
*/
- var intersectionWith = rest(function(arrays) {
+ var intersectionWith = baseRest(function(arrays) {
var comparator = last(arrays),
mapped = arrayMap(arrays, castArrayLikeObject);
- if (comparator === last(mapped)) {
- comparator = undefined;
- } else {
+ comparator = typeof comparator == 'function' ? comparator : undefined;
+ if (comparator) {
mapped.pop();
}
return (mapped.length && mapped[0] === arrays[0])
@@ -39235,7 +41486,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 'a~b~c'
*/
function join(array, separator) {
- return array ? nativeJoin.call(array, separator) : '';
+ return array == null ? '' : nativeJoin.call(array, separator);
}
/**
@@ -39253,7 +41504,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 3
*/
function last(array) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
return length ? array[length - 1] : undefined;
}
@@ -39265,7 +41516,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 0.1.0
* @category Array
- * @param {Array} array The array to search.
+ * @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} [fromIndex=array.length-1] The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
@@ -39279,28 +41530,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 1
*/
function lastIndexOf(array, value, fromIndex) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
var index = length;
if (fromIndex !== undefined) {
index = toInteger(fromIndex);
- index = (
- index < 0
- ? nativeMax(length + index, 0)
- : nativeMin(index, length - 1)
- ) + 1;
- }
- if (value !== value) {
- return indexOfNaN(array, index - 1, true);
- }
- while (index--) {
- if (array[index] === value) {
- return index;
- }
+ index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1);
}
- return -1;
+ return value === value
+ ? strictLastIndexOf(array, value, index)
+ : baseFindIndex(array, baseIsNaN, index, true);
}
/**
@@ -39330,7 +41571,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* Removes all given values from `array` using
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove`
@@ -39351,7 +41592,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* console.log(array);
* // => ['b', 'b']
*/
- var pull = rest(pullAll);
+ var pull = baseRest(pullAll);
/**
* This method is like `_.pull` except that it accepts an array of values to remove.
@@ -39392,8 +41633,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @category Array
* @param {Array} array The array to modify.
* @param {Array} values The values to remove.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns `array`.
* @example
*
@@ -39405,7 +41645,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function pullAllBy(array, values, iteratee) {
return (array && array.length && values && values.length)
- ? basePullAll(array, values, getIteratee(iteratee))
+ ? basePullAll(array, values, getIteratee(iteratee, 2))
: array;
}
@@ -39462,10 +41702,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* console.log(pulled);
* // => ['b', 'd']
*/
- var pullAt = rest(function(array, indexes) {
- indexes = baseFlatten(indexes, 1);
-
- var length = array ? array.length : 0,
+ var pullAt = flatRest(function(array, indexes) {
+ var length = array == null ? 0 : array.length,
result = baseAt(array, indexes);
basePullAt(array, arrayMap(indexes, function(index) {
@@ -39488,8 +41726,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 2.0.0
* @category Array
* @param {Array} array The array to modify.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new array of removed elements.
* @example
*
@@ -39549,7 +41786,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [3, 2, 1]
*/
function reverse(array) {
- return array ? nativeReverse.call(array) : array;
+ return array == null ? array : nativeReverse.call(array);
}
/**
@@ -39569,7 +41806,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Array} Returns the slice of `array`.
*/
function slice(array, start, end) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
@@ -39616,8 +41853,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @category Array
* @param {Array} array The sorted array to inspect.
* @param {*} value The value to evaluate.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {number} Returns the index at which `value` should be inserted
* into `array`.
* @example
@@ -39632,7 +41868,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 0
*/
function sortedIndexBy(array, value, iteratee) {
- return baseSortedIndexBy(array, value, getIteratee(iteratee));
+ return baseSortedIndexBy(array, value, getIteratee(iteratee, 2));
}
/**
@@ -39643,7 +41879,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 4.0.0
* @category Array
- * @param {Array} array The array to search.
+ * @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
* @example
@@ -39652,7 +41888,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 1
*/
function sortedIndexOf(array, value) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (length) {
var index = baseSortedIndex(array, value);
if (index < length && eq(array[index], value)) {
@@ -39695,8 +41931,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @category Array
* @param {Array} array The sorted array to inspect.
* @param {*} value The value to evaluate.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {number} Returns the index at which `value` should be inserted
* into `array`.
* @example
@@ -39711,7 +41946,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 1
*/
function sortedLastIndexBy(array, value, iteratee) {
- return baseSortedIndexBy(array, value, getIteratee(iteratee), true);
+ return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true);
}
/**
@@ -39722,7 +41957,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 4.0.0
* @category Array
- * @param {Array} array The array to search.
+ * @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
* @example
@@ -39731,7 +41966,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 3
*/
function sortedLastIndexOf(array, value) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (length) {
var index = baseSortedIndex(array, value, true) - 1;
if (eq(array[index], value)) {
@@ -39780,7 +42015,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function sortedUniqBy(array, iteratee) {
return (array && array.length)
- ? baseSortedUniq(array, getIteratee(iteratee))
+ ? baseSortedUniq(array, getIteratee(iteratee, 2))
: [];
}
@@ -39799,7 +42034,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [2, 3]
*/
function tail(array) {
- return drop(array, 1);
+ var length = array == null ? 0 : array.length;
+ return length ? baseSlice(array, 1, length) : [];
}
/**
@@ -39861,7 +42097,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => []
*/
function takeRight(array, n, guard) {
- var length = array ? array.length : 0;
+ var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
@@ -39880,8 +42116,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
@@ -39922,14 +42157,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 3.0.0
* @category Array
* @param {Array} array The array to query.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the slice of `array`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': false },
- * { 'user': 'fred', 'active': false},
+ * { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': true }
* ];
*
@@ -39956,7 +42190,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* Creates an array of unique values, in order, from all given arrays using
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @static
@@ -39970,14 +42204,15 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.union([2], [1, 2]);
* // => [2, 1]
*/
- var union = rest(function(arrays) {
+ var union = baseRest(function(arrays) {
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
});
/**
* This method is like `_.union` except that it accepts `iteratee` which is
* invoked for each element of each `arrays` to generate the criterion by
- * which uniqueness is computed. The iteratee is invoked with one argument:
+ * which uniqueness is computed. Result values are chosen from the first
+ * array in which the value occurs. The iteratee is invoked with one argument:
* (value).
*
* @static
@@ -39985,8 +42220,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.0.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new array of combined values.
* @example
*
@@ -39997,17 +42231,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }]
*/
- var unionBy = rest(function(arrays) {
+ var unionBy = baseRest(function(arrays) {
var iteratee = last(arrays);
if (isArrayLikeObject(iteratee)) {
iteratee = undefined;
}
- return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee));
+ return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2));
});
/**
* This method is like `_.union` except that it accepts `comparator` which
- * is invoked to compare elements of `arrays`. The comparator is invoked
+ * is invoked to compare elements of `arrays`. Result values are chosen from
+ * the first array in which the value occurs. The comparator is invoked
* with two arguments: (arrVal, othVal).
*
* @static
@@ -40025,19 +42260,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.unionWith(objects, others, _.isEqual);
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
*/
- var unionWith = rest(function(arrays) {
+ var unionWith = baseRest(function(arrays) {
var comparator = last(arrays);
- if (isArrayLikeObject(comparator)) {
- comparator = undefined;
- }
+ comparator = typeof comparator == 'function' ? comparator : undefined;
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);
});
/**
* Creates a duplicate-free version of an array, using
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
- * for equality comparisons, in which only the first occurrence of each
- * element is kept.
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons, in which only the first occurrence of each element
+ * is kept. The order of result values is determined by the order they occur
+ * in the array.
*
* @static
* @memberOf _
@@ -40051,23 +42285,22 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [2, 1]
*/
function uniq(array) {
- return (array && array.length)
- ? baseUniq(array)
- : [];
+ return (array && array.length) ? baseUniq(array) : [];
}
/**
* This method is like `_.uniq` except that it accepts `iteratee` which is
* invoked for each element in `array` to generate the criterion by which
- * uniqueness is computed. The iteratee is invoked with one argument: (value).
+ * uniqueness is computed. The order of result values is determined by the
+ * order they occur in the array. The iteratee is invoked with one argument:
+ * (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {Array} array The array to inspect.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new duplicate free array.
* @example
*
@@ -40079,15 +42312,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [{ 'x': 1 }, { 'x': 2 }]
*/
function uniqBy(array, iteratee) {
- return (array && array.length)
- ? baseUniq(array, getIteratee(iteratee))
- : [];
+ return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : [];
}
/**
* This method is like `_.uniq` except that it accepts `comparator` which
- * is invoked to compare elements of `array`. The comparator is invoked with
- * two arguments: (arrVal, othVal).
+ * is invoked to compare elements of `array`. The order of result values is
+ * determined by the order they occur in the array.The comparator is invoked
+ * with two arguments: (arrVal, othVal).
*
* @static
* @memberOf _
@@ -40104,9 +42336,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
*/
function uniqWith(array, comparator) {
- return (array && array.length)
- ? baseUniq(array, undefined, comparator)
- : [];
+ comparator = typeof comparator == 'function' ? comparator : undefined;
+ return (array && array.length) ? baseUniq(array, undefined, comparator) : [];
}
/**
@@ -40122,11 +42353,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Array} Returns the new array of regrouped elements.
* @example
*
- * var zipped = _.zip(['fred', 'barney'], [30, 40], [true, false]);
- * // => [['fred', 30, true], ['barney', 40, false]]
+ * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
+ * // => [['a', 1, true], ['b', 2, false]]
*
* _.unzip(zipped);
- * // => [['fred', 'barney'], [30, 40], [true, false]]
+ * // => [['a', 'b'], [1, 2], [true, false]]
*/
function unzip(array) {
if (!(array && array.length)) {
@@ -40180,9 +42411,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* Creates an array excluding all given values using
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
+ * **Note:** Unlike `_.pull`, this method returns a new array.
+ *
* @static
* @memberOf _
* @since 0.1.0
@@ -40196,7 +42429,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.without([2, 1, 2, 3], 1, 2);
* // => [3]
*/
- var without = rest(function(array, values) {
+ var without = baseRest(function(array, values) {
return isArrayLikeObject(array)
? baseDifference(array, values)
: [];
@@ -40220,23 +42453,23 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.xor([2, 1], [2, 3]);
* // => [1, 3]
*/
- var xor = rest(function(arrays) {
+ var xor = baseRest(function(arrays) {
return baseXor(arrayFilter(arrays, isArrayLikeObject));
});
/**
* This method is like `_.xor` except that it accepts `iteratee` which is
* invoked for each element of each `arrays` to generate the criterion by
- * which by which they're compared. The iteratee is invoked with one argument:
- * (value).
+ * which by which they're compared. The order of result values is determined
+ * by the order they occur in the arrays. The iteratee is invoked with one
+ * argument: (value).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new array of filtered values.
* @example
*
@@ -40247,18 +42480,19 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 2 }]
*/
- var xorBy = rest(function(arrays) {
+ var xorBy = baseRest(function(arrays) {
var iteratee = last(arrays);
if (isArrayLikeObject(iteratee)) {
iteratee = undefined;
}
- return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee));
+ return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2));
});
/**
* This method is like `_.xor` except that it accepts `comparator` which is
- * invoked to compare elements of `arrays`. The comparator is invoked with
- * two arguments: (arrVal, othVal).
+ * invoked to compare elements of `arrays`. The order of result values is
+ * determined by the order they occur in the arrays. The comparator is invoked
+ * with two arguments: (arrVal, othVal).
*
* @static
* @memberOf _
@@ -40275,11 +42509,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.xorWith(objects, others, _.isEqual);
* // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
*/
- var xorWith = rest(function(arrays) {
+ var xorWith = baseRest(function(arrays) {
var comparator = last(arrays);
- if (isArrayLikeObject(comparator)) {
- comparator = undefined;
- }
+ comparator = typeof comparator == 'function' ? comparator : undefined;
return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator);
});
@@ -40296,10 +42528,10 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Array} Returns the new array of grouped elements.
* @example
*
- * _.zip(['fred', 'barney'], [30, 40], [true, false]);
- * // => [['fred', 30, true], ['barney', 40, false]]
+ * _.zip(['a', 'b'], [1, 2], [true, false]);
+ * // => [['a', 1, true], ['b', 2, false]]
*/
- var zip = rest(unzip);
+ var zip = baseRest(unzip);
/**
* This method is like `_.fromPairs` except that it accepts two arrays,
@@ -40350,7 +42582,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 3.8.0
* @category Array
* @param {...Array} [arrays] The arrays to process.
- * @param {Function} [iteratee=_.identity] The function to combine grouped values.
+ * @param {Function} [iteratee=_.identity] The function to combine
+ * grouped values.
* @returns {Array} Returns the new array of grouped elements.
* @example
*
@@ -40359,7 +42592,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* });
* // => [111, 222]
*/
- var zipWith = rest(function(arrays) {
+ var zipWith = baseRest(function(arrays) {
var length = arrays.length,
iteratee = length > 1 ? arrays[length - 1] : undefined;
@@ -40466,7 +42699,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 1.0.0
* @category Seq
- * @param {...(string|string[])} [paths] The property paths of elements to pick.
+ * @param {...(string|string[])} [paths] The property paths to pick.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
@@ -40475,8 +42708,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _(object).at(['a[0].b.c', 'a[1]']).value();
* // => [3, 4]
*/
- var wrapperAt = rest(function(paths) {
- paths = baseFlatten(paths, 1);
+ var wrapperAt = flatRest(function(paths) {
var length = paths.length,
start = length ? paths[0] : 0,
value = this.__wrapped__,
@@ -40728,8 +42960,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.5.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee to transform keys.
+ * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*
@@ -40741,7 +42972,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => { '3': 2, '5': 1 }
*/
var countBy = createAggregator(function(result, value, key) {
- hasOwnProperty.call(result, key) ? ++result[key] : (result[key] = 1);
+ if (hasOwnProperty.call(result, key)) {
+ ++result[key];
+ } else {
+ baseAssignValue(result, key, 1);
+ }
});
/**
@@ -40749,13 +42984,17 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* Iteration is stopped once `predicate` returns falsey. The predicate is
* invoked with three arguments: (value, index|key, collection).
*
+ * **Note:** This method returns `true` for
+ * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because
+ * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of
+ * elements of empty collections.
+ *
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`.
@@ -40794,13 +43033,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* `predicate` returns truthy for. The predicate is invoked with three
* arguments: (value, index|key, collection).
*
+ * **Note:** Unlike `_.remove`, this method returns a new array.
+ *
* @static
* @memberOf _
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
* @see _.reject
* @example
@@ -40839,9 +43079,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 0.1.0
* @category Collection
- * @param {Array|Object} collection The collection to search.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Array|Object} collection The collection to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=0] The index to search from.
* @returns {*} Returns the matched element, else `undefined`.
* @example
@@ -40877,9 +43116,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 2.0.0
* @category Collection
- * @param {Array|Object} collection The collection to search.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Array|Object} collection The collection to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param {number} [fromIndex=collection.length-1] The index to search from.
* @returns {*} Returns the matched element, else `undefined`.
* @example
@@ -40901,8 +43139,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.0.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new flattened array.
* @example
*
@@ -40926,8 +43163,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.7.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new flattened array.
* @example
*
@@ -40951,8 +43187,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.7.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @param {number} [depth=1] The maximum recursion depth.
* @returns {Array} Returns the new flattened array.
* @example
@@ -40989,7 +43224,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @see _.forEachRight
* @example
*
- * _([1, 2]).forEach(function(value) {
+ * _.forEach([1, 2], function(value) {
* console.log(value);
* });
* // => Logs `1` then `2`.
@@ -41041,8 +43276,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee to transform keys.
+ * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*
@@ -41057,14 +43291,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
if (hasOwnProperty.call(result, key)) {
result[key].push(value);
} else {
- result[key] = [value];
+ baseAssignValue(result, key, [value]);
}
});
/**
* Checks if `value` is in `collection`. If `collection` is a string, it's
* checked for a substring of `value`, otherwise
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* is used for equality comparisons. If `fromIndex` is negative, it's used as
* the offset from the end of `collection`.
*
@@ -41072,7 +43306,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 0.1.0
* @category Collection
- * @param {Array|Object|string} collection The collection to search.
+ * @param {Array|Object|string} collection The collection to inspect.
* @param {*} value The value to search for.
* @param {number} [fromIndex=0] The index to search from.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`.
@@ -41085,10 +43319,10 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.includes([1, 2, 3], 1, 2);
* // => false
*
- * _.includes({ 'user': 'fred', 'age': 40 }, 'fred');
+ * _.includes({ 'a': 1, 'b': 2 }, 1);
* // => true
*
- * _.includes('pebbles', 'eb');
+ * _.includes('abcd', 'bc');
* // => true
*/
function includes(collection, value, fromIndex, guard) {
@@ -41107,8 +43341,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* Invokes the method at `path` of each element in `collection`, returning
* an array of the results of each invoked method. Any additional arguments
- * are provided to each invoked method. If `methodName` is a function, it's
- * invoked for and `this` bound to, each element in `collection`.
+ * are provided to each invoked method. If `path` is a function, it's invoked
+ * for, and `this` bound to, each element in `collection`.
*
* @static
* @memberOf _
@@ -41127,15 +43361,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.invokeMap([123, 456], String.prototype.split, '');
* // => [['1', '2', '3'], ['4', '5', '6']]
*/
- var invokeMap = rest(function(collection, path, args) {
+ var invokeMap = baseRest(function(collection, path, args) {
var index = -1,
isFunc = typeof path == 'function',
- isProp = isKey(path),
result = isArrayLike(collection) ? Array(collection.length) : [];
baseEach(collection, function(value) {
- var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined);
- result[++index] = func ? apply(func, value, args) : baseInvoke(value, path, args);
+ result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
});
return result;
});
@@ -41151,8 +43383,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.0.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee to transform keys.
+ * @param {Function} [iteratee=_.identity] The iteratee to transform keys.
* @returns {Object} Returns the composed aggregate object.
* @example
*
@@ -41170,7 +43401,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
*/
var keyBy = createAggregator(function(result, value, key) {
- result[key] = value;
+ baseAssignValue(result, key, value);
});
/**
@@ -41192,8 +43423,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
* @example
*
@@ -41275,8 +43505,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 3.0.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the array of grouped elements.
* @example
*
@@ -41387,8 +43616,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
* @see _.filter
* @example
@@ -41415,10 +43643,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function reject(collection, predicate) {
var func = isArray(collection) ? arrayFilter : baseFilter;
- predicate = getIteratee(predicate, 3);
- return func(collection, function(value, index, collection) {
- return !predicate(value, index, collection);
- });
+ return func(collection, negate(getIteratee(predicate, 3)));
}
/**
@@ -41436,10 +43661,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 2
*/
function sample(collection) {
- var array = isArrayLike(collection) ? collection : values(collection),
- length = array.length;
-
- return length > 0 ? array[baseRandom(0, length - 1)] : undefined;
+ var func = isArray(collection) ? arraySample : baseSample;
+ return func(collection);
}
/**
@@ -41463,25 +43686,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [2, 3, 1]
*/
function sampleSize(collection, n, guard) {
- var index = -1,
- result = toArray(collection),
- length = result.length,
- lastIndex = length - 1;
-
if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) {
n = 1;
} else {
- n = baseClamp(toInteger(n), 0, length);
- }
- while (++index < n) {
- var rand = baseRandom(index, lastIndex),
- value = result[rand];
-
- result[rand] = result[index];
- result[index] = value;
+ n = toInteger(n);
}
- result.length = n;
- return result;
+ var func = isArray(collection) ? arraySampleSize : baseSampleSize;
+ return func(collection, n);
}
/**
@@ -41500,7 +43711,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [4, 1, 3, 2]
*/
function shuffle(collection) {
- return sampleSize(collection, MAX_ARRAY_LENGTH);
+ var func = isArray(collection) ? arrayShuffle : baseShuffle;
+ return func(collection);
}
/**
@@ -41511,7 +43723,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 0.1.0
* @category Collection
- * @param {Array|Object} collection The collection to inspect.
+ * @param {Array|Object|string} collection The collection to inspect.
* @returns {number} Returns the collection size.
* @example
*
@@ -41529,16 +43741,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
return 0;
}
if (isArrayLike(collection)) {
- var result = collection.length;
- return (result && isString(collection)) ? stringSize(collection) : result;
+ return isString(collection) ? stringSize(collection) : collection.length;
}
- if (isObjectLike(collection)) {
- var tag = getTag(collection);
- if (tag == mapTag || tag == setTag) {
- return collection.size;
- }
+ var tag = getTag(collection);
+ if (tag == mapTag || tag == setTag) {
+ return collection.size;
}
- return keys(collection).length;
+ return baseKeys(collection).length;
}
/**
@@ -41551,8 +43760,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
* @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`.
@@ -41597,8 +43805,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
- * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
- * [iteratees=[_.identity]] The iteratees to sort by.
+ * @param {...(Function|Function[])} [iteratees=[_.identity]]
+ * The iteratees to sort by.
* @returns {Array} Returns the new sorted array.
* @example
*
@@ -41609,18 +43817,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* { 'user': 'barney', 'age': 34 }
* ];
*
- * _.sortBy(users, function(o) { return o.user; });
+ * _.sortBy(users, [function(o) { return o.user; }]);
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
*
* _.sortBy(users, ['user', 'age']);
* // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
- *
- * _.sortBy(users, 'user', function(o) {
- * return Math.floor(o.age / 10);
- * });
- * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
*/
- var sortBy = rest(function(collection, iteratees) {
+ var sortBy = baseRest(function(collection, iteratees) {
if (collection == null) {
return [];
}
@@ -41630,11 +43833,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
iteratees = [iteratees[0]];
}
- iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
- ? iteratees[0]
- : baseFlatten(iteratees, 1, isFlattenableIteratee);
-
- return baseOrderBy(collection, iteratees, []);
+ return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
});
/*------------------------------------------------------------------------*/
@@ -41655,9 +43854,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* }, _.now());
* // => Logs the number of milliseconds it took for the deferred invocation.
*/
- function now() {
- return Date.now();
- }
+ var now = ctxNow || function() {
+ return root.Date.now();
+ };
/*------------------------------------------------------------------------*/
@@ -41717,7 +43916,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
function ary(func, n, guard) {
n = guard ? undefined : n;
n = (func && n == null) ? func.length : n;
- return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n);
+ return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n);
}
/**
@@ -41735,7 +43934,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @example
*
* jQuery(element).on('click', _.before(5, addContactToList));
- * // => allows adding up to 4 contacts to the list
+ * // => Allows adding up to 4 contacts to the list.
*/
function before(n, func) {
var result;
@@ -41774,9 +43973,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Function} Returns the new bound function.
* @example
*
- * var greet = function(greeting, punctuation) {
+ * function greet(greeting, punctuation) {
* return greeting + ' ' + this.user + punctuation;
- * };
+ * }
*
* var object = { 'user': 'fred' };
*
@@ -41789,13 +43988,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* bound('hi');
* // => 'hi fred!'
*/
- var bind = rest(function(func, thisArg, partials) {
- var bitmask = BIND_FLAG;
+ var bind = baseRest(function(func, thisArg, partials) {
+ var bitmask = WRAP_BIND_FLAG;
if (partials.length) {
var holders = replaceHolders(partials, getHolder(bind));
- bitmask |= PARTIAL_FLAG;
+ bitmask |= WRAP_PARTIAL_FLAG;
}
- return createWrapper(func, bitmask, thisArg, partials, holders);
+ return createWrap(func, bitmask, thisArg, partials, holders);
});
/**
@@ -41843,13 +44042,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* bound('hi');
* // => 'hiya fred!'
*/
- var bindKey = rest(function(object, key, partials) {
- var bitmask = BIND_FLAG | BIND_KEY_FLAG;
+ var bindKey = baseRest(function(object, key, partials) {
+ var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
if (partials.length) {
var holders = replaceHolders(partials, getHolder(bindKey));
- bitmask |= PARTIAL_FLAG;
+ bitmask |= WRAP_PARTIAL_FLAG;
}
- return createWrapper(key, bitmask, object, partials, holders);
+ return createWrap(key, bitmask, object, partials, holders);
});
/**
@@ -41895,7 +44094,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function curry(func, arity, guard) {
arity = guard ? undefined : arity;
- var result = createWrapper(func, CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
+ var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curry.placeholder;
return result;
}
@@ -41940,7 +44139,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function curryRight(func, arity, guard) {
arity = guard ? undefined : arity;
- var result = createWrapper(func, CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
+ var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curryRight.placeholder;
return result;
}
@@ -41950,14 +44149,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
- * Provide an options object to indicate whether `func` should be invoked on
- * the leading and/or trailing edge of the `wait` timeout. The `func` is invoked
- * with the last arguments provided to the debounced function. Subsequent calls
- * to the debounced function return the result of the last `func` invocation.
+ * Provide `options` to indicate whether `func` should be invoked on the
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
+ * with the last arguments provided to the debounced function. Subsequent
+ * calls to the debounced function return the result of the last `func`
+ * invocation.
+ *
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
+ * invoked on the trailing edge of the timeout only if the debounced function
+ * is invoked more than once during the `wait` timeout.
*
- * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
- * on the trailing edge of the timeout only if the debounced function is
- * invoked more than once during the `wait` timeout.
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
@@ -42078,6 +44281,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
function cancel() {
+ if (timerId !== undefined) {
+ clearTimeout(timerId);
+ }
lastInvokeTime = 0;
lastArgs = lastCallTime = lastThis = timerId = undefined;
}
@@ -42130,9 +44336,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.defer(function(text) {
* console.log(text);
* }, 'deferred');
- * // => Logs 'deferred' after one or more milliseconds.
+ * // => Logs 'deferred' after one millisecond.
*/
- var defer = rest(function(func, args) {
+ var defer = baseRest(function(func, args) {
return baseDelay(func, 1, args);
});
@@ -42155,7 +44361,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* }, 1000, 'later');
* // => Logs 'later' after one second.
*/
- var delay = rest(function(func, wait, args) {
+ var delay = baseRest(function(func, wait, args) {
return baseDelay(func, toNumber(wait) || 0, args);
});
@@ -42178,7 +44384,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => ['d', 'c', 'b', 'a']
*/
function flip(func) {
- return createWrapper(func, FLIP_FLAG);
+ return createWrap(func, WRAP_FLIP_FLAG);
}
/**
@@ -42191,8 +44397,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
- * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object)
- * method interface of `delete`, `get`, `has`, and `set`.
+ * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
+ * method interface of `clear`, `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
@@ -42226,7 +44432,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
- if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
+ if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
throw new TypeError(FUNC_ERROR_TEXT);
}
var memoized = function() {
@@ -42238,14 +44444,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
return cache.get(key);
}
var result = func.apply(this, args);
- memoized.cache = cache.set(key, result);
+ memoized.cache = cache.set(key, result) || cache;
return result;
};
memoized.cache = new (memoize.Cache || MapCache);
return memoized;
}
- // Assign cache to `_.memoize`.
+ // Expose `MapCache`.
memoize.Cache = MapCache;
/**
@@ -42273,7 +44479,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {
- return !predicate.apply(this, arguments);
+ var args = arguments;
+ switch (args.length) {
+ case 0: return !predicate.call(this);
+ case 1: return !predicate.call(this, args[0]);
+ case 2: return !predicate.call(this, args[0], args[1]);
+ case 3: return !predicate.call(this, args[0], args[1], args[2]);
+ }
+ return !predicate.apply(this, args);
};
}
@@ -42293,23 +44506,22 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* var initialize = _.once(createApplication);
* initialize();
* initialize();
- * // `initialize` invokes `createApplication` once
+ * // => `createApplication` is invoked once
*/
function once(func) {
return before(2, func);
}
/**
- * Creates a function that invokes `func` with arguments transformed by
- * corresponding `transforms`.
+ * Creates a function that invokes `func` with its arguments transformed.
*
* @static
* @since 4.0.0
* @memberOf _
* @category Function
* @param {Function} func The function to wrap.
- * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
- * [transforms[_.identity]] The functions to transform.
+ * @param {...(Function|Function[])} [transforms=[_.identity]]
+ * The argument transforms.
* @returns {Function} Returns the new function.
* @example
*
@@ -42331,13 +44543,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* func(10, 5);
* // => [100, 10]
*/
- var overArgs = rest(function(func, transforms) {
+ var overArgs = castRest(function(func, transforms) {
transforms = (transforms.length == 1 && isArray(transforms[0]))
? arrayMap(transforms[0], baseUnary(getIteratee()))
- : arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseUnary(getIteratee()));
+ : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee()));
var funcsLength = transforms.length;
- return rest(function(args) {
+ return baseRest(function(args) {
var index = -1,
length = nativeMin(args.length, funcsLength);
@@ -42368,9 +44580,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Function} Returns the new partially applied function.
* @example
*
- * var greet = function(greeting, name) {
+ * function greet(greeting, name) {
* return greeting + ' ' + name;
- * };
+ * }
*
* var sayHelloTo = _.partial(greet, 'hello');
* sayHelloTo('fred');
@@ -42381,9 +44593,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* greetFred('hi');
* // => 'hi fred'
*/
- var partial = rest(function(func, partials) {
+ var partial = baseRest(function(func, partials) {
var holders = replaceHolders(partials, getHolder(partial));
- return createWrapper(func, PARTIAL_FLAG, undefined, partials, holders);
+ return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders);
});
/**
@@ -42405,9 +44617,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Function} Returns the new partially applied function.
* @example
*
- * var greet = function(greeting, name) {
+ * function greet(greeting, name) {
* return greeting + ' ' + name;
- * };
+ * }
*
* var greetFred = _.partialRight(greet, 'fred');
* greetFred('hi');
@@ -42418,9 +44630,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* sayHelloTo('fred');
* // => 'hello fred'
*/
- var partialRight = rest(function(func, partials) {
+ var partialRight = baseRest(function(func, partials) {
var holders = replaceHolders(partials, getHolder(partialRight));
- return createWrapper(func, PARTIAL_RIGHT_FLAG, undefined, partials, holders);
+ return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders);
});
/**
@@ -42445,8 +44657,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* rearged('b', 'c', 'a')
* // => ['a', 'b', 'c']
*/
- var rearg = rest(function(func, indexes) {
- return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes, 1));
+ var rearg = flatRest(function(func, indexes) {
+ return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
});
/**
@@ -42478,35 +44690,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
- start = nativeMax(start === undefined ? (func.length - 1) : toInteger(start), 0);
- return function() {
- var args = arguments,
- index = -1,
- length = nativeMax(args.length - start, 0),
- array = Array(length);
-
- while (++index < length) {
- array[index] = args[start + index];
- }
- switch (start) {
- case 0: return func.call(this, array);
- case 1: return func.call(this, args[0], array);
- case 2: return func.call(this, args[0], args[1], array);
- }
- var otherArgs = Array(start + 1);
- index = -1;
- while (++index < start) {
- otherArgs[index] = args[index];
- }
- otherArgs[start] = array;
- return apply(func, this, otherArgs);
- };
+ start = start === undefined ? start : toInteger(start);
+ return baseRest(func, start);
}
/**
* Creates a function that invokes `func` with the `this` binding of the
* create function and an array of arguments much like
- * [`Function#apply`](http://www.ecma-international.org/ecma-262/6.0/#sec-function.prototype.apply).
+ * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
*
* **Note:** This method is based on the
* [spread operator](https://mdn.io/spread_operator).
@@ -42541,8 +44732,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
- start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
- return rest(function(args) {
+ start = start == null ? 0 : nativeMax(toInteger(start), 0);
+ return baseRest(function(args) {
var array = args[start],
otherArgs = castSlice(args, 0, start);
@@ -42557,8 +44748,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* Creates a throttled function that only invokes `func` at most once per
* every `wait` milliseconds. The throttled function comes with a `cancel`
* method to cancel delayed `func` invocations and a `flush` method to
- * immediately invoke them. Provide an options object to indicate whether
- * `func` should be invoked on the leading and/or trailing edge of the `wait`
+ * immediately invoke them. Provide `options` to indicate whether `func`
+ * should be invoked on the leading and/or trailing edge of the `wait`
* timeout. The `func` is invoked with the last arguments provided to the
* throttled function. Subsequent calls to the throttled function return the
* result of the last `func` invocation.
@@ -42567,6 +44758,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* invoked on the trailing edge of the timeout only if the throttled function
* is invoked more than once during the `wait` timeout.
*
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
+ *
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.throttle` and `_.debounce`.
*
@@ -42632,10 +44826,10 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * Creates a function that provides `value` to the wrapper function as its
- * first argument. Any additional arguments provided to the function are
- * appended to those provided to the wrapper function. The wrapper is invoked
- * with the `this` binding of the created function.
+ * Creates a function that provides `value` to `wrapper` as its first
+ * argument. Any additional arguments provided to the function are appended
+ * to those provided to the `wrapper`. The wrapper is invoked with the `this`
+ * binding of the created function.
*
* @static
* @memberOf _
@@ -42654,8 +44848,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => '<p>fred, barney, &amp; pebbles</p>'
*/
function wrap(value, wrapper) {
- wrapper = wrapper == null ? identity : wrapper;
- return partial(wrapper, value);
+ return partial(castFunction(wrapper), value);
}
/*------------------------------------------------------------------------*/
@@ -42728,7 +44921,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => true
*/
function clone(value) {
- return baseClone(value, false, true);
+ return baseClone(value, CLONE_SYMBOLS_FLAG);
}
/**
@@ -42763,7 +44956,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 0
*/
function cloneWith(value, customizer) {
- return baseClone(value, false, true, customizer);
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
}
/**
@@ -42785,7 +44979,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => false
*/
function cloneDeep(value) {
- return baseClone(value, true, true);
+ return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
}
/**
@@ -42817,12 +45011,41 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 20
*/
function cloneDeepWith(value, customizer) {
- return baseClone(value, true, true, customizer);
+ customizer = typeof customizer == 'function' ? customizer : undefined;
+ return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
+ }
+
+ /**
+ * Checks if `object` conforms to `source` by invoking the predicate
+ * properties of `source` with the corresponding property values of `object`.
+ *
+ * **Note:** This method is equivalent to `_.conforms` when `source` is
+ * partially applied.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.14.0
+ * @category Lang
+ * @param {Object} object The object to inspect.
+ * @param {Object} source The object of property predicates to conform to.
+ * @returns {boolean} Returns `true` if `object` conforms, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1, 'b': 2 };
+ *
+ * _.conformsTo(object, { 'b': function(n) { return n > 1; } });
+ * // => true
+ *
+ * _.conformsTo(object, { 'b': function(n) { return n > 2; } });
+ * // => false
+ */
+ function conformsTo(object, source) {
+ return source == null || baseConformsTo(object, source, keys(source));
}
/**
* Performs a
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
@@ -42834,8 +45057,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
- * var object = { 'user': 'fred' };
- * var other = { 'user': 'fred' };
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
@@ -42916,7 +45139,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
* else `false`.
* @example
*
@@ -42926,11 +45149,10 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.isArguments([1, 2, 3]);
* // => false
*/
- function isArguments(value) {
- // Safari 8.1 incorrectly makes `arguments.callee` enumerable in strict mode.
- return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
- (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
- }
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
+ return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
+ !propertyIsEnumerable.call(value, 'callee');
+ };
/**
* Checks if `value` is classified as an `Array` object.
@@ -42938,11 +45160,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @static
* @memberOf _
* @since 0.1.0
- * @type {Function}
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
@@ -42967,8 +45187,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`.
* @example
*
* _.isArrayBuffer(new ArrayBuffer(2));
@@ -42977,9 +45196,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.isArrayBuffer(new Array(2));
* // => false
*/
- function isArrayBuffer(value) {
- return isObjectLike(value) && objectToString.call(value) == arrayBufferTag;
- }
+ var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer;
/**
* Checks if `value` is array-like. A value is considered array-like if it's
@@ -43007,7 +45224,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => false
*/
function isArrayLike(value) {
- return value != null && isLength(getLength(value)) && !isFunction(value);
+ return value != null && isLength(value.length) && !isFunction(value);
}
/**
@@ -43047,8 +45264,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a boolean, else `false`.
* @example
*
* _.isBoolean(false);
@@ -43059,7 +45275,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function isBoolean(value) {
return value === true || value === false ||
- (isObjectLike(value) && objectToString.call(value) == boolTag);
+ (isObjectLike(value) && baseGetTag(value) == boolTag);
}
/**
@@ -43079,9 +45295,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.isBuffer(new Uint8Array(2));
* // => false
*/
- var isBuffer = !Buffer ? stubFalse : function(value) {
- return value instanceof Buffer;
- };
+ var isBuffer = nativeIsBuffer || stubFalse;
/**
* Checks if `value` is classified as a `Date` object.
@@ -43091,8 +45305,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a date object, else `false`.
* @example
*
* _.isDate(new Date);
@@ -43101,9 +45314,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.isDate('Mon April 23 2012');
* // => false
*/
- function isDate(value) {
- return isObjectLike(value) && objectToString.call(value) == dateTag;
- }
+ var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate;
/**
* Checks if `value` is likely a DOM element.
@@ -43113,8 +45324,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a DOM element,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`.
* @example
*
* _.isElement(document.body);
@@ -43124,7 +45334,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => false
*/
function isElement(value) {
- return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value);
+ return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value);
}
/**
@@ -43161,23 +45371,27 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => false
*/
function isEmpty(value) {
+ if (value == null) {
+ return true;
+ }
if (isArrayLike(value) &&
- (isArray(value) || isString(value) || isFunction(value.splice) ||
- isArguments(value) || isBuffer(value))) {
+ (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
+ isBuffer(value) || isTypedArray(value) || isArguments(value))) {
return !value.length;
}
- if (isObjectLike(value)) {
- var tag = getTag(value);
- if (tag == mapTag || tag == setTag) {
- return !value.size;
- }
+ var tag = getTag(value);
+ if (tag == mapTag || tag == setTag) {
+ return !value.size;
+ }
+ if (isPrototype(value)) {
+ return !baseKeys(value).length;
}
for (var key in value) {
if (hasOwnProperty.call(value, key)) {
return false;
}
}
- return !(nonEnumShadows && keys(value).length);
+ return true;
}
/**
@@ -43188,7 +45402,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* date objects, error objects, maps, numbers, `Object` objects, regexes,
* sets, strings, symbols, and typed arrays. `Object` objects are compared
* by their own, not inherited, enumerable properties. Functions and DOM
- * nodes are **not** supported.
+ * nodes are compared by strict equality, i.e. `===`.
*
* @static
* @memberOf _
@@ -43196,12 +45410,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
- * @returns {boolean} Returns `true` if the values are equivalent,
- * else `false`.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
- * var object = { 'user': 'fred' };
- * var other = { 'user': 'fred' };
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
*
* _.isEqual(object, other);
* // => true
@@ -43226,8 +45439,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @param {Function} [customizer] The function to customize comparisons.
- * @returns {boolean} Returns `true` if the values are equivalent,
- * else `false`.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* function isGreeting(value) {
@@ -43249,7 +45461,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
function isEqualWith(value, other, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
var result = customizer ? customizer(value, other) : undefined;
- return result === undefined ? baseIsEqual(value, other, customizer) : !!result;
+ return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result;
}
/**
@@ -43261,8 +45473,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an error object,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is an error object, else `false`.
* @example
*
* _.isError(new Error);
@@ -43275,8 +45486,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
if (!isObjectLike(value)) {
return false;
}
- return (objectToString.call(value) == errorTag) ||
- (typeof value.message == 'string' && typeof value.name == 'string');
+ var tag = baseGetTag(value);
+ return tag == errorTag || tag == domExcTag ||
+ (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value));
}
/**
@@ -43290,8 +45502,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a finite number,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a finite number, else `false`.
* @example
*
* _.isFinite(3);
@@ -43318,8 +45529,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
@@ -43329,11 +45539,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => false
*/
function isFunction(value) {
+ if (!isObject(value)) {
+ return false;
+ }
// The use of `Object#toString` avoids issues with the `typeof` operator
- // in Safari 8 which returns 'object' for typed array and weak map constructors,
- // and PhantomJS 1.9 which returns 'function' for `NodeList` instances.
- var tag = isObject(value) ? objectToString.call(value) : '';
- return tag == funcTag || tag == genTag;
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
+ var tag = baseGetTag(value);
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
}
/**
@@ -43369,16 +45581,15 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* Checks if `value` is a valid array-like length.
*
- * **Note:** This function is loosely based on
- * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
+ * **Note:** This method is loosely based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
* @example
*
* _.isLength(3);
@@ -43400,7 +45611,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* Checks if `value` is the
- * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types)
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
@@ -43425,7 +45636,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function isObject(value) {
var type = typeof value;
- return !!value && (type == 'object' || type == 'function');
+ return value != null && (type == 'object' || type == 'function');
}
/**
@@ -43453,7 +45664,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => false
*/
function isObjectLike(value) {
- return !!value && typeof value == 'object';
+ return value != null && typeof value == 'object';
}
/**
@@ -43464,8 +45675,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a map, else `false`.
* @example
*
* _.isMap(new Map);
@@ -43474,16 +45684,18 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.isMap(new WeakMap);
* // => false
*/
- function isMap(value) {
- return isObjectLike(value) && getTag(value) == mapTag;
- }
+ var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
/**
* Performs a partial deep comparison between `object` and `source` to
- * determine if `object` contains equivalent property values. This method is
- * equivalent to a `_.matches` function when `source` is partially applied.
+ * determine if `object` contains equivalent property values.
+ *
+ * **Note:** This method is equivalent to `_.matches` when `source` is
+ * partially applied.
*
- * **Note:** This method supports comparing the same values as `_.isEqual`.
+ * Partial comparisons will match empty array and empty object `source`
+ * values against any array or object value, respectively. See `_.isEqual`
+ * for a list of supported value comparisons.
*
* @static
* @memberOf _
@@ -43494,12 +45706,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {boolean} Returns `true` if `object` is a match, else `false`.
* @example
*
- * var object = { 'user': 'fred', 'age': 40 };
+ * var object = { 'a': 1, 'b': 2 };
*
- * _.isMatch(object, { 'age': 40 });
+ * _.isMatch(object, { 'b': 2 });
* // => true
*
- * _.isMatch(object, { 'age': 36 });
+ * _.isMatch(object, { 'b': 1 });
* // => false
*/
function isMatch(object, source) {
@@ -43581,13 +45793,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* Checks if `value` is a pristine native function.
*
- * **Note:** This method can't reliably detect native functions in the
- * presence of the `core-js` package because `core-js` circumvents this kind
- * of detection. Despite multiple requests, the `core-js` maintainer has made
- * it clear: any attempt to fix the detection will be obstructed. As a result,
- * we're left with little choice but to throw an error. Unfortunately, this
- * also affects packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
- * which rely on `core-js`.
+ * **Note:** This method can't reliably detect native functions in the presence
+ * of the core-js package because core-js circumvents this kind of detection.
+ * Despite multiple requests, the core-js maintainer has made it clear: any
+ * attempt to fix the detection will be obstructed. As a result, we're left
+ * with little choice but to throw an error. Unfortunately, this also affects
+ * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill),
+ * which rely on core-js.
*
* @static
* @memberOf _
@@ -43606,7 +45818,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function isNative(value) {
if (isMaskable(value)) {
- throw new Error('This method is not supported with `core-js`. Try https://github.com/es-shims.');
+ throw new Error(CORE_ERROR_TEXT);
}
return baseIsNative(value);
}
@@ -43667,8 +45879,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a number, else `false`.
* @example
*
* _.isNumber(3);
@@ -43685,7 +45896,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function isNumber(value) {
return typeof value == 'number' ||
- (isObjectLike(value) && objectToString.call(value) == numberTag);
+ (isObjectLike(value) && baseGetTag(value) == numberTag);
}
/**
@@ -43697,8 +45908,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.8.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a plain object,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
* @example
*
* function Foo() {
@@ -43718,8 +45928,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => true
*/
function isPlainObject(value) {
- if (!isObjectLike(value) ||
- objectToString.call(value) != objectTag || isHostObject(value)) {
+ if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
return false;
}
var proto = getPrototype(value);
@@ -43727,8 +45936,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
return true;
}
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
- return (typeof Ctor == 'function' &&
- Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
+ return typeof Ctor == 'function' && Ctor instanceof Ctor &&
+ funcToString.call(Ctor) == objectCtorString;
}
/**
@@ -43739,8 +45948,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a regexp, else `false`.
* @example
*
* _.isRegExp(/abc/);
@@ -43749,9 +45957,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.isRegExp('/abc/');
* // => false
*/
- function isRegExp(value) {
- return isObject(value) && objectToString.call(value) == regexpTag;
- }
+ var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp;
/**
* Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754
@@ -43765,8 +45971,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a safe integer,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`.
* @example
*
* _.isSafeInteger(3);
@@ -43793,8 +45998,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a set, else `false`.
* @example
*
* _.isSet(new Set);
@@ -43803,9 +46007,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.isSet(new WeakSet);
* // => false
*/
- function isSet(value) {
- return isObjectLike(value) && getTag(value) == setTag;
- }
+ var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
/**
* Checks if `value` is classified as a `String` primitive or object.
@@ -43815,8 +46017,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a string, else `false`.
* @example
*
* _.isString('abc');
@@ -43827,7 +46028,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function isString(value) {
return typeof value == 'string' ||
- (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
+ (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag);
}
/**
@@ -43838,8 +46039,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
@@ -43850,7 +46050,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function isSymbol(value) {
return typeof value == 'symbol' ||
- (isObjectLike(value) && objectToString.call(value) == symbolTag);
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
}
/**
@@ -43861,8 +46061,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
* @example
*
* _.isTypedArray(new Uint8Array);
@@ -43871,10 +46070,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.isTypedArray([]);
* // => false
*/
- function isTypedArray(value) {
- return isObjectLike(value) &&
- isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
- }
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
/**
* Checks if `value` is `undefined`.
@@ -43905,8 +46101,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a weak map, else `false`.
* @example
*
* _.isWeakMap(new WeakMap);
@@ -43927,8 +46122,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified,
- * else `false`.
+ * @returns {boolean} Returns `true` if `value` is a weak set, else `false`.
* @example
*
* _.isWeakSet(new WeakSet);
@@ -43938,7 +46132,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => false
*/
function isWeakSet(value) {
- return isObjectLike(value) && objectToString.call(value) == weakSetTag;
+ return isObjectLike(value) && baseGetTag(value) == weakSetTag;
}
/**
@@ -44023,8 +46217,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
if (isArrayLike(value)) {
return isString(value) ? stringToArray(value) : copyArray(value);
}
- if (iteratorSymbol && value[iteratorSymbol]) {
- return iteratorToArray(value[iteratorSymbol]());
+ if (symIterator && value[symIterator]) {
+ return iteratorToArray(value[symIterator]());
}
var tag = getTag(value),
func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values);
@@ -44071,7 +46265,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* Converts `value` to an integer.
*
* **Note:** This method is loosely based on
- * [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger).
+ * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger).
*
* @static
* @memberOf _
@@ -44105,7 +46299,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* array-like object.
*
* **Note:** This method is based on
- * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
*
* @static
* @memberOf _
@@ -44162,7 +46356,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
return NAN;
}
if (isObject(value)) {
- var other = isFunction(value.valueOf) ? value.valueOf() : value;
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
value = isObject(other) ? (other + '') : other;
}
if (typeof value != 'string') {
@@ -44228,7 +46422,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 3
*/
function toSafeInteger(value) {
- return baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
+ return value
+ ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER)
+ : (value === 0 ? value : 0);
}
/**
@@ -44239,8 +46435,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 4.0.0
* @category Lang
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
* @example
*
* _.toString(null);
@@ -44277,21 +46473,21 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @example
*
* function Foo() {
- * this.c = 3;
+ * this.a = 1;
* }
*
* function Bar() {
- * this.e = 5;
+ * this.c = 3;
* }
*
- * Foo.prototype.d = 4;
- * Bar.prototype.f = 6;
+ * Foo.prototype.b = 2;
+ * Bar.prototype.d = 4;
*
- * _.assign({ 'a': 1 }, new Foo, new Bar);
- * // => { 'a': 1, 'c': 3, 'e': 5 }
+ * _.assign({ 'a': 0 }, new Foo, new Bar);
+ * // => { 'a': 1, 'c': 3 }
*/
var assign = createAssigner(function(object, source) {
- if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
+ if (isPrototype(source) || isArrayLike(source)) {
copyObject(source, keys(source), object);
return;
}
@@ -44320,27 +46516,21 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @example
*
* function Foo() {
- * this.b = 2;
+ * this.a = 1;
* }
*
* function Bar() {
- * this.d = 4;
+ * this.c = 3;
* }
*
- * Foo.prototype.c = 3;
- * Bar.prototype.e = 5;
+ * Foo.prototype.b = 2;
+ * Bar.prototype.d = 4;
*
- * _.assignIn({ 'a': 1 }, new Foo, new Bar);
- * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
+ * _.assignIn({ 'a': 0 }, new Foo, new Bar);
+ * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
*/
var assignIn = createAssigner(function(object, source) {
- if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
- copyObject(source, keysIn(source), object);
- return;
- }
- for (var key in source) {
- assignValue(object, key, source[key]);
- }
+ copyObject(source, keysIn(source), object);
});
/**
@@ -44416,7 +46606,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 1.0.0
* @category Object
* @param {Object} object The object to iterate over.
- * @param {...(string|string[])} [paths] The property paths of elements to pick.
+ * @param {...(string|string[])} [paths] The property paths to pick.
* @returns {Array} Returns the picked values.
* @example
*
@@ -44425,9 +46615,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.at(object, ['a[0].b.c', 'a[1]']);
* // => [3, 4]
*/
- var at = rest(function(object, paths) {
- return baseAt(object, baseFlatten(paths, 1));
- });
+ var at = flatRest(baseAt);
/**
* Creates an object that inherits from the `prototype` object. If a
@@ -44465,7 +46653,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function create(prototype, properties) {
var result = baseCreate(prototype);
- return properties ? baseAssign(result, properties) : result;
+ return properties == null ? result : baseAssign(result, properties);
}
/**
@@ -44486,11 +46674,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @see _.defaultsDeep
* @example
*
- * _.defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
- * // => { 'user': 'barney', 'age': 36 }
+ * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
+ * // => { 'a': 1, 'b': 2 }
*/
- var defaults = rest(function(args) {
- args.push(undefined, assignInDefaults);
+ var defaults = baseRest(function(args) {
+ args.push(undefined, customDefaultsAssignIn);
return apply(assignInWith, undefined, args);
});
@@ -44510,12 +46698,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @see _.defaults
* @example
*
- * _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } });
- * // => { 'user': { 'name': 'barney', 'age': 36 } }
- *
+ * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
+ * // => { 'a': { 'b': 2, 'c': 3 } }
*/
- var defaultsDeep = rest(function(args) {
- args.push(undefined, mergeDefaults);
+ var defaultsDeep = baseRest(function(args) {
+ args.push(undefined, customDefaultsMerge);
return apply(mergeWith, undefined, args);
});
@@ -44527,9 +46714,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 1.1.0
* @category Object
- * @param {Object} object The object to search.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Object} object The object to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {string|undefined} Returns the key of the matched element,
* else `undefined`.
* @example
@@ -44567,9 +46753,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 2.0.0
* @category Object
- * @param {Object} object The object to search.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per iteration.
+ * @param {Object} object The object to inspect.
+ * @param {Function} [predicate=_.identity] The function invoked per iteration.
* @returns {string|undefined} Returns the key of the matched element,
* else `undefined`.
* @example
@@ -44783,7 +46968,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* Gets the value at `path` of `object`. If the resolved value is
- * `undefined`, the `defaultValue` is used in its place.
+ * `undefined`, the `defaultValue` is returned in its place.
*
* @static
* @memberOf _
@@ -44906,8 +47091,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.1.0
* @category Object
* @param {Object} object The object to invert.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Object} Returns the new inverted object.
* @example
*
@@ -44947,13 +47131,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.invoke(object, 'a[0].b.c.slice', 1, 3);
* // => [2, 3]
*/
- var invoke = rest(baseInvoke);
+ var invoke = baseRest(baseInvoke);
/**
* Creates an array of the own enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects. See the
- * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
* for more details.
*
* @static
@@ -44978,23 +47162,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => ['0', '1']
*/
function keys(object) {
- var isProto = isPrototype(object);
- if (!(isProto || isArrayLike(object))) {
- return baseKeys(object);
- }
- var indexes = indexKeys(object),
- skipIndexes = !!indexes,
- result = indexes || [],
- length = result.length;
-
- for (var key in object) {
- if (baseHas(object, key) &&
- !(skipIndexes && (key == 'length' || isIndex(key, length))) &&
- !(isProto && key == 'constructor')) {
- result.push(key);
- }
- }
- return result;
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
}
/**
@@ -45021,23 +47189,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
*/
function keysIn(object) {
- var index = -1,
- isProto = isPrototype(object),
- props = baseKeysIn(object),
- propsLength = props.length,
- indexes = indexKeys(object),
- skipIndexes = !!indexes,
- result = indexes || [],
- length = result.length;
-
- while (++index < propsLength) {
- var key = props[index];
- if (!(skipIndexes && (key == 'length' || isIndex(key, length))) &&
- !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
- result.push(key);
- }
- }
- return result;
+ return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
}
/**
@@ -45051,8 +47203,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 3.8.0
* @category Object
* @param {Object} object The object to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns the new mapped object.
* @see _.mapValues
* @example
@@ -45067,7 +47218,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
iteratee = getIteratee(iteratee, 3);
baseForOwn(object, function(value, key, object) {
- result[iteratee(value, key, object)] = value;
+ baseAssignValue(result, iteratee(value, key, object), value);
});
return result;
}
@@ -45083,8 +47234,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 2.4.0
* @category Object
* @param {Object} object The object to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The function invoked per iteration.
+ * @param {Function} [iteratee=_.identity] The function invoked per iteration.
* @returns {Object} Returns the new mapped object.
* @see _.mapKeys
* @example
@@ -45106,7 +47256,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
iteratee = getIteratee(iteratee, 3);
baseForOwn(object, function(value, key, object) {
- result[key] = iteratee(value, key, object);
+ baseAssignValue(result, key, iteratee(value, key, object));
});
return result;
}
@@ -45131,16 +47281,16 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Object} Returns `object`.
* @example
*
- * var users = {
- * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
+ * var object = {
+ * 'a': [{ 'b': 2 }, { 'd': 4 }]
* };
*
- * var ages = {
- * 'data': [{ 'age': 36 }, { 'age': 40 }]
+ * var other = {
+ * 'a': [{ 'c': 3 }, { 'e': 5 }]
* };
*
- * _.merge(users, ages);
- * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
+ * _.merge(object, other);
+ * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
*/
var merge = createAssigner(function(object, source, srcIndex) {
baseMerge(object, source, srcIndex);
@@ -45150,7 +47300,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* This method is like `_.merge` except that it accepts `customizer` which
* is invoked to produce the merged values of the destination and source
* properties. If `customizer` returns `undefined`, merging is handled by the
- * method instead. The `customizer` is invoked with seven arguments:
+ * method instead. The `customizer` is invoked with six arguments:
* (objValue, srcValue, key, object, source, stack).
*
* **Note:** This method mutates `object`.
@@ -45171,18 +47321,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* }
* }
*
- * var object = {
- * 'fruits': ['apple'],
- * 'vegetables': ['beet']
- * };
- *
- * var other = {
- * 'fruits': ['banana'],
- * 'vegetables': ['carrot']
- * };
+ * var object = { 'a': [1], 'b': [2] };
+ * var other = { 'a': [3], 'b': [4] };
*
* _.mergeWith(object, other, customizer);
- * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
+ * // => { 'a': [1, 3], 'b': [2, 4] }
*/
var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
baseMerge(object, source, srcIndex, customizer);
@@ -45190,15 +47333,16 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* The opposite of `_.pick`; this method creates an object composed of the
- * own and inherited enumerable string keyed properties of `object` that are
- * not omitted.
+ * own and inherited enumerable property paths of `object` that are not omitted.
+ *
+ * **Note:** This method is considerably slower than `_.pick`.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The source object.
- * @param {...(string|string[])} [props] The property identifiers to omit.
+ * @param {...(string|string[])} [paths] The property paths to omit.
* @returns {Object} Returns the new object.
* @example
*
@@ -45207,12 +47351,26 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.omit(object, ['a', 'c']);
* // => { 'b': '2' }
*/
- var omit = rest(function(object, props) {
+ var omit = flatRest(function(object, paths) {
+ var result = {};
if (object == null) {
- return {};
+ return result;
+ }
+ var isDeep = false;
+ paths = arrayMap(paths, function(path) {
+ path = castPath(path, object);
+ isDeep || (isDeep = path.length > 1);
+ return path;
+ });
+ copyObject(object, getAllKeysIn(object), result);
+ if (isDeep) {
+ result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
}
- props = arrayMap(baseFlatten(props, 1), toKey);
- return basePick(object, baseDifference(getAllKeysIn(object), props));
+ var length = paths.length;
+ while (length--) {
+ baseUnset(result, paths[length]);
+ }
+ return result;
});
/**
@@ -45226,8 +47384,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.0.0
* @category Object
* @param {Object} object The source object.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per property.
+ * @param {Function} [predicate=_.identity] The function invoked per property.
* @returns {Object} Returns the new object.
* @example
*
@@ -45237,10 +47394,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => { 'b': '2' }
*/
function omitBy(object, predicate) {
- predicate = getIteratee(predicate);
- return basePickBy(object, function(value, key) {
- return !predicate(value, key);
- });
+ return pickBy(object, negate(getIteratee(predicate)));
}
/**
@@ -45251,7 +47405,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @category Object
* @param {Object} object The source object.
- * @param {...(string|string[])} [props] The property identifiers to pick.
+ * @param {...(string|string[])} [paths] The property paths to pick.
* @returns {Object} Returns the new object.
* @example
*
@@ -45260,8 +47414,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.pick(object, ['a', 'c']);
* // => { 'a': 1, 'c': 3 }
*/
- var pick = rest(function(object, props) {
- return object == null ? {} : basePick(object, arrayMap(baseFlatten(props, 1), toKey));
+ var pick = flatRest(function(object, paths) {
+ return object == null ? {} : basePick(object, paths);
});
/**
@@ -45273,8 +47427,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.0.0
* @category Object
* @param {Object} object The source object.
- * @param {Array|Function|Object|string} [predicate=_.identity]
- * The function invoked per property.
+ * @param {Function} [predicate=_.identity] The function invoked per property.
* @returns {Object} Returns the new object.
* @example
*
@@ -45284,7 +47437,16 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => { 'a': 1, 'c': 3 }
*/
function pickBy(object, predicate) {
- return object == null ? {} : basePickBy(object, getIteratee(predicate));
+ if (object == null) {
+ return {};
+ }
+ var props = arrayMap(getAllKeysIn(object), function(prop) {
+ return [prop];
+ });
+ predicate = getIteratee(predicate);
+ return basePickBy(object, props, function(value, path) {
+ return predicate(value, path[0]);
+ });
}
/**
@@ -45317,15 +47479,15 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 'default'
*/
function result(object, path, defaultValue) {
- path = isKey(path, object) ? [path] : castPath(path);
+ path = castPath(path, object);
var index = -1,
length = path.length;
// Ensure the loop is entered when path is empty.
if (!length) {
- object = undefined;
length = 1;
+ object = undefined;
}
while (++index < length) {
var value = object == null ? undefined : object[toKey(path[index])];
@@ -45482,22 +47644,23 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => { '1': ['a', 'c'], '2': ['b'] }
*/
function transform(object, iteratee, accumulator) {
- var isArr = isArray(object) || isTypedArray(object);
- iteratee = getIteratee(iteratee, 4);
+ var isArr = isArray(object),
+ isArrLike = isArr || isBuffer(object) || isTypedArray(object);
+ iteratee = getIteratee(iteratee, 4);
if (accumulator == null) {
- if (isArr || isObject(object)) {
- var Ctor = object.constructor;
- if (isArr) {
- accumulator = isArray(object) ? new Ctor : [];
- } else {
- accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
- }
- } else {
+ var Ctor = object && object.constructor;
+ if (isArrLike) {
+ accumulator = isArr ? new Ctor : [];
+ }
+ else if (isObject(object)) {
+ accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {};
+ }
+ else {
accumulator = {};
}
}
- (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {
+ (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) {
return iteratee(accumulator, value, index, object);
});
return accumulator;
@@ -45621,7 +47784,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => ['h', 'i']
*/
function values(object) {
- return object ? baseValues(object, keys(object)) : [];
+ return object == null ? [] : baseValues(object, keys(object));
}
/**
@@ -45728,12 +47891,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => true
*/
function inRange(number, start, end) {
- start = toNumber(start) || 0;
+ start = toFinite(start);
if (end === undefined) {
end = start;
start = 0;
} else {
- end = toNumber(end) || 0;
+ end = toFinite(end);
}
number = toNumber(number);
return baseInRange(number, start, end);
@@ -45789,12 +47952,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
upper = 1;
}
else {
- lower = toNumber(lower) || 0;
+ lower = toFinite(lower);
if (upper === undefined) {
upper = lower;
lower = 0;
} else {
- upper = toNumber(upper) || 0;
+ upper = toFinite(upper);
}
}
if (lower > upper) {
@@ -45857,8 +48020,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* Deburrs `string` by converting
- * [latin-1 supplementary letters](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
- * to basic latin letters and removing
+ * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table)
+ * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A)
+ * letters to basic Latin letters and removing
* [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks).
*
* @static
@@ -45874,7 +48038,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function deburr(string) {
string = toString(string);
- return string && string.replace(reLatin1, deburrLetter).replace(reComboMark, '');
+ return string && string.replace(reLatin, deburrLetter).replace(reComboMark, '');
}
/**
@@ -45884,7 +48048,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 3.0.0
* @category String
- * @param {string} [string=''] The string to search.
+ * @param {string} [string=''] The string to inspect.
* @param {string} [target] The string to search for.
* @param {number} [position=string.length] The position to search up to.
* @returns {boolean} Returns `true` if `string` ends with `target`,
@@ -45909,13 +48073,14 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
? length
: baseClamp(toInteger(position), 0, length);
+ var end = position;
position -= target.length;
- return position >= 0 && string.indexOf(target, position) == position;
+ return position >= 0 && string.slice(position, end) == target;
}
/**
- * Converts the characters "&", "<", ">", '"', "'", and "\`" in `string` to
- * their corresponding HTML entities.
+ * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
+ * corresponding HTML entities.
*
* **Note:** No other characters are escaped. To escape additional
* characters use a third-party library like [_he_](https://mths.be/he).
@@ -45926,12 +48091,6 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands)
* (under "semi-related fun fact") for more details.
*
- * Backticks are escaped because in IE < 9, they can break out of
- * attribute values or HTML comments. See [#59](https://html5sec.org/#59),
- * [#102](https://html5sec.org/#102), [#108](https://html5sec.org/#108), and
- * [#133](https://html5sec.org/#133) of the
- * [HTML5 Security Cheatsheet](https://html5sec.org/) for more details.
- *
* When working with HTML you should always
* [quote attribute values](http://wonko.com/post/html-escaping) to reduce
* XSS vectors.
@@ -46174,15 +48333,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => [6, 8, 10]
*/
function parseInt(string, radix, guard) {
- // Chrome fails to trim leading <BOM> whitespace characters.
- // See https://bugs.chromium.org/p/v8/issues/detail?id=3109 for more details.
if (guard || radix == null) {
radix = 0;
} else if (radix) {
radix = +radix;
}
- string = toString(string).replace(reTrim, '');
- return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
+ return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
}
/**
@@ -46239,7 +48395,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var args = arguments,
string = toString(args[0]);
- return args.length < 3 ? string : nativeReplace.call(string, args[1], args[2]);
+ return args.length < 3 ? string : string.replace(args[1], args[2]);
}
/**
@@ -46300,11 +48456,11 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
(separator != null && !isRegExp(separator))
)) {
separator = baseToString(separator);
- if (separator == '' && reHasComplexSymbol.test(string)) {
+ if (!separator && hasUnicode(string)) {
return castSlice(stringToArray(string), 0, limit);
}
}
- return nativeSplit.call(string, separator, limit);
+ return string.split(separator, limit);
}
/**
@@ -46339,7 +48495,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 3.0.0
* @category String
- * @param {string} [string=''] The string to search.
+ * @param {string} [string=''] The string to inspect.
* @param {string} [target] The string to search for.
* @param {number} [position=0] The position to search from.
* @returns {boolean} Returns `true` if `string` starts with `target`,
@@ -46357,8 +48513,12 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function startsWith(string, target, position) {
string = toString(string);
- position = baseClamp(toInteger(position), 0, string.length);
- return string.lastIndexOf(baseToString(target), position) == position;
+ position = position == null
+ ? 0
+ : baseClamp(toInteger(position), 0, string.length);
+
+ target = baseToString(target);
+ return string.slice(position, position + target.length) == target;
}
/**
@@ -46420,7 +48580,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* compiled({ 'user': 'barney' });
* // => 'hello barney!'
*
- * // Use the ES delimiter as an alternative to the default "interpolate" delimiter.
+ * // Use the ES template literal delimiter as an "interpolate" delimiter.
+ * // Disable support by replacing the "interpolate" delimiter.
* var compiled = _.template('hello ${ user }!');
* compiled({ 'user': 'pebbles' });
* // => 'hello pebbles!'
@@ -46474,9 +48635,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
options = undefined;
}
string = toString(string);
- options = assignInWith({}, options, settings, assignInDefaults);
+ options = assignInWith({}, options, settings, customDefaultsAssignIn);
- var imports = assignInWith({}, options.imports, settings.imports, assignInDefaults),
+ var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn),
importsKeys = keys(imports),
importsValues = baseValues(imports, importsKeys);
@@ -46775,7 +48936,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
string = toString(string);
var strLength = string.length;
- if (reHasComplexSymbol.test(string)) {
+ if (hasUnicode(string)) {
var strSymbols = stringToArray(string);
strLength = strSymbols.length;
}
@@ -46821,7 +48982,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
/**
* The inverse of `_.escape`; this method converts the HTML entities
- * `&amp;`, `&lt;`, `&gt;`, `&quot;`, `&#39;`, and `&#96;` in `string` to
+ * `&amp;`, `&lt;`, `&gt;`, `&quot;`, and `&#39;` in `string` to
* their corresponding characters.
*
* **Note:** No other HTML entities are unescaped. To unescape additional
@@ -46912,7 +49073,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
pattern = guard ? undefined : pattern;
if (pattern === undefined) {
- pattern = reHasComplexWord.test(string) ? reComplexWord : reBasicWord;
+ return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
}
return string.match(pattern) || [];
}
@@ -46941,7 +49102,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* elements = [];
* }
*/
- var attempt = rest(function(func, args) {
+ var attempt = baseRest(function(func, args) {
try {
return apply(func, undefined, args);
} catch (e) {
@@ -46966,19 +49127,19 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*
* var view = {
* 'label': 'docs',
- * 'onClick': function() {
+ * 'click': function() {
* console.log('clicked ' + this.label);
* }
* };
*
- * _.bindAll(view, ['onClick']);
- * jQuery(element).on('click', view.onClick);
+ * _.bindAll(view, ['click']);
+ * jQuery(element).on('click', view.click);
* // => Logs 'clicked docs' when clicked.
*/
- var bindAll = rest(function(object, methodNames) {
- arrayEach(baseFlatten(methodNames, 1), function(key) {
+ var bindAll = flatRest(function(object, methodNames) {
+ arrayEach(methodNames, function(key) {
key = toKey(key);
- object[key] = bind(object[key], object);
+ baseAssignValue(object, key, bind(object[key], object));
});
return object;
});
@@ -47000,7 +49161,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* var func = _.cond([
* [_.matches({ 'a': 1 }), _.constant('matches A')],
* [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
- * [_.constant(true), _.constant('no match')]
+ * [_.stubTrue, _.constant('no match')]
* ]);
*
* func({ 'a': 1, 'b': 2 });
@@ -47013,7 +49174,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 'no match'
*/
function cond(pairs) {
- var length = pairs ? pairs.length : 0,
+ var length = pairs == null ? 0 : pairs.length,
toIteratee = getIteratee();
pairs = !length ? [] : arrayMap(pairs, function(pair) {
@@ -47023,7 +49184,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
return [toIteratee(pair[0]), pair[1]];
});
- return rest(function(args) {
+ return baseRest(function(args) {
var index = -1;
while (++index < length) {
var pair = pairs[index];
@@ -47039,6 +49200,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* the corresponding property values of a given object, returning `true` if
* all predicates return truthy, else `false`.
*
+ * **Note:** The created function is equivalent to `_.conformsTo` with
+ * `source` partially applied.
+ *
* @static
* @memberOf _
* @since 4.0.0
@@ -47047,16 +49211,16 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Function} Returns the new spec function.
* @example
*
- * var users = [
- * { 'user': 'barney', 'age': 36 },
- * { 'user': 'fred', 'age': 40 }
+ * var objects = [
+ * { 'a': 2, 'b': 1 },
+ * { 'a': 1, 'b': 2 }
* ];
*
- * _.filter(users, _.conforms({ 'age': function(n) { return n > 38; } }));
- * // => [{ 'user': 'fred', 'age': 40 }]
+ * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } }));
+ * // => [{ 'a': 1, 'b': 2 }]
*/
function conforms(source) {
- return baseConforms(baseClone(source, true));
+ return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
}
/**
@@ -47085,6 +49249,30 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
+ * Checks `value` to determine whether a default value should be returned in
+ * its place. The `defaultValue` is returned if `value` is `NaN`, `null`,
+ * or `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.14.0
+ * @category Util
+ * @param {*} value The value to check.
+ * @param {*} defaultValue The default value.
+ * @returns {*} Returns the resolved value.
+ * @example
+ *
+ * _.defaultTo(1, 10);
+ * // => 1
+ *
+ * _.defaultTo(undefined, 10);
+ * // => 10
+ */
+ function defaultTo(value, defaultValue) {
+ return (value == null || value !== value) ? defaultValue : value;
+ }
+
+ /**
* Creates a function that returns the result of invoking the given functions
* with the `this` binding of the created function, where each successive
* invocation is supplied the return value of the previous.
@@ -47093,7 +49281,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 3.0.0
* @category Util
- * @param {...(Function|Function[])} [funcs] Functions to invoke.
+ * @param {...(Function|Function[])} [funcs] The functions to invoke.
* @returns {Function} Returns the new composite function.
* @see _.flowRight
* @example
@@ -47116,7 +49304,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 3.0.0
* @memberOf _
* @category Util
- * @param {...(Function|Function[])} [funcs] Functions to invoke.
+ * @param {...(Function|Function[])} [funcs] The functions to invoke.
* @returns {Function} Returns the new composite function.
* @see _.flow
* @example
@@ -47132,7 +49320,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var flowRight = createFlow(true);
/**
- * This method returns the first argument given to it.
+ * This method returns the first argument it receives.
*
* @static
* @since 0.1.0
@@ -47142,7 +49330,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {*} Returns `value`.
* @example
*
- * var object = { 'user': 'fred' };
+ * var object = { 'a': 1 };
*
* console.log(_.identity(object) === object);
* // => true
@@ -47194,16 +49382,20 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => ['def']
*/
function iteratee(func) {
- return baseIteratee(typeof func == 'function' ? func : baseClone(func, true));
+ return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG));
}
/**
* Creates a function that performs a partial deep comparison between a given
* object and `source`, returning `true` if the given object has equivalent
- * property values, else `false`. The created function is equivalent to
- * `_.isMatch` with a `source` partially applied.
+ * property values, else `false`.
+ *
+ * **Note:** The created function is equivalent to `_.isMatch` with `source`
+ * partially applied.
*
- * **Note:** This method supports comparing the same values as `_.isEqual`.
+ * Partial comparisons will match empty array and empty object `source`
+ * values against any array or object value, respectively. See `_.isEqual`
+ * for a list of supported value comparisons.
*
* @static
* @memberOf _
@@ -47213,16 +49405,16 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Function} Returns the new spec function.
* @example
*
- * var users = [
- * { 'user': 'barney', 'age': 36, 'active': true },
- * { 'user': 'fred', 'age': 40, 'active': false }
+ * var objects = [
+ * { 'a': 1, 'b': 2, 'c': 3 },
+ * { 'a': 4, 'b': 5, 'c': 6 }
* ];
*
- * _.filter(users, _.matches({ 'age': 40, 'active': false }));
- * // => [{ 'user': 'fred', 'age': 40, 'active': false }]
+ * _.filter(objects, _.matches({ 'a': 4, 'c': 6 }));
+ * // => [{ 'a': 4, 'b': 5, 'c': 6 }]
*/
function matches(source) {
- return baseMatches(baseClone(source, true));
+ return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
}
/**
@@ -47230,7 +49422,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* value at `path` of a given object to `srcValue`, returning `true` if the
* object value is equivalent, else `false`.
*
- * **Note:** This method supports comparing the same values as `_.isEqual`.
+ * **Note:** Partial comparisons will match empty array and empty object
+ * `srcValue` values against any array or object value, respectively. See
+ * `_.isEqual` for a list of supported value comparisons.
*
* @static
* @memberOf _
@@ -47241,16 +49435,16 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @returns {Function} Returns the new spec function.
* @example
*
- * var users = [
- * { 'user': 'barney' },
- * { 'user': 'fred' }
+ * var objects = [
+ * { 'a': 1, 'b': 2, 'c': 3 },
+ * { 'a': 4, 'b': 5, 'c': 6 }
* ];
*
- * _.find(users, _.matchesProperty('user', 'fred'));
- * // => { 'user': 'fred' }
+ * _.find(objects, _.matchesProperty('a', 4));
+ * // => { 'a': 4, 'b': 5, 'c': 6 }
*/
function matchesProperty(path, srcValue) {
- return baseMatchesProperty(path, baseClone(srcValue, true));
+ return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
}
/**
@@ -47277,7 +49471,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.map(objects, _.method(['a', 'b']));
* // => [2, 1]
*/
- var method = rest(function(path, args) {
+ var method = baseRest(function(path, args) {
return function(object) {
return baseInvoke(object, path, args);
};
@@ -47306,7 +49500,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* _.map([['a', '2'], ['c', '0']], _.methodOf(object));
* // => [2, 0]
*/
- var methodOf = rest(function(object, args) {
+ var methodOf = baseRest(function(object, args) {
return function(path) {
return baseInvoke(object, path, args);
};
@@ -47405,7 +49599,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * A method that returns `undefined`.
+ * This method returns `undefined`.
*
* @static
* @memberOf _
@@ -47442,7 +49636,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function nthArg(n) {
n = toInteger(n);
- return rest(function(args) {
+ return baseRest(function(args) {
return baseNth(args, n);
});
}
@@ -47455,8 +49649,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 4.0.0
* @category Util
- * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
- * [iteratees=[_.identity]] The iteratees to invoke.
+ * @param {...(Function|Function[])} [iteratees=[_.identity]]
+ * The iteratees to invoke.
* @returns {Function} Returns the new function.
* @example
*
@@ -47475,8 +49669,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 4.0.0
* @category Util
- * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
- * [predicates=[_.identity]] The predicates to check.
+ * @param {...(Function|Function[])} [predicates=[_.identity]]
+ * The predicates to check.
* @returns {Function} Returns the new function.
* @example
*
@@ -47501,8 +49695,8 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @memberOf _
* @since 4.0.0
* @category Util
- * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
- * [predicates=[_.identity]] The predicates to check.
+ * @param {...(Function|Function[])} [predicates=[_.identity]]
+ * The predicates to check.
* @returns {Function} Returns the new function.
* @example
*
@@ -47654,7 +49848,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
var rangeRight = createRange(true);
/**
- * A method that returns a new empty array.
+ * This method returns a new empty array.
*
* @static
* @memberOf _
@@ -47676,7 +49870,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * A method that returns `false`.
+ * This method returns `false`.
*
* @static
* @memberOf _
@@ -47693,7 +49887,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * A method that returns a new empty object.
+ * This method returns a new empty object.
*
* @static
* @memberOf _
@@ -47715,7 +49909,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * A method that returns an empty string.
+ * This method returns an empty string.
*
* @static
* @memberOf _
@@ -47732,7 +49926,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
/**
- * A method that returns `true`.
+ * This method returns `true`.
*
* @static
* @memberOf _
@@ -47806,7 +50000,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
if (isArray(value)) {
return arrayMap(value, toKey);
}
- return isSymbol(value) ? [value] : copyArray(stringToPath(value));
+ return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value)));
}
/**
@@ -47850,7 +50044,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
var add = createMathOperation(function(augend, addend) {
return augend + addend;
- });
+ }, 0);
/**
* Computes `number` rounded up to `precision`.
@@ -47892,7 +50086,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
var divide = createMathOperation(function(dividend, divisor) {
return dividend / divisor;
- });
+ }, 1);
/**
* Computes `number` rounded down to `precision`.
@@ -47951,8 +50145,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.0.0
* @category Math
* @param {Array} array The array to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {*} Returns the maximum value.
* @example
*
@@ -47967,7 +50160,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function maxBy(array, iteratee) {
return (array && array.length)
- ? baseExtremum(array, getIteratee(iteratee), baseGt)
+ ? baseExtremum(array, getIteratee(iteratee, 2), baseGt)
: undefined;
}
@@ -47999,8 +50192,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.7.0
* @category Math
* @param {Array} array The array to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {number} Returns the mean.
* @example
*
@@ -48014,7 +50206,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* // => 5
*/
function meanBy(array, iteratee) {
- return baseMean(array, getIteratee(iteratee));
+ return baseMean(array, getIteratee(iteratee, 2));
}
/**
@@ -48051,8 +50243,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.0.0
* @category Math
* @param {Array} array The array to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {*} Returns the minimum value.
* @example
*
@@ -48067,7 +50258,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function minBy(array, iteratee) {
return (array && array.length)
- ? baseExtremum(array, getIteratee(iteratee), baseLt)
+ ? baseExtremum(array, getIteratee(iteratee, 2), baseLt)
: undefined;
}
@@ -48088,7 +50279,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
var multiply = createMathOperation(function(multiplier, multiplicand) {
return multiplier * multiplicand;
- });
+ }, 1);
/**
* Computes `number` rounded to `precision`.
@@ -48130,7 +50321,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
var subtract = createMathOperation(function(minuend, subtrahend) {
return minuend - subtrahend;
- });
+ }, 0);
/**
* Computes the sum of the values in `array`.
@@ -48162,8 +50353,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
* @since 4.0.0
* @category Math
* @param {Array} array The array to iterate over.
- * @param {Array|Function|Object|string} [iteratee=_.identity]
- * The iteratee invoked per element.
+ * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
* @returns {number} Returns the sum.
* @example
*
@@ -48178,7 +50368,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
*/
function sumBy(array, iteratee) {
return (array && array.length)
- ? baseSum(array, getIteratee(iteratee))
+ ? baseSum(array, getIteratee(iteratee, 2))
: 0;
}
@@ -48357,7 +50547,9 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
lodash.cloneDeep = cloneDeep;
lodash.cloneDeepWith = cloneDeepWith;
lodash.cloneWith = cloneWith;
+ lodash.conformsTo = conformsTo;
lodash.deburr = deburr;
+ lodash.defaultTo = defaultTo;
lodash.divide = divide;
lodash.endsWith = endsWith;
lodash.eq = eq;
@@ -48529,14 +50721,13 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
// Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
arrayEach(['drop', 'take'], function(methodName, index) {
LazyWrapper.prototype[methodName] = function(n) {
- var filtered = this.__filtered__;
- if (filtered && !index) {
- return new LazyWrapper(this);
- }
n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
- var result = this.clone();
- if (filtered) {
+ var result = (this.__filtered__ && !index)
+ ? new LazyWrapper(this)
+ : this.clone();
+
+ if (result.__filtered__) {
result.__takeCount__ = nativeMin(n, result.__takeCount__);
} else {
result.__views__.push({
@@ -48598,7 +50789,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
return this.reverse().find(predicate);
};
- LazyWrapper.prototype.invokeMap = rest(function(path, args) {
+ LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
if (typeof path == 'function') {
return new LazyWrapper(this);
}
@@ -48608,10 +50799,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
});
LazyWrapper.prototype.reject = function(predicate) {
- predicate = getIteratee(predicate, 3);
- return this.filter(function(value) {
- return !predicate(value);
- });
+ return this.filter(negate(getIteratee(predicate)));
};
LazyWrapper.prototype.slice = function(start, end) {
@@ -48715,7 +50903,7 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
}
});
- realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [{
+ realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{
'name': 'wrapper',
'func': undefined
}];
@@ -48734,33 +50922,35 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
lodash.prototype.reverse = wrapperReverse;
lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
- if (iteratorSymbol) {
- lodash.prototype[iteratorSymbol] = wrapperToIterator;
+ // Add lazy aliases.
+ lodash.prototype.first = lodash.prototype.head;
+
+ if (symIterator) {
+ lodash.prototype[symIterator] = wrapperToIterator;
}
return lodash;
- }
+ });
/*--------------------------------------------------------------------------*/
// Export lodash.
var _ = runInContext();
- // Expose Lodash on the free variable `window` or `self` when available so it's
- // globally accessible, even when bundled with Browserify, Webpack, etc. This
- // also prevents errors in cases where Lodash is loaded by a script tag in the
- // presence of an AMD loader. See http://requirejs.org/docs/errors.html#mismatch
- // for more details. Use `_.noConflict` to remove Lodash from the global object.
- (freeSelf || {})._ = _;
-
- // Some AMD build optimizers like r.js check for condition patterns like the following:
+ // Some AMD build optimizers, like r.js, check for condition patterns like:
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
+ // Expose Lodash on the global object to prevent errors when Lodash is
+ // loaded by a script tag in the presence of an AMD loader.
+ // See http://requirejs.org/docs/errors.html#mismatch for more details.
+ // Use `_.noConflict` to remove Lodash from the global object.
+ root._ = _;
+
// Define as an anonymous module so, through path mapping, it can be
// referenced as the "underscore" module.
define(function() {
return _;
});
}
- // Check for `exports` after `define` in case a build optimizer adds an `exports` object.
+ // Check for `exports` after `define` in case a build optimizer adds it.
else if (freeModule) {
// Export for Node.js.
(freeModule.exports = _)._ = _;
@@ -48779,20 +50969,35 @@ module.exports.Dispatcher = require('./lib/Dispatcher');
'use strict';
var React = require('react');
+var ReactDOM = require('react-dom');
+var findDOMNode = ReactDOM.findDOMNode;
var className = require('classnames');
var debounce = require('lodash.debounce');
+function normalizeLineEndings(str) {
+ if (!str) return str;
+ return str.replace(/\r\n|\r/g, '\n');
+}
+
var CodeMirror = React.createClass({
displayName: 'CodeMirror',
propTypes: {
+ className: React.PropTypes.any,
+ codeMirrorInstance: React.PropTypes.func,
+ defaultValue: React.PropTypes.string,
onChange: React.PropTypes.func,
onFocusChange: React.PropTypes.func,
+ onScroll: React.PropTypes.func,
options: React.PropTypes.object,
path: React.PropTypes.string,
value: React.PropTypes.string,
- className: React.PropTypes.any,
- codeMirrorInstance: React.PropTypes.object
+ preserveScrollPosition: React.PropTypes.bool
+ },
+ getDefaultProps: function getDefaultProps() {
+ return {
+ preserveScrollPosition: false
+ };
},
getCodeMirrorInstance: function getCodeMirrorInstance() {
return this.props.codeMirrorInstance || require('codemirror');
@@ -48802,13 +51007,17 @@ var CodeMirror = React.createClass({
isFocused: false
};
},
+ componentWillMount: function componentWillMount() {
+ this.componentWillReceiveProps = debounce(this.componentWillReceiveProps, 0);
+ },
componentDidMount: function componentDidMount() {
- var textareaNode = this.refs.textarea;
+ var textareaNode = findDOMNode(this.refs.textarea);
var codeMirrorInstance = this.getCodeMirrorInstance();
this.codeMirror = codeMirrorInstance.fromTextArea(textareaNode, this.props.options);
this.codeMirror.on('change', this.codemirrorValueChanged);
this.codeMirror.on('focus', this.focusChanged.bind(this, true));
this.codeMirror.on('blur', this.focusChanged.bind(this, false));
+ this.codeMirror.on('scroll', this.scrollChanged);
this.codeMirror.setValue(this.props.defaultValue || this.props.value || '');
},
componentWillUnmount: function componentWillUnmount() {
@@ -48817,9 +51026,15 @@ var CodeMirror = React.createClass({
this.codeMirror.toTextArea();
}
},
- componentWillReceiveProps: debounce(function (nextProps) {
- if (this.codeMirror && nextProps.value !== undefined && this.codeMirror.getValue() != nextProps.value) {
- this.codeMirror.setValue(nextProps.value);
+ componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
+ if (this.codeMirror && nextProps.value !== undefined && normalizeLineEndings(this.codeMirror.getValue()) !== normalizeLineEndings(nextProps.value)) {
+ if (this.props.preserveScrollPosition) {
+ var prevScrollPosition = this.codeMirror.getScrollInfo();
+ this.codeMirror.setValue(nextProps.value);
+ this.codeMirror.scrollTo(prevScrollPosition.left, prevScrollPosition.top);
+ } else {
+ this.codeMirror.setValue(nextProps.value);
+ }
}
if (typeof nextProps.options === 'object') {
for (var optionName in nextProps.options) {
@@ -48828,7 +51043,7 @@ var CodeMirror = React.createClass({
}
}
}
- }, 0),
+ },
getCodeMirror: function getCodeMirror() {
return this.codeMirror;
},
@@ -48843,9 +51058,12 @@ var CodeMirror = React.createClass({
});
this.props.onFocusChange && this.props.onFocusChange(focused);
},
+ scrollChanged: function scrollChanged(cm) {
+ this.props.onScroll && this.props.onScroll(cm.getScrollInfo());
+ },
codemirrorValueChanged: function codemirrorValueChanged(doc, change) {
- if (this.props.onChange && change.origin != 'setValue') {
- this.props.onChange(doc.getValue());
+ if (this.props.onChange && change.origin !== 'setValue') {
+ this.props.onChange(doc.getValue(), change);
}
},
render: function render() {
@@ -48859,142 +51077,93 @@ var CodeMirror = React.createClass({
});
module.exports = CodeMirror;
-},{"classnames":"classnames","codemirror":1,"lodash.debounce":7,"react":"react"}],"react-dom":[function(require,module,exports){
+},{"classnames":"classnames","codemirror":1,"lodash.debounce":29,"react":"react","react-dom":"react-dom"}],"react-dom":[function(require,module,exports){
'use strict';
-module.exports = require('react/lib/ReactDOM');
+module.exports = require('./lib/ReactDOM');
-},{"react/lib/ReactDOM":58}],"react-redux":[function(require,module,exports){
+},{"./lib/ReactDOM":73}],"react-redux":[function(require,module,exports){
'use strict';
exports.__esModule = true;
-exports.connect = exports.Provider = undefined;
+exports.connect = exports.connectAdvanced = exports.Provider = undefined;
var _Provider = require('./components/Provider');
var _Provider2 = _interopRequireDefault(_Provider);
-var _connect = require('./components/connect');
+var _connectAdvanced = require('./components/connectAdvanced');
+
+var _connectAdvanced2 = _interopRequireDefault(_connectAdvanced);
+
+var _connect = require('./connect/connect');
var _connect2 = _interopRequireDefault(_connect);
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-exports.Provider = _Provider2["default"];
-exports.connect = _connect2["default"];
-},{"./components/Provider":16,"./components/connect":17}],"react":[function(require,module,exports){
+exports.Provider = _Provider2.default;
+exports.connectAdvanced = _connectAdvanced2.default;
+exports.connect = _connect2.default;
+},{"./components/Provider":171,"./components/connectAdvanced":172,"./connect/connect":173}],"react":[function(require,module,exports){
'use strict';
module.exports = require('./lib/React');
-},{"./lib/React":47}],"redux-logger":[function(require,module,exports){
-"use strict";
+},{"./lib/React":187}],"redux-logger":[function(require,module,exports){
+'use strict';
-function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
-function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; }
+var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
-var repeat = function repeat(str, times) {
- return new Array(times + 1).join(str);
-};
-var pad = function pad(num, maxLength) {
- return repeat("0", maxLength - num.toString().length) + num;
-};
-var formatTime = function formatTime(time) {
- return "@ " + pad(time.getHours(), 2) + ":" + pad(time.getMinutes(), 2) + ":" + pad(time.getSeconds(), 2) + "." + pad(time.getMilliseconds(), 3);
-};
+var _core = require('./core');
-// Use the new performance api to get better precision if available
-var timer = typeof performance !== "undefined" && typeof performance.now === "function" ? performance : Date;
+var _helpers = require('./helpers');
-/**
- * parse the level option of createLogger
- *
- * @property {string | function | object} level - console[level]
- * @property {object} action
- * @property {array} payload
- * @property {string} type
- */
+var _defaults = require('./defaults');
-function getLogLevel(level, action, payload, type) {
- switch (typeof level === "undefined" ? "undefined" : _typeof(level)) {
- case "object":
- return typeof level[type] === "function" ? level[type].apply(level, _toConsumableArray(payload)) : level[type];
- case "function":
- return level(action);
- default:
- return level;
- }
-}
+var _defaults2 = _interopRequireDefault(_defaults);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
- * Creates logger with followed options
+ * Creates logger with following options
*
* @namespace
- * @property {object} options - options for logger
- * @property {string | function | object} options.level - console[level]
- * @property {boolean} options.duration - print duration of each action?
- * @property {boolean} options.timestamp - print timestamp with each action?
- * @property {object} options.colors - custom colors
- * @property {object} options.logger - implementation of the `console` API
- * @property {boolean} options.logErrors - should errors in action execution be caught, logged, and re-thrown?
- * @property {boolean} options.collapsed - is group collapsed?
- * @property {boolean} options.predicate - condition which resolves logger behavior
- * @property {function} options.stateTransformer - transform state before print
- * @property {function} options.actionTransformer - transform action before print
- * @property {function} options.errorTransformer - transform error before print
+ * @param {object} options - options for logger
+ * @param {string | function | object} options.level - console[level]
+ * @param {boolean} options.duration - print duration of each action?
+ * @param {boolean} options.timestamp - print timestamp with each action?
+ * @param {object} options.colors - custom colors
+ * @param {object} options.logger - implementation of the `console` API
+ * @param {boolean} options.logErrors - should errors in action execution be caught, logged, and re-thrown?
+ * @param {boolean} options.collapsed - is group collapsed?
+ * @param {boolean} options.predicate - condition which resolves logger behavior
+ * @param {function} options.stateTransformer - transform state before print
+ * @param {function} options.actionTransformer - transform action before print
+ * @param {function} options.errorTransformer - transform error before print
+ *
+ * @returns {function} logger middleware
*/
-
function createLogger() {
- var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
- var _options$level = options.level;
- var level = _options$level === undefined ? "log" : _options$level;
- var _options$logger = options.logger;
- var logger = _options$logger === undefined ? console : _options$logger;
- var _options$logErrors = options.logErrors;
- var logErrors = _options$logErrors === undefined ? true : _options$logErrors;
- var collapsed = options.collapsed;
- var predicate = options.predicate;
- var _options$duration = options.duration;
- var duration = _options$duration === undefined ? false : _options$duration;
- var _options$timestamp = options.timestamp;
- var timestamp = _options$timestamp === undefined ? true : _options$timestamp;
- var transformer = options.transformer;
- var _options$stateTransfo = options.stateTransformer;
- var // deprecated
- stateTransformer = _options$stateTransfo === undefined ? function (state) {
- return state;
- } : _options$stateTransfo;
- var _options$actionTransf = options.actionTransformer;
- var actionTransformer = _options$actionTransf === undefined ? function (actn) {
- return actn;
- } : _options$actionTransf;
- var _options$errorTransfo = options.errorTransformer;
- var errorTransformer = _options$errorTransfo === undefined ? function (error) {
- return error;
- } : _options$errorTransfo;
- var _options$colors = options.colors;
- var colors = _options$colors === undefined ? {
- title: function title() {
- return "#000000";
- },
- prevState: function prevState() {
- return "#9E9E9E";
- },
- action: function action() {
- return "#03A9F4";
- },
- nextState: function nextState() {
- return "#4CAF50";
- },
- error: function error() {
- return "#F20404";
- }
- } : _options$colors;
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
+
+ var loggerOptions = _extends({}, _defaults2.default, options);
- // exit if console undefined
+ var logger = loggerOptions.logger,
+ transformer = loggerOptions.transformer,
+ stateTransformer = loggerOptions.stateTransformer,
+ errorTransformer = loggerOptions.errorTransformer,
+ predicate = loggerOptions.predicate,
+ logErrors = loggerOptions.logErrors,
+ diffPredicate = loggerOptions.diffPredicate;
- if (typeof logger === "undefined") {
+ // Return if 'console' object is not defined
+
+ if (typeof logger === 'undefined') {
return function () {
return function (next) {
return function (action) {
@@ -49005,94 +51174,29 @@ function createLogger() {
}
if (transformer) {
- console.error("Option 'transformer' is deprecated, use stateTransformer instead");
+ console.error('Option \'transformer\' is deprecated, use \'stateTransformer\' instead!'); // eslint-disable-line no-console
}
var logBuffer = [];
- function printBuffer() {
- logBuffer.forEach(function (logEntry, key) {
- var started = logEntry.started;
- var startedTime = logEntry.startedTime;
- var action = logEntry.action;
- var prevState = logEntry.prevState;
- var error = logEntry.error;
- var took = logEntry.took;
- var nextState = logEntry.nextState;
-
- var nextEntry = logBuffer[key + 1];
- if (nextEntry) {
- nextState = nextEntry.prevState;
- took = nextEntry.started - started;
- }
- // message
- var formattedAction = actionTransformer(action);
- var isCollapsed = typeof collapsed === "function" ? collapsed(function () {
- return nextState;
- }, action) : collapsed;
-
- var formattedTime = formatTime(startedTime);
- var titleCSS = colors.title ? "color: " + colors.title(formattedAction) + ";" : null;
- var title = "action " + (timestamp ? formattedTime : "") + " " + formattedAction.type + " " + (duration ? "(in " + took.toFixed(2) + " ms)" : "");
-
- // render
- try {
- if (isCollapsed) {
- if (colors.title) logger.groupCollapsed("%c " + title, titleCSS);else logger.groupCollapsed(title);
- } else {
- if (colors.title) logger.group("%c " + title, titleCSS);else logger.group(title);
- }
- } catch (e) {
- logger.log(title);
- }
-
- var prevStateLevel = getLogLevel(level, formattedAction, [prevState], "prevState");
- var actionLevel = getLogLevel(level, formattedAction, [formattedAction], "action");
- var errorLevel = getLogLevel(level, formattedAction, [error, prevState], "error");
- var nextStateLevel = getLogLevel(level, formattedAction, [nextState], "nextState");
-
- if (prevStateLevel) {
- if (colors.prevState) logger[prevStateLevel]("%c prev state", "color: " + colors.prevState(prevState) + "; font-weight: bold", prevState);else logger[prevStateLevel]("prev state", prevState);
- }
-
- if (actionLevel) {
- if (colors.action) logger[actionLevel]("%c action", "color: " + colors.action(formattedAction) + "; font-weight: bold", formattedAction);else logger[actionLevel]("action", formattedAction);
- }
-
- if (error && errorLevel) {
- if (colors.error) logger[errorLevel]("%c error", "color: " + colors.error(error, prevState) + "; font-weight: bold", error);else logger[errorLevel]("error", error);
- }
-
- if (nextStateLevel) {
- if (colors.nextState) logger[nextStateLevel]("%c next state", "color: " + colors.nextState(nextState) + "; font-weight: bold", nextState);else logger[nextStateLevel]("next state", nextState);
- }
-
- try {
- logger.groupEnd();
- } catch (e) {
- logger.log("—— log end ——");
- }
- });
- logBuffer.length = 0;
- }
return function (_ref) {
var getState = _ref.getState;
return function (next) {
return function (action) {
- // exit early if predicate function returns false
- if (typeof predicate === "function" && !predicate(getState, action)) {
+ // Exit early if predicate function returns 'false'
+ if (typeof predicate === 'function' && !predicate(getState, action)) {
return next(action);
}
var logEntry = {};
logBuffer.push(logEntry);
- logEntry.started = timer.now();
+ logEntry.started = _helpers.timer.now();
logEntry.startedTime = new Date();
logEntry.prevState = stateTransformer(getState());
logEntry.action = action;
- var returnedValue = undefined;
+ var returnedValue = void 0;
if (logErrors) {
try {
returnedValue = next(action);
@@ -49103,10 +51207,13 @@ function createLogger() {
returnedValue = next(action);
}
- logEntry.took = timer.now() - logEntry.started;
+ logEntry.took = _helpers.timer.now() - logEntry.started;
logEntry.nextState = stateTransformer(getState());
- printBuffer();
+ var diff = loggerOptions.diff && typeof diffPredicate === 'function' ? diffPredicate(getState, action) : loggerOptions.diff;
+
+ (0, _core.printBuffer)(logBuffer, _extends({}, loggerOptions, { diff: diff }));
+ logBuffer.length = 0;
if (logEntry.error) throw logEntry.error;
return returnedValue;
@@ -49115,15 +51222,16 @@ function createLogger() {
};
}
-module.exports = createLogger;
-},{}],"redux-thunk":[function(require,module,exports){
+exports.default = createLogger;
+module.exports = exports['default'];
+},{"./core":210,"./defaults":211,"./helpers":213}],"redux-thunk":[function(require,module,exports){
'use strict';
exports.__esModule = true;
function createThunkMiddleware(extraArgument) {
return function (_ref) {
- var dispatch = _ref.dispatch;
- var getState = _ref.getState;
+ var dispatch = _ref.dispatch,
+ getState = _ref.getState;
return function (next) {
return function (action) {
if (typeof action === 'function') {
@@ -49171,7 +51279,7 @@ var _warning = require('./utils/warning');
var _warning2 = _interopRequireDefault(_warning);
-function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
/*
* This is a dummy function to check if the function name has been altered by minification.
@@ -49180,17 +51288,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
function isCrushed() {}
if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
- (0, _warning2["default"])('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.');
+ (0, _warning2['default'])('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.');
}
-exports.createStore = _createStore2["default"];
-exports.combineReducers = _combineReducers2["default"];
-exports.bindActionCreators = _bindActionCreators2["default"];
-exports.applyMiddleware = _applyMiddleware2["default"];
-exports.compose = _compose2["default"];
+exports.createStore = _createStore2['default'];
+exports.combineReducers = _combineReducers2['default'];
+exports.bindActionCreators = _bindActionCreators2['default'];
+exports.applyMiddleware = _applyMiddleware2['default'];
+exports.compose = _compose2['default'];
}).call(this,require('_process'))
-},{"./applyMiddleware":189,"./bindActionCreators":190,"./combineReducers":191,"./compose":192,"./createStore":193,"./utils/warning":194,"_process":15}],"shallowequal":[function(require,module,exports){
+},{"./applyMiddleware":214,"./bindActionCreators":215,"./combineReducers":216,"./compose":217,"./createStore":218,"./utils/warning":219,"_process":43}],"shallowequal":[function(require,module,exports){
'use strict';
var fetchKeys = require('lodash.keys');
@@ -49239,7 +51347,6 @@ module.exports = function shallowEqual(objA, objB, compare, compareContext) {
return true;
};
-},{"lodash.keys":195}]},{},[])
-
+},{"lodash.keys":32}]},{},[])
//# sourceMappingURL=vendor.js.map
diff --git a/release/README.md b/release/README.md
index 723b0950..02fabfe9 100644
--- a/release/README.md
+++ b/release/README.md
@@ -8,5 +8,7 @@
- Create release notice on Github
- Upload wheel to pypi (`twine upload wheelname`)
- Update docker-releases repo
+ - Create a new branch based of master for major versions.
+ - Add a commit that pins dependencies like so: https://github.com/mitmproxy/docker-releases/commit/3d6a9989fde068ad0aea257823ac3d7986ff1613. The requirements can be obtained by creating a fresh venv, pip-installing the new wheel in there, and then running `pip freeze`.
- Update `latest` tag on https://hub.docker.com/r/mitmproxy/mitmproxy/~/settings/automated-builds/
- Bump the version in https://github.com/mitmproxy/mitmproxy/blob/master/mitmproxy/version.py and update https://github.com/mitmproxy/mitmproxy/blob/master/mitmproxy/io_compat.py in the next commit
diff --git a/test/mitmproxy/proxy/test_server.py b/test/mitmproxy/proxy/test_server.py
index 8b133085..56b09b9a 100644
--- a/test/mitmproxy/proxy/test_server.py
+++ b/test/mitmproxy/proxy/test_server.py
@@ -481,6 +481,26 @@ class TestHTTPSNoCommonName(tservers.HTTPProxyTest):
class TestReverse(tservers.ReverseProxyTest, CommonMixin, TcpMixin):
reverse = True
+ def test_host_header(self):
+ self.config.options.keep_host_header = True
+ p = self.pathoc()
+ with p.connect():
+ resp = p.request("get:/p/200:h'Host'='example.com'")
+ assert resp.status_code == 200
+
+ req = self.master.state.flows[0].request
+ assert req.host_header == "example.com"
+
+ def test_overridden_host_header(self):
+ self.config.options.keep_host_header = False # default value
+ p = self.pathoc()
+ with p.connect():
+ resp = p.request("get:/p/200:h'Host'='example.com'")
+ assert resp.status_code == 200
+
+ req = self.master.state.flows[0].request
+ assert req.host_header == "127.0.0.1"
+
class TestReverseSSL(tservers.ReverseProxyTest, CommonMixin, TcpMixin):
reverse = True
diff --git a/test/mitmproxy/test_examples.py b/test/mitmproxy/test_examples.py
index f3603fca..668d0d4a 100644
--- a/test/mitmproxy/test_examples.py
+++ b/test/mitmproxy/test_examples.py
@@ -114,13 +114,11 @@ class TestScripts(tservers.MasterTest):
# Rewrite by reverse proxy mode
f.request.scheme = "https"
- f.request.host = "mitmproxy.org"
f.request.port = 443
m.request(f)
assert f.request.scheme == "http"
- assert f.request.host == original_host
assert f.request.port == 80
assert f.request.headers["Host"] == original_host
diff --git a/web/src/css/flowdetail.less b/web/src/css/flowdetail.less
index b6a7102b..200ec46d 100644
--- a/web/src/css/flowdetail.less
+++ b/web/src/css/flowdetail.less
@@ -14,8 +14,7 @@
}
section {
- display: flex;
- flex-direction: column;
+ overflow-y: scroll;
>article{
overflow: auto;
padding: 5px 12px 0;
diff --git a/web/src/css/header.less b/web/src/css/header.less
index 042d6811..97c69930 100644
--- a/web/src/css/header.less
+++ b/web/src/css/header.less
@@ -113,5 +113,12 @@ header {
.popover-content {
max-height: 500px;
overflow-y: auto;
+
+ tr {
+ cursor: pointer;
+ &:hover {
+ background-color: hsla(209, 52%, 84%, 0.5) !important;
+ }
+ }
}
}
diff --git a/web/src/js/components/Header/FilterDocs.jsx b/web/src/js/components/Header/FilterDocs.jsx
index 49fb5fbc..b471840b 100644
--- a/web/src/js/components/Header/FilterDocs.jsx
+++ b/web/src/js/components/Header/FilterDocs.jsx
@@ -37,7 +37,7 @@ export default class FilterDocs extends Component {
<table className="table table-condensed">
<tbody>
{doc.commands.map(cmd => (
- <tr key={cmd[1]}>
+ <tr key={cmd[1]} onClick={e => this.props.selectHandler(cmd[0].split(" ")[0] + " ")}>
<td>{cmd[0].replace(' ', '\u00a0')}</td>
<td>{cmd[1]}</td>
</tr>
diff --git a/web/src/js/components/Header/FilterInput.jsx b/web/src/js/components/Header/FilterInput.jsx
index e421f1a4..12479c10 100644
--- a/web/src/js/components/Header/FilterInput.jsx
+++ b/web/src/js/components/Header/FilterInput.jsx
@@ -21,6 +21,7 @@ export default class FilterInput extends Component {
this.onKeyDown = this.onKeyDown.bind(this)
this.onMouseEnter = this.onMouseEnter.bind(this)
this.onMouseLeave = this.onMouseLeave.bind(this)
+ this.selectFilter = this.selectFilter.bind(this)
}
componentWillReceiveProps(nextProps) {
@@ -41,7 +42,7 @@ export default class FilterInput extends Component {
getDesc() {
if (!this.state.value) {
- return <FilterDocs/>
+ return <FilterDocs selectHandler={this.selectFilter}/>
}
try {
return Filt.parse(this.state.value).desc
@@ -85,6 +86,11 @@ export default class FilterInput extends Component {
e.stopPropagation()
}
+ selectFilter(cmd) {
+ this.setState({value: cmd})
+ ReactDOM.findDOMNode(this.refs.input).focus()
+ }
+
blur() {
ReactDOM.findDOMNode(this.refs.input).blur()
}
diff --git a/web/src/js/flow/utils.js b/web/src/js/flow/utils.js
index cd174069..3c38058e 100644
--- a/web/src/js/flow/utils.js
+++ b/web/src/js/flow/utils.js
@@ -54,16 +54,12 @@ export var MessageUtils = {
};
export var RequestUtils = _.extend(MessageUtils, {
- pretty_host: function (request) {
- //FIXME: Add hostheader
- return request.host;
- },
pretty_url: function (request) {
var port = "";
if (defaultPorts[request.scheme] !== request.port) {
port = ":" + request.port;
}
- return request.scheme + "://" + this.pretty_host(request) + port + request.path;
+ return request.scheme + "://" + request.pretty_host + port + request.path;
}
});