123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151 |
- 'use strict';
- // tslint:disable-next-line
- var global = function () {
- var local;
- if (typeof global !== 'undefined') {
- local = global;
- } else if (typeof self !== 'undefined') {
- local = self;
- } else {
- try {
- local = Function('return this')();
- } catch (e) {
- throw new Error('global object is unavailable in this environment');
- }
- }
- return local;
- }();
- var isBrowser = typeof window !== 'undefined';
- // tslint:disable-next-line:no-empty
- function noop() {}
- var fakeDoc = {
- createElement: noop,
- createElementNS: noop,
- createTextNode: noop
- };
- var doc = isBrowser ? document : fakeDoc;
- function isNumber(arg) {
- return typeof arg === 'number';
- }
- var isSupportSVG = isFunction(doc.createAttributeNS);
- function isString(arg) {
- return typeof arg === 'string';
- }
- function isFunction(arg) {
- return typeof arg === 'function';
- }
- function isBoolean(arg) {
- return arg === true || arg === false;
- }
- var isArray = Array.isArray;
- function isUndefined(o) {
- return o === undefined;
- }
- var canUsePromise = 'Promise' in global;
- var resolved;
- if (canUsePromise) {
- resolved = Promise.resolve();
- }
- var nextTick = function (fn) {
- var args = [],
- len = arguments.length - 1;
- while (len-- > 0) args[len] = arguments[len + 1];
- fn = isFunction(fn) ? fn.bind.apply(fn, [null].concat(args)) : fn;
- if (canUsePromise) {
- return resolved.then(fn);
- }
- var timerFunc = 'requestAnimationFrame' in global ? requestAnimationFrame : setTimeout;
- timerFunc(fn);
- };
- /* istanbul ignore next */
- // tslint:disable-next-line
- Object.is = Object.is || function (x, y) {
- if (x === y) {
- return x !== 0 || 1 / x === 1 / y;
- }
- return x !== x && y !== y;
- };
- function shallowEqual(obj1, obj2) {
- if (obj1 === null || obj2 === null) {
- return false;
- }
- if (Object.is(obj1, obj2)) {
- return true;
- }
- var obj1Keys = obj1 ? Object.keys(obj1) : [];
- var obj2Keys = obj2 ? Object.keys(obj2) : [];
- if (obj1Keys.length !== obj2Keys.length) {
- return false;
- }
- for (var i = 0; i < obj1Keys.length; i++) {
- var obj1KeyItem = obj1Keys[i];
- if (!obj2.hasOwnProperty(obj1KeyItem) || !Object.is(obj1[obj1KeyItem], obj2[obj1KeyItem])) {
- return false;
- }
- }
- return true;
- }
- var SimpleMap = function SimpleMap() {
- this.cache = [];
- this.size = 0;
- };
- SimpleMap.prototype.set = function set(k, v) {
- var this$1 = this;
- var len = this.cache.length;
- if (!len) {
- this.cache.push({ k: k, v: v });
- this.size += 1;
- return;
- }
- for (var i = 0; i < len; i++) {
- var item = this$1.cache[i];
- if (item.k === k) {
- item.v = v;
- return;
- }
- }
- this.cache.push({ k: k, v: v });
- this.size += 1;
- };
- SimpleMap.prototype.get = function get(k) {
- var this$1 = this;
- var len = this.cache.length;
- if (!len) {
- return;
- }
- for (var i = 0; i < len; i++) {
- var item = this$1.cache[i];
- if (item.k === k) {
- return item.v;
- }
- }
- };
- SimpleMap.prototype.has = function has(k) {
- var this$1 = this;
- var len = this.cache.length;
- if (!len) {
- return false;
- }
- for (var i = 0; i < len; i++) {
- var item = this$1.cache[i];
- if (item.k === k) {
- return true;
- }
- }
- return false;
- };
- SimpleMap.prototype['delete'] = function delete$1(k) {
- var this$1 = this;
- var len = this.cache.length;
- for (var i = 0; i < len; i++) {
- var item = this$1.cache[i];
- if (item.k === k) {
- this$1.cache.splice(i, 1);
- this$1.size -= 1;
- return true;
- }
- }
- return false;
- };
- SimpleMap.prototype.clear = function clear() {
- var this$1 = this;
- var len = this.cache.length;
- this.size = 0;
- if (!len) {
- return;
- }
- while (len) {
- this$1.cache.pop();
- len--;
- }
- };
- var MapClass = 'Map' in global ? Map : SimpleMap;
- function isAttrAnEvent(attr) {
- return attr[0] === 'o' && attr[1] === 'n';
- }
- function extend(source, from) {
- if (!from) {
- return source;
- }
- for (var key in from) {
- if (from.hasOwnProperty(key)) {
- source[key] = from[key];
- }
- }
- return source;
- }
- function clone(obj) {
- return extend({}, obj);
- }
- var Current = {
- current: null
- };
- var EMPTY_CHILDREN = [];
- var EMPTY_OBJ = {};
- function isNullOrUndef(o) {
- return o === undefined || o === null;
- }
- function isInvalid(o) {
- return isNullOrUndef(o) || o === true || o === false;
- }
- function isVNode(node) {
- return !isNullOrUndef(node) && node.vtype === 2 /* Node */;
- }
- function isVText(node) {
- return !isNullOrUndef(node) && node.vtype === 1 /* Text */;
- }
- function isComponent(instance) {
- return !isInvalid(instance) && instance.isReactComponent === EMPTY_OBJ;
- }
- function isWidget(node) {
- return !isNullOrUndef(node) && (node.vtype & (4 /* Composite */ | 8 /* Stateless */)) > 0;
- }
- function isPortal(vtype, node) {
- return (vtype & 32 /* Portal */) > 0;
- }
- function isComposite(node) {
- return !isNullOrUndef(node) && node.vtype === 4 /* Composite */;
- }
- function isValidElement(node) {
- return !isNullOrUndef(node) && node.vtype;
- }
- // tslint:disable-next-line:no-empty
- function noop$1() {}
- // typescript will compile the enum's value for us.
- // eg.
- // Composite = 1 << 2 => Composite = 4
- var VType;
- (function (VType) {
- VType[VType["Text"] = 1] = "Text";
- VType[VType["Node"] = 2] = "Node";
- VType[VType["Composite"] = 4] = "Composite";
- VType[VType["Stateless"] = 8] = "Stateless";
- VType[VType["Void"] = 16] = "Void";
- VType[VType["Portal"] = 32] = "Portal";
- })(VType || (VType = {}));
- var Ref = {
- update: function update(lastVnode, nextVnode, domNode) {
- var prevRef = lastVnode != null && lastVnode.ref;
- var nextRef = nextVnode != null && nextVnode.ref;
- if (prevRef !== nextRef) {
- if (!isFunction(prevRef) || !isFunction(nextRef)) {
- this.detach(lastVnode, prevRef, lastVnode.dom);
- }
- this.attach(nextVnode, nextRef, domNode);
- }
- },
- attach: function attach(vnode, ref, domNode) {
- var node = isComposite(vnode) ? vnode.component : domNode;
- if (isFunction(ref)) {
- ref(node);
- } else if (isString(ref)) {
- var inst = vnode._owner;
- if (inst && isFunction(inst.render)) {
- inst.refs[ref] = node;
- }
- }
- },
- detach: function detach(vnode, ref, domNode) {
- var node = isComposite(vnode) ? vnode.component : domNode;
- if (isFunction(ref)) {
- ref(null);
- } else if (isString(ref)) {
- var inst = vnode._owner;
- if (inst.refs[ref] === node && isFunction(inst.render)) {
- delete inst.refs[ref];
- }
- }
- }
- };
- var ONINPUT = 'oninput';
- var ONPROPERTYCHANGE = 'onpropertychange';
- var isiOS = isBrowser && !!navigator.platform && /iPad|iPhone|iPod/.test(navigator.platform);
- var delegatedEvents = new MapClass();
- var unbubbleEvents = {
- onmousemove: 1,
- ontouchmove: 1,
- onmouseleave: 1,
- onmouseenter: 1,
- onload: 1,
- onunload: 1,
- onscroll: 1,
- onfocus: 1,
- onblur: 1,
- onrowexit: 1,
- onbeforeunload: 1,
- onstop: 1,
- ondragdrop: 1,
- ondragenter: 1,
- ondragexit: 1,
- ondraggesture: 1,
- ondragover: 1,
- oncontextmenu: 1,
- onerror: 1,
- onabort: 1,
- oncanplay: 1,
- oncanplaythrough: 1,
- ondurationchange: 1,
- onemptied: 1,
- onended: 1,
- onloadeddata: 1,
- onloadedmetadata: 1,
- onloadstart: 1,
- onencrypted: 1,
- onpause: 1,
- onplay: 1,
- onplaying: 1,
- onprogress: 1,
- onratechange: 1,
- onseeking: 1,
- onseeked: 1,
- onstalled: 1,
- onsuspend: 1,
- ontimeupdate: 1,
- onvolumechange: 1,
- onwaiting: 1
- };
- unbubbleEvents[ONPROPERTYCHANGE] = 1;
- var bindFocus = false;
- /* istanbul ignore next */
- if (isBrowser && navigator.userAgent.indexOf('MSIE 9') >= 0) {
- var elements = [];
- var values = [];
- doc.addEventListener('selectionchange', function () {
- var el = doc.activeElement;
- if (detectCanUseOnInputNode(el)) {
- var index = elements.indexOf(el);
- var element = elements[index] || elements.push(el);
- if (element.value !== values[index]) {
- var ev = doc.createEvent('CustomEvent');
- ev.initCustomEvent('input', true, true, undefined);
- values[index] = element.value;
- el.dispatchEvent(ev);
- }
- }
- });
- }
- if (typeof Event !== 'undefined' && !Event.prototype.persist) {
- // tslint:disable-next-line:no-empty
- Event.prototype.persist = noop$1;
- }
- function attachEvent(domNode, eventName, handler) {
- eventName = fixEvent(domNode, eventName);
- /* istanbul ignore next */
- if (eventName === ONPROPERTYCHANGE) {
- processOnPropertyChangeEvent(domNode, handler);
- return;
- }
- var delegatedRoots = delegatedEvents.get(eventName);
- if (unbubbleEvents[eventName] === 1) {
- if (!delegatedRoots) {
- delegatedRoots = new MapClass();
- }
- var event = attachEventToNode(domNode, eventName, delegatedRoots);
- delegatedEvents.set(eventName, delegatedRoots);
- if (isFunction(handler)) {
- delegatedRoots.set(domNode, {
- eventHandler: handler,
- event: event
- });
- }
- } else {
- if (!delegatedRoots) {
- delegatedRoots = {
- items: new MapClass()
- };
- delegatedRoots.event = attachEventToDocument(doc, eventName, delegatedRoots);
- delegatedEvents.set(eventName, delegatedRoots);
- }
- if (isFunction(handler)) {
- if (isiOS) {
- domNode.onclick = noop$1;
- }
- delegatedRoots.items.set(domNode, handler);
- }
- }
- }
- function detachEvent(domNode, eventName, handler) {
- eventName = fixEvent(domNode, eventName);
- if (eventName === ONPROPERTYCHANGE) {
- return;
- }
- var delegatedRoots = delegatedEvents.get(eventName);
- if (unbubbleEvents[eventName] === 1 && delegatedRoots) {
- var event = delegatedRoots.get(domNode);
- if (event) {
- domNode.removeEventListener(parseEventName(eventName), event.event, false);
- /* istanbul ignore next */
- var delegatedRootsSize = delegatedRoots.size;
- if (delegatedRoots['delete'](domNode) && delegatedRootsSize === 0) {
- delegatedEvents['delete'](eventName);
- }
- }
- } else if (delegatedRoots && delegatedRoots.items) {
- var items = delegatedRoots.items;
- if (items['delete'](domNode) && items.size === 0) {
- doc.removeEventListener(parseEventName(eventName), delegatedRoots.event, false);
- delegatedEvents['delete'](eventName);
- }
- }
- }
- var propertyChangeActiveElement;
- var propertyChangeActiveElementValue;
- var propertyChangeActiveElementValueProp;
- var propertyChangeActiveHandler;
- /* istanbul ignore next */
- function propertyChangeHandler(event) {
- if (event.propertyName !== 'value') {
- return;
- }
- var target = event.target || event.srcElement;
- var val = target.value;
- if (val === propertyChangeActiveElementValue) {
- return;
- }
- propertyChangeActiveElementValue = val;
- if (isFunction(propertyChangeActiveHandler)) {
- propertyChangeActiveHandler.call(target, event);
- }
- }
- /* istanbul ignore next */
- function processOnPropertyChangeEvent(node, handler) {
- propertyChangeActiveHandler = handler;
- if (!bindFocus) {
- bindFocus = true;
- doc.addEventListener('focusin', function () {
- unbindOnPropertyChange();
- bindOnPropertyChange(node);
- }, false);
- doc.addEventListener('focusout', unbindOnPropertyChange, false);
- }
- }
- /* istanbul ignore next */
- function bindOnPropertyChange(node) {
- propertyChangeActiveElement = node;
- propertyChangeActiveElementValue = node.value;
- propertyChangeActiveElementValueProp = Object.getOwnPropertyDescriptor(node.constructor.prototype, 'value');
- Object.defineProperty(propertyChangeActiveElement, 'value', {
- get: function get() {
- return propertyChangeActiveElementValueProp.get.call(this);
- },
- set: function set(val) {
- propertyChangeActiveElementValue = val;
- propertyChangeActiveElementValueProp.set.call(this, val);
- }
- });
- propertyChangeActiveElement.addEventListener('propertychange', propertyChangeHandler, false);
- }
- /* istanbul ignore next */
- function unbindOnPropertyChange() {
- if (!propertyChangeActiveElement) {
- return;
- }
- delete propertyChangeActiveElement.value;
- propertyChangeActiveElement.removeEventListener('propertychange', propertyChangeHandler, false);
- propertyChangeActiveElement = null;
- propertyChangeActiveElementValue = null;
- propertyChangeActiveElementValueProp = null;
- }
- function detectCanUseOnInputNode(node) {
- var nodeName = node.nodeName && node.nodeName.toLowerCase();
- var type = node.type;
- return nodeName === 'input' && /text|password/.test(type) || nodeName === 'textarea';
- }
- function fixEvent(node, eventName) {
- if (eventName === 'onDoubleClick') {
- eventName = 'ondblclick';
- } else if (eventName === 'onTouchTap') {
- eventName = 'onclick';
- // tslint:disable-next-line:prefer-conditional-expression
- } else if (eventName === 'onChange' && detectCanUseOnInputNode(node)) {
- eventName = ONINPUT in window ? ONINPUT : ONPROPERTYCHANGE;
- } else {
- eventName = eventName.toLowerCase();
- }
- return eventName;
- }
- function parseEventName(name) {
- return name.substr(2);
- }
- /* istanbul ignore next */
- function stopPropagation() {
- this.cancelBubble = true;
- this.stopImmediatePropagation();
- }
- function dispatchEvent(event, target, items, count, eventData) {
- var eventsToTrigger = items.get(target);
- if (eventsToTrigger) {
- count--;
- eventData.currentTarget = target;
- // for React synthetic event compatibility
- Object.defineProperties(event, {
- nativeEvent: {
- value: event
- }
- });
- eventsToTrigger(event);
- if (event.cancelBubble) {
- return;
- }
- }
- if (count > 0) {
- var parentDom = target.parentNode;
- if (parentDom === null || event.type === 'click' && parentDom.nodeType === 1 && parentDom.disabled) {
- return;
- }
- dispatchEvent(event, parentDom, items, count, eventData);
- }
- }
- function attachEventToDocument(d, eventName, delegatedRoots) {
- var eventHandler = function (event) {
- var items = delegatedRoots.items;
- var count = items.size;
- if (count > 0) {
- var eventData = {
- currentTarget: event.target
- };
- /* istanbul ignore next */
- try {
- Object.defineProperties(event, {
- currentTarget: {
- configurable: true,
- get: function get() {
- return eventData.currentTarget;
- }
- },
- stopPropagation: {
- value: stopPropagation
- }
- });
- } catch (error) {
- // some browsers crashed
- // see: https://stackoverflow.com/questions/44052813/why-cannot-redefine-property
- }
- dispatchEvent(event, event.target, delegatedRoots.items, count, eventData);
- }
- };
- d.addEventListener(parseEventName(eventName), eventHandler, false);
- return eventHandler;
- }
- function attachEventToNode(node, eventName, delegatedRoots) {
- var eventHandler = function (event) {
- var eventToTrigger = delegatedRoots.get(node);
- if (eventToTrigger && eventToTrigger.eventHandler) {
- var eventData = {
- currentTarget: node
- };
- /* istanbul ignore next */
- Object.defineProperties(event, {
- currentTarget: {
- configurable: true,
- get: function get() {
- return eventData.currentTarget;
- }
- }
- });
- eventToTrigger.eventHandler(event);
- }
- };
- node.addEventListener(parseEventName(eventName), eventHandler, false);
- return eventHandler;
- }
- var options = {
- afterMount: noop$1,
- afterUpdate: noop$1,
- beforeUnmount: noop$1,
- roots: [],
- debug: false
- };
- function unmountChildren(children, parentDom) {
- if (isArray(children)) {
- for (var i = 0, len = children.length; i < len; i++) {
- unmount(children[i], parentDom);
- }
- } else {
- unmount(children, parentDom);
- }
- }
- function unmount(vnode, parentDom) {
- if (isInvalid(vnode)) {
- return;
- }
- var vtype = vnode.vtype;
- // Bitwise operators for better performance
- // see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators
- var dom = vtype & 4 /* Composite */ ? vnode.component.dom : vnode.dom;
- if ((vtype & (4 /* Composite */ | 8 /* Stateless */)) > 0) {
- options.beforeUnmount(vnode);
- vnode.destroy();
- } else if ((vtype & 2 /* Node */) > 0) {
- var props = vnode.props;
- var children = vnode.children;
- var ref = vnode.ref;
- unmountChildren(children);
- for (var propName in props) {
- if (isAttrAnEvent(propName)) {
- detachEvent(dom, propName, props[propName]);
- }
- }
- if (ref !== null) {
- Ref.detach(vnode, ref, dom);
- }
- } else if (vtype & 32 /* Portal */) {
- unmountChildren(vnode.children, vnode.type);
- }
- if (!isNullOrUndef(parentDom) && !isNullOrUndef(dom)) {
- parentDom.removeChild(dom);
- }
- // vnode.dom = null
- }
- var NS = {
- ev: 'http://www.w3.org/2001/xml-events',
- xlink: 'http://www.w3.org/1999/xlink',
- xml: 'http://www.w3.org/XML/1998/namespace'
- };
- var ATTRS = {
- accentHeight: 'accent-height',
- accumulate: 0,
- additive: 0,
- alignmentBaseline: 'alignment-baseline',
- allowReorder: 'allowReorder',
- alphabetic: 0,
- amplitude: 0,
- arabicForm: 'arabic-form',
- ascent: 0,
- attributeName: 'attributeName',
- attributeType: 'attributeType',
- autoReverse: 'autoReverse',
- azimuth: 0,
- baseFrequency: 'baseFrequency',
- baseProfile: 'baseProfile',
- baselineShift: 'baseline-shift',
- bbox: 0,
- begin: 0,
- bias: 0,
- by: 0,
- calcMode: 'calcMode',
- capHeight: 'cap-height',
- clip: 0,
- clipPath: 'clip-path',
- clipRule: 'clip-rule',
- clipPathUnits: 'clipPathUnits',
- colorInterpolation: 'color-interpolation',
- colorInterpolationFilters: 'color-interpolation-filters',
- colorProfile: 'color-profile',
- colorRendering: 'color-rendering',
- contentScriptType: 'contentScriptType',
- contentStyleType: 'contentStyleType',
- cursor: 0,
- cx: 0,
- cy: 0,
- d: 0,
- decelerate: 0,
- descent: 0,
- diffuseConstant: 'diffuseConstant',
- direction: 0,
- display: 0,
- divisor: 0,
- dominantBaseline: 'dominant-baseline',
- dur: 0,
- dx: 0,
- dy: 0,
- edgeMode: 'edgeMode',
- elevation: 0,
- enableBackground: 'enable-background',
- end: 0,
- evEvent: 'ev:event',
- exponent: 0,
- externalResourcesRequired: 'externalResourcesRequired',
- fill: 0,
- fillOpacity: 'fill-opacity',
- fillRule: 'fill-rule',
- filter: 0,
- filterRes: 'filterRes',
- filterUnits: 'filterUnits',
- floodColor: 'flood-color',
- floodOpacity: 'flood-opacity',
- focusable: 0,
- fontFamily: 'font-family',
- fontSize: 'font-size',
- fontSizeAdjust: 'font-size-adjust',
- fontStretch: 'font-stretch',
- fontStyle: 'font-style',
- fontVariant: 'font-variant',
- fontWeight: 'font-weight',
- format: 0,
- from: 0,
- fx: 0,
- fy: 0,
- g1: 0,
- g2: 0,
- glyphName: 'glyph-name',
- glyphOrientationHorizontal: 'glyph-orientation-horizontal',
- glyphOrientationVertical: 'glyph-orientation-vertical',
- glyphRef: 'glyphRef',
- gradientTransform: 'gradientTransform',
- gradientUnits: 'gradientUnits',
- hanging: 0,
- horizAdvX: 'horiz-adv-x',
- horizOriginX: 'horiz-origin-x',
- ideographic: 0,
- imageRendering: 'image-rendering',
- 'in': 0,
- in2: 0,
- intercept: 0,
- k: 0,
- k1: 0,
- k2: 0,
- k3: 0,
- k4: 0,
- kernelMatrix: 'kernelMatrix',
- kernelUnitLength: 'kernelUnitLength',
- kerning: 0,
- keyPoints: 'keyPoints',
- keySplines: 'keySplines',
- keyTimes: 'keyTimes',
- lengthAdjust: 'lengthAdjust',
- letterSpacing: 'letter-spacing',
- lightingColor: 'lighting-color',
- limitingConeAngle: 'limitingConeAngle',
- local: 0,
- markerEnd: 'marker-end',
- markerMid: 'marker-mid',
- markerStart: 'marker-start',
- markerHeight: 'markerHeight',
- markerUnits: 'markerUnits',
- markerWidth: 'markerWidth',
- mask: 0,
- maskContentUnits: 'maskContentUnits',
- maskUnits: 'maskUnits',
- mathematical: 0,
- mode: 0,
- numOctaves: 'numOctaves',
- offset: 0,
- opacity: 0,
- operator: 0,
- order: 0,
- orient: 0,
- orientation: 0,
- origin: 0,
- overflow: 0,
- overlinePosition: 'overline-position',
- overlineThickness: 'overline-thickness',
- paintOrder: 'paint-order',
- panose1: 'panose-1',
- pathLength: 'pathLength',
- patternContentUnits: 'patternContentUnits',
- patternTransform: 'patternTransform',
- patternUnits: 'patternUnits',
- pointerEvents: 'pointer-events',
- points: 0,
- pointsAtX: 'pointsAtX',
- pointsAtY: 'pointsAtY',
- pointsAtZ: 'pointsAtZ',
- preserveAlpha: 'preserveAlpha',
- preserveAspectRatio: 'preserveAspectRatio',
- primitiveUnits: 'primitiveUnits',
- r: 0,
- radius: 0,
- refX: 'refX',
- refY: 'refY',
- renderingIntent: 'rendering-intent',
- repeatCount: 'repeatCount',
- repeatDur: 'repeatDur',
- requiredExtensions: 'requiredExtensions',
- requiredFeatures: 'requiredFeatures',
- restart: 0,
- result: 0,
- rotate: 0,
- rx: 0,
- ry: 0,
- scale: 0,
- seed: 0,
- shapeRendering: 'shape-rendering',
- slope: 0,
- spacing: 0,
- specularConstant: 'specularConstant',
- specularExponent: 'specularExponent',
- speed: 0,
- spreadMethod: 'spreadMethod',
- startOffset: 'startOffset',
- stdDeviation: 'stdDeviation',
- stemh: 0,
- stemv: 0,
- stitchTiles: 'stitchTiles',
- stopColor: 'stop-color',
- stopOpacity: 'stop-opacity',
- strikethroughPosition: 'strikethrough-position',
- strikethroughThickness: 'strikethrough-thickness',
- string: 0,
- stroke: 0,
- strokeDasharray: 'stroke-dasharray',
- strokeDashoffset: 'stroke-dashoffset',
- strokeLinecap: 'stroke-linecap',
- strokeLinejoin: 'stroke-linejoin',
- strokeMiterlimit: 'stroke-miterlimit',
- strokeOpacity: 'stroke-opacity',
- strokeWidth: 'stroke-width',
- surfaceScale: 'surfaceScale',
- systemLanguage: 'systemLanguage',
- tableValues: 'tableValues',
- targetX: 'targetX',
- targetY: 'targetY',
- textAnchor: 'text-anchor',
- textDecoration: 'text-decoration',
- textRendering: 'text-rendering',
- textLength: 'textLength',
- to: 0,
- transform: 0,
- u1: 0,
- u2: 0,
- underlinePosition: 'underline-position',
- underlineThickness: 'underline-thickness',
- unicode: 0,
- unicodeBidi: 'unicode-bidi',
- unicodeRange: 'unicode-range',
- unitsPerEm: 'units-per-em',
- vAlphabetic: 'v-alphabetic',
- vHanging: 'v-hanging',
- vIdeographic: 'v-ideographic',
- vMathematical: 'v-mathematical',
- values: 0,
- vectorEffect: 'vector-effect',
- version: 0,
- vertAdvY: 'vert-adv-y',
- vertOriginX: 'vert-origin-x',
- vertOriginY: 'vert-origin-y',
- viewBox: 'viewBox',
- viewTarget: 'viewTarget',
- visibility: 0,
- widths: 0,
- wordSpacing: 'word-spacing',
- writingMode: 'writing-mode',
- x: 0,
- xHeight: 'x-height',
- x1: 0,
- x2: 0,
- xChannelSelector: 'xChannelSelector',
- xlinkActuate: 'xlink:actuate',
- xlinkArcrole: 'xlink:arcrole',
- xlinkHref: 'xlink:href',
- xlinkRole: 'xlink:role',
- xlinkShow: 'xlink:show',
- xlinkTitle: 'xlink:title',
- xlinkType: 'xlink:type',
- xmlBase: 'xml:base',
- xmlId: 'xml:id',
- xmlns: 0,
- xmlnsXlink: 'xmlns:xlink',
- xmlLang: 'xml:lang',
- xmlSpace: 'xml:space',
- y: 0,
- y1: 0,
- y2: 0,
- yChannelSelector: 'yChannelSelector',
- z: 0,
- zoomAndPan: 'zoomAndPan'
- };
- var SVGPropertyConfig = {
- Properties: {},
- DOMAttributeNamespaces: {
- 'ev:event': NS.ev,
- 'xlink:actuate': NS.xlink,
- 'xlink:arcrole': NS.xlink,
- 'xlink:href': NS.xlink,
- 'xlink:role': NS.xlink,
- 'xlink:show': NS.xlink,
- 'xlink:title': NS.xlink,
- 'xlink:type': NS.xlink,
- 'xml:base': NS.xml,
- 'xml:id': NS.xml,
- 'xml:lang': NS.xml,
- 'xml:space': NS.xml
- },
- DOMAttributeNames: {}
- };
- Object.keys(ATTRS).forEach(function (key) {
- SVGPropertyConfig.Properties[key] = 0;
- if (ATTRS[key]) {
- SVGPropertyConfig.DOMAttributeNames[key] = ATTRS[key];
- }
- });
- /* tslint:disable: no-empty*/
- function patch(lastVnode, nextVnode, lastDom, context, isSvg) {
- lastDom = lastVnode && lastVnode.dom || lastDom;
- if (isVText(nextVnode) && isVText(lastVnode)) {
- return patchVText(lastVnode, nextVnode);
- }
- var newDom;
- if (isSameVNode(lastVnode, nextVnode)) {
- if (isVNode(nextVnode)) {
- isSvg = isNullOrUndef(isSvg) ? lastVnode.isSvg : isSvg;
- if (isSvg) {
- nextVnode.isSvg = isSvg;
- }
- patchProps(lastDom, nextVnode.props, lastVnode.props, lastVnode, isSvg);
- patchChildren(lastDom, lastVnode.children, nextVnode.children, context, isSvg);
- if (nextVnode.ref !== null) {
- Ref.update(lastVnode, nextVnode, lastDom);
- }
- newDom = lastDom;
- } else if (isWidget(nextVnode)) {
- newDom = nextVnode.update(lastVnode, nextVnode, context, lastDom);
- options.afterUpdate(nextVnode);
- }
- nextVnode.dom = newDom;
- } else {
- var parentNode = lastDom.parentNode;
- var nextSibling = lastDom.nextSibling;
- unmount(lastVnode, parentNode);
- newDom = createElement(nextVnode, isSvg, context);
- if (nextVnode !== null) {
- nextVnode.dom = newDom;
- }
- if (parentNode !== null) {
- parentNode.insertBefore(newDom, nextVnode !== null && nextVnode.vtype & 32 /* Portal */ ? null : nextSibling);
- }
- }
- return newDom;
- }
- function patchArrayChildren(parentDom, lastChildren, nextChildren, context, isSvg) {
- var lastLength = lastChildren.length;
- var nextLength = nextChildren.length;
- if (lastLength === 0) {
- if (nextLength > 0) {
- for (var i = 0; i < nextLength; i++) {
- mountChild(nextChildren[i], parentDom, context, isSvg);
- }
- }
- } else if (nextLength === 0) {
- unmountChildren(lastChildren);
- parentDom.textContent = '';
- } else {
- if (isKeyed(lastChildren, nextChildren)) {
- patchKeyedChildren(lastChildren, nextChildren, parentDom, context, isSvg, lastLength, nextLength);
- } else {
- patchNonKeyedChildren(parentDom, lastChildren, nextChildren, context, isSvg, lastLength, nextLength);
- }
- }
- }
- function patchChildren(parentDom, lastChildren, nextChildren, context, isSvg) {
- if (lastChildren === nextChildren) {
- return;
- }
- var lastChildrenIsArray = isArray(lastChildren);
- var nextChildrenIsArray = isArray(nextChildren);
- if (lastChildrenIsArray && nextChildrenIsArray) {
- patchArrayChildren(parentDom, lastChildren, nextChildren, context, isSvg);
- } else if (!lastChildrenIsArray && !nextChildrenIsArray) {
- patch(lastChildren, nextChildren, parentDom, context, isSvg);
- } else if (lastChildrenIsArray && !nextChildrenIsArray) {
- patchArrayChildren(parentDom, lastChildren, [nextChildren], context, isSvg);
- } else if (!lastChildrenIsArray && nextChildrenIsArray) {
- patchArrayChildren(parentDom, [lastChildren], nextChildren, context, isSvg);
- }
- }
- function patchNonKeyedChildren(parentDom, lastChildren, nextChildren, context, isSvg, lastLength, nextLength) {
- var minLength = Math.min(lastLength, nextLength);
- var i = 0;
- while (i < minLength) {
- patch(lastChildren[i], nextChildren[i], parentDom, context, isSvg);
- i++;
- }
- if (lastLength < nextLength) {
- for (i = minLength; i < nextLength; i++) {
- if (parentDom !== null) {
- parentDom.appendChild(createElement(nextChildren[i], isSvg, context));
- }
- }
- } else if (lastLength > nextLength) {
- for (i = minLength; i < lastLength; i++) {
- unmount(lastChildren[i], parentDom);
- }
- }
- }
- /**
- *
- * Virtual DOM patching algorithm based on ivi by
- * Boris Kaul (@localvoid)
- * Licensed under the MIT License
- * https://github.com/ivijs/ivi/blob/master/LICENSE
- *
- */
- function patchKeyedChildren(a, b, dom, context, isSvg, aLength, bLength) {
- var aEnd = aLength - 1;
- var bEnd = bLength - 1;
- var aStart = 0;
- var bStart = 0;
- var i;
- var j;
- var aNode;
- var bNode;
- var nextNode;
- var nextPos;
- var node;
- var aStartNode = a[aStart];
- var bStartNode = b[bStart];
- var aEndNode = a[aEnd];
- var bEndNode = b[bEnd];
- // Step 1
- // tslint:disable-next-line
- outer: {
- // Sync nodes with the same key at the beginning.
- while (aStartNode.key === bStartNode.key) {
- patch(aStartNode, bStartNode, dom, context, isSvg);
- aStart++;
- bStart++;
- if (aStart > aEnd || bStart > bEnd) {
- break outer;
- }
- aStartNode = a[aStart];
- bStartNode = b[bStart];
- }
- // Sync nodes with the same key at the end.
- while (aEndNode.key === bEndNode.key) {
- patch(aEndNode, bEndNode, dom, context, isSvg);
- aEnd--;
- bEnd--;
- if (aStart > aEnd || bStart > bEnd) {
- break outer;
- }
- aEndNode = a[aEnd];
- bEndNode = b[bEnd];
- }
- }
- if (aStart > aEnd) {
- if (bStart <= bEnd) {
- nextPos = bEnd + 1;
- nextNode = nextPos < bLength ? b[nextPos].dom : null;
- while (bStart <= bEnd) {
- node = b[bStart];
- bStart++;
- attachNewNode(dom, createElement(node, isSvg, context), nextNode);
- }
- }
- } else if (bStart > bEnd) {
- while (aStart <= aEnd) {
- unmount(a[aStart++], dom);
- }
- } else {
- var aLeft = aEnd - aStart + 1;
- var bLeft = bEnd - bStart + 1;
- var sources = new Array(bLeft);
- // Mark all nodes as inserted.
- for (i = 0; i < bLeft; i++) {
- sources[i] = -1;
- }
- var moved = false;
- var pos = 0;
- var patched = 0;
- // When sizes are small, just loop them through
- if (bLeft <= 4 || aLeft * bLeft <= 16) {
- for (i = aStart; i <= aEnd; i++) {
- aNode = a[i];
- if (patched < bLeft) {
- for (j = bStart; j <= bEnd; j++) {
- bNode = b[j];
- if (aNode.key === bNode.key) {
- sources[j - bStart] = i;
- if (pos > j) {
- moved = true;
- } else {
- pos = j;
- }
- patch(aNode, bNode, dom, context, isSvg);
- patched++;
- a[i] = null;
- break;
- }
- }
- }
- }
- } else {
- var keyIndex = new MapClass();
- for (i = bStart; i <= bEnd; i++) {
- keyIndex.set(b[i].key, i);
- }
- for (i = aStart; i <= aEnd; i++) {
- aNode = a[i];
- if (patched < bLeft) {
- j = keyIndex.get(aNode.key);
- if (j !== undefined) {
- bNode = b[j];
- sources[j - bStart] = i;
- if (pos > j) {
- moved = true;
- } else {
- pos = j;
- }
- patch(aNode, bNode, dom, context, isSvg);
- patched++;
- a[i] = null;
- }
- }
- }
- }
- if (aLeft === aLength && patched === 0) {
- unmountChildren(a);
- dom.textContent = '';
- while (bStart < bLeft) {
- node = b[bStart];
- bStart++;
- attachNewNode(dom, createElement(node, isSvg, context), null);
- }
- } else {
- i = aLeft - patched;
- while (i > 0) {
- aNode = a[aStart++];
- if (aNode !== null) {
- unmount(aNode, dom);
- i--;
- }
- }
- if (moved) {
- var seq = lis(sources);
- j = seq.length - 1;
- for (i = bLeft - 1; i >= 0; i--) {
- if (sources[i] === -1) {
- pos = i + bStart;
- node = b[pos];
- nextPos = pos + 1;
- attachNewNode(dom, createElement(node, isSvg, context), nextPos < bLength ? b[nextPos].dom : null);
- } else {
- if (j < 0 || i !== seq[j]) {
- pos = i + bStart;
- node = b[pos];
- nextPos = pos + 1;
- attachNewNode(dom, node.dom, nextPos < bLength ? b[nextPos].dom : null);
- } else {
- j--;
- }
- }
- }
- } else if (patched !== bLeft) {
- for (i = bLeft - 1; i >= 0; i--) {
- if (sources[i] === -1) {
- pos = i + bStart;
- node = b[pos];
- nextPos = pos + 1;
- attachNewNode(dom, createElement(node, isSvg, context), nextPos < bLength ? b[nextPos].dom : null);
- }
- }
- }
- }
- }
- }
- function attachNewNode(parentDom, newNode, nextNode) {
- if (isNullOrUndef(nextNode)) {
- parentDom.appendChild(newNode);
- } else {
- parentDom.insertBefore(newNode, nextNode);
- }
- }
- /**
- * Slightly modified Longest Increased Subsequence algorithm, it ignores items that have -1 value, they're representing
- * new items.
- *
- * http://en.wikipedia.org/wiki/Longest_increasing_subsequence
- *
- * @param a Array of numbers.
- * @returns Longest increasing subsequence.
- */
- function lis(a) {
- var p = a.slice();
- var result = [];
- result.push(0);
- var u;
- var v;
- for (var i = 0, il = a.length; i < il; ++i) {
- if (a[i] === -1) {
- continue;
- }
- var j = result[result.length - 1];
- if (a[j] < a[i]) {
- p[i] = j;
- result.push(i);
- continue;
- }
- u = 0;
- v = result.length - 1;
- while (u < v) {
- var c = (u + v) / 2 | 0;
- if (a[result[c]] < a[i]) {
- u = c + 1;
- } else {
- v = c;
- }
- }
- if (a[i] < a[result[u]]) {
- if (u > 0) {
- p[i] = result[u - 1];
- }
- result[u] = i;
- }
- }
- u = result.length;
- v = result[u - 1];
- while (u-- > 0) {
- result[u] = v;
- v = p[v];
- }
- return result;
- }
- function isKeyed(lastChildren, nextChildren) {
- return nextChildren.length > 0 && !isNullOrUndef(nextChildren[0]) && !isNullOrUndef(nextChildren[0].key) && lastChildren.length > 0 && !isNullOrUndef(lastChildren[0]) && !isNullOrUndef(lastChildren[0].key);
- }
- function isSameVNode(a, b) {
- if (isInvalid(a) || isInvalid(b) || isArray(a) || isArray(b)) {
- return false;
- }
- return a.type === b.type && a.key === b.key;
- }
- function patchVText(lastVNode, nextVNode) {
- var dom = lastVNode.dom;
- if (dom === null) {
- return;
- }
- var nextText = nextVNode.text;
- nextVNode.dom = dom;
- if (lastVNode.text !== nextText) {
- dom.nodeValue = nextText;
- }
- return dom;
- }
- var skipProps = {
- children: 1,
- key: 1,
- ref: 1,
- owner: 1
- };
- var IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i;
- function setStyle(domStyle, style, value) {
- if (isNullOrUndef(value) || isNumber(value) && isNaN(value)) {
- domStyle[style] = '';
- return;
- }
- if (style === 'float') {
- domStyle['cssFloat'] = value;
- domStyle['styleFloat'] = value;
- return;
- }
- domStyle[style] = !isNumber(value) || IS_NON_DIMENSIONAL.test(style) ? value : value + 'px';
- }
- function patchEvent(eventName, lastEvent, nextEvent, domNode) {
- if (lastEvent !== nextEvent) {
- if (isFunction(lastEvent)) {
- detachEvent(domNode, eventName, lastEvent);
- }
- attachEvent(domNode, eventName, nextEvent);
- }
- }
- function patchStyle(lastAttrValue, nextAttrValue, dom) {
- var domStyle = dom.style;
- var style;
- var value;
- if (isString(nextAttrValue)) {
- domStyle.cssText = nextAttrValue;
- return;
- }
- if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) {
- for (style in nextAttrValue) {
- value = nextAttrValue[style];
- if (value !== lastAttrValue[style]) {
- setStyle(domStyle, style, value);
- }
- }
- } else {
- for (style in nextAttrValue) {
- value = nextAttrValue[style];
- setStyle(domStyle, style, value);
- }
- }
- }
- function patchProp(domNode, prop, lastValue, nextValue, lastVnode, isSvg) {
- // fix the value update for textarea/input
- if (lastValue !== nextValue || prop === 'value') {
- if (prop === 'className') {
- prop = 'class';
- }
- if (skipProps[prop] === 1) {
- return;
- } else if (prop === 'class' && !isSvg) {
- domNode.className = nextValue;
- } else if (prop === 'dangerouslySetInnerHTML') {
- var lastHtml = lastValue && lastValue.__html;
- var nextHtml = nextValue && nextValue.__html;
- if (lastHtml !== nextHtml) {
- if (!isNullOrUndef(nextHtml)) {
- if (isValidElement(lastVnode) && lastVnode.children !== EMPTY_CHILDREN) {
- unmountChildren(lastVnode.children);
- lastVnode.children = [];
- }
- domNode.innerHTML = nextHtml;
- }
- }
- } else if (isAttrAnEvent(prop)) {
- patchEvent(prop, lastValue, nextValue, domNode);
- } else if (prop === 'style') {
- patchStyle(lastValue, nextValue, domNode);
- } else if (prop !== 'list' && prop !== 'type' && !isSvg && prop in domNode) {
- setProperty(domNode, prop, nextValue == null ? '' : nextValue);
- if (nextValue == null || nextValue === false) {
- domNode.removeAttribute(prop);
- }
- } else if (isNullOrUndef(nextValue) || nextValue === false) {
- domNode.removeAttribute(prop);
- } else {
- var namespace = SVGPropertyConfig.DOMAttributeNamespaces[prop];
- if (isSvg && namespace) {
- if (nextValue) {
- domNode.setAttributeNS(namespace, prop, nextValue);
- } else {
- var colonPosition = prop.indexOf(':');
- var localName = colonPosition > -1 ? prop.substr(colonPosition + 1) : prop;
- domNode.removeAttributeNS(namespace, localName);
- }
- } else {
- if (!isFunction(nextValue)) {
- domNode.setAttribute(prop, nextValue);
- }
- // WARNING: Non-event attributes with function values:
- // https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html#changes-in-detail
- }
- }
- }
- }
- function setProperty(node, name, value) {
- try {
- node[name] = value;
- } catch (e) {}
- }
- function patchProps(domNode, nextProps, previousProps, lastVnode, isSvg) {
- for (var propName in previousProps) {
- var value = previousProps[propName];
- if (isNullOrUndef(nextProps[propName]) && !isNullOrUndef(value)) {
- if (isAttrAnEvent(propName)) {
- detachEvent(domNode, propName, value);
- } else if (propName === 'dangerouslySetInnerHTML') {
- domNode.textContent = '';
- } else if (propName === 'className') {
- domNode.removeAttribute('class');
- } else {
- domNode.removeAttribute(propName);
- }
- }
- }
- for (var propName$1 in nextProps) {
- patchProp(domNode, propName$1, previousProps[propName$1], nextProps[propName$1], lastVnode, isSvg);
- }
- }
- var SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
- function createElement(vnode, isSvg, parentContext, parentComponent) {
- var domNode;
- if (isValidElement(vnode)) {
- var vtype = vnode.vtype;
- if (vtype & (4 /* Composite */ | 8 /* Stateless */)) {
- domNode = vnode.init(parentContext, parentComponent);
- options.afterMount(vnode);
- } else if (vtype & 1 /* Text */) {
- domNode = doc.createTextNode(vnode.text);
- vnode.dom = domNode;
- } else if (vtype & 2 /* Node */) {
- domNode = mountVNode$1(vnode, isSvg, parentContext, parentComponent);
- } else if (vtype & 16 /* Void */) {
- domNode = vnode.dom;
- } else if (isPortal(vtype, vnode)) {
- vnode.type.appendChild(createElement(vnode.children, isSvg, parentContext, parentComponent));
- domNode = doc.createTextNode('');
- }
- } else if (isString(vnode) || isNumber(vnode)) {
- domNode = doc.createTextNode(vnode);
- } else if (isNullOrUndef(vnode) || isBoolean(vnode)) {
- domNode = doc.createTextNode('');
- } else if (isArray(vnode)) {
- domNode = doc.createDocumentFragment();
- vnode.forEach(function (child) {
- if (!isInvalid(child)) {
- var childNode = createElement(child, isSvg, parentContext, parentComponent);
- if (childNode) {
- domNode.appendChild(childNode);
- }
- }
- });
- } else {
- throw new Error('Unsupported VNode.');
- }
- return domNode;
- }
- function mountVNode$1(vnode, isSvg, parentContext, parentComponent) {
- if (vnode.isSvg) {
- isSvg = true;
- } else if (vnode.type === 'svg') {
- isSvg = true;
- /* istanbul ignore next */
- } else if (!isSupportSVG) {
- isSvg = false;
- }
- if (isSvg) {
- vnode.namespace = SVG_NAMESPACE;
- vnode.isSvg = isSvg;
- }
- var domNode = !isSvg ? doc.createElement(vnode.type) : doc.createElementNS(vnode.namespace, vnode.type);
- setProps(domNode, vnode, isSvg);
- if (vnode.type === 'foreignObject') {
- isSvg = false;
- }
- var children = vnode.children;
- if (isArray(children)) {
- for (var i = 0, len = children.length; i < len; i++) {
- mountChild(children[i], domNode, parentContext, isSvg, parentComponent);
- }
- } else {
- mountChild(children, domNode, parentContext, isSvg, parentComponent);
- }
- vnode.dom = domNode;
- if (vnode.ref !== null) {
- Ref.attach(vnode, vnode.ref, domNode);
- }
- return domNode;
- }
- function mountChild(child, domNode, parentContext, isSvg, parentComponent) {
- child.parentContext = parentContext || EMPTY_OBJ;
- var childNode = createElement(child, isSvg, parentContext, parentComponent);
- if (childNode !== null) {
- domNode.appendChild(childNode);
- }
- }
- function setProps(domNode, vnode, isSvg) {
- var props = vnode.props;
- for (var p in props) {
- patchProp(domNode, p, null, props[p], null, isSvg);
- }
- }
- function createVText(text) {
- return {
- text: text,
- vtype: 1 /* Text */
- , dom: null
- };
- }
- function createVoid() {
- var dom = doc.createTextNode('');
- return {
- dom: dom,
- vtype: 16 /* Void */
- };
- }
- var readyComponents = [];
- function errorCatcher(fn, component) {
- try {
- return fn();
- } catch (error) {
- errorHandler(component, error);
- }
- }
- function errorHandler(component, error) {
- var boundary;
- while (true) {
- if (isFunction(component.componentDidCatch)) {
- boundary = component;
- break;
- } else if (component._parentComponent) {
- component = component._parentComponent;
- } else {
- break;
- }
- }
- if (boundary) {
- var _disable = boundary._disable;
- boundary._disable = false;
- boundary.componentDidCatch(error);
- boundary._disable = _disable;
- } else {
- throw error;
- }
- }
- function mountVNode(vnode, parentContext, parentComponent) {
- return createElement(vnode, false, parentContext, parentComponent);
- }
- function mountComponent(vnode, parentContext, parentComponent) {
- var ref = vnode.ref;
- vnode.component = new vnode.type(vnode.props, parentContext);
- var component = vnode.component;
- if (isComponent(parentComponent)) {
- component._parentComponent = parentComponent;
- }
- if (isFunction(component.componentWillMount)) {
- errorCatcher(function () {
- component.componentWillMount();
- }, component);
- component.state = component.getState();
- }
- component._dirty = false;
- var rendered = renderComponent(component);
- component._rendered = rendered;
- if (isFunction(component.componentDidMount)) {
- readyComponents.push(component);
- }
- if (!isNullOrUndef(ref)) {
- Ref.attach(vnode, ref, component.dom);
- }
- var dom = vnode.dom = component.dom = mountVNode(rendered, getChildContext(component, parentContext), component);
- component._disable = false;
- return dom;
- }
- function mountStatelessComponent(vnode, parentContext) {
- vnode._rendered = vnode.type(vnode.props, parentContext);
- return vnode.dom = mountVNode(vnode._rendered, parentContext);
- }
- function getChildContext(component, context) {
- if (component.getChildContext) {
- return extend(context, component.getChildContext());
- }
- return context;
- }
- function renderComponent(component) {
- Current.current = component;
- var rendered;
- errorCatcher(function () {
- rendered = component.render();
- }, component);
- if (isNumber(rendered) || isString(rendered)) {
- rendered = createVText(rendered);
- } else if (isUndefined(rendered)) {
- rendered = createVoid();
- }
- Current.current = null;
- return rendered;
- }
- function flushMount() {
- if (!readyComponents.length) {
- return;
- }
- // @TODO: perf
- var queue = readyComponents.slice(0);
- readyComponents.length = 0;
- queue.forEach(function (item) {
- if (isFunction(item)) {
- item();
- } else if (item.componentDidMount) {
- errorCatcher(function () {
- item.componentDidMount();
- }, item);
- }
- });
- }
- function reRenderComponent(prev, current) {
- var component = current.component = prev.component;
- var nextProps = current.props;
- var nextContext = component.context;
- component._disable = true;
- if (isFunction(component.componentWillReceiveProps)) {
- errorCatcher(function () {
- component.componentWillReceiveProps(nextProps, nextContext);
- }, component);
- }
- component._disable = false;
- component.prevProps = component.props;
- component.prevState = component.state;
- component.prevContext = component.context;
- component.props = nextProps;
- component.context = nextContext;
- if (!isNullOrUndef(current.ref)) {
- Ref.update(prev, current);
- }
- updateComponent(component);
- return component.dom;
- }
- function reRenderStatelessComponent(prev, current, parentContext, domNode) {
- var lastRendered = prev._rendered;
- var rendered = current.type(current.props, parentContext);
- current._rendered = rendered;
- return current.dom = patch(lastRendered, rendered, domNode, parentContext);
- }
- function updateComponent(component, isForce) {
- if (isForce === void 0) isForce = false;
- var lastDom = component.dom;
- var props = component.props;
- var state = component.getState();
- var context = component.context;
- var prevProps = component.prevProps || props;
- var prevState = component.prevState || state;
- var prevContext = component.prevContext || context;
- component.props = prevProps;
- component.context = prevContext;
- var skip = false;
- if (!isForce && isFunction(component.shouldComponentUpdate) && component.shouldComponentUpdate(props, state, context) === false) {
- skip = true;
- } else if (isFunction(component.componentWillUpdate)) {
- errorCatcher(function () {
- component.componentWillUpdate(props, state, context);
- }, component);
- }
- component.props = props;
- component.state = state;
- component.context = context;
- component._dirty = false;
- if (!skip) {
- var lastRendered = component._rendered;
- var rendered = renderComponent(component);
- var childContext = getChildContext(component, context);
- component.dom = patch(lastRendered, rendered, lastDom, childContext);
- component._rendered = rendered;
- if (isFunction(component.componentDidUpdate)) {
- errorCatcher(function () {
- component.componentDidUpdate(prevProps, prevState, context);
- }, component);
- }
- }
- component.prevProps = component.props;
- component.prevState = component.state;
- component.prevContext = component.context;
- if (component._pendingCallbacks) {
- while (component._pendingCallbacks.length) {
- component._pendingCallbacks.pop().call(component);
- }
- }
- flushMount();
- }
- function unmountComponent(vnode) {
- var component = vnode.component;
- if (isFunction(component.componentWillUnmount)) {
- errorCatcher(function () {
- component.componentWillUnmount();
- }, component);
- }
- component._disable = true;
- unmount(component._rendered);
- if (!isNullOrUndef(vnode.ref)) {
- Ref.detach(vnode, vnode.ref, vnode.dom);
- }
- }
- function unmountStatelessComponent(vnode) {
- unmount(vnode._rendered);
- }
- var items = [];
- function enqueueRender(component) {
- // tslint:disable-next-line:no-conditional-assignment
- if (!component._dirty && (component._dirty = true) && items.push(component) === 1) {
- nextTick(rerender);
- }
- }
- function rerender() {
- var p;
- var list = items;
- items = [];
- // tslint:disable-next-line:no-conditional-assignment
- while (p = list.pop()) {
- if (p._dirty) {
- updateComponent(p);
- }
- }
- }
- var Component = function Component(props, context) {
- this._dirty = true;
- this._disable = true;
- this._pendingStates = [];
- // Is a React Component.
- // tslint:disable-next-line:max-line-length
- // see: https://github.com/facebook/react/blob/3c977dea6b96f6a9bb39f09886848da870748441/packages/react/src/ReactBaseClasses.js#L26
- this.isReactComponent = EMPTY_OBJ;
- if (!this.state) {
- this.state = {};
- }
- this.props = props || {};
- this.context = context || EMPTY_OBJ;
- this.refs = {};
- };
- Component.prototype.setState = function setState(state, callback) {
- if (state) {
- (this._pendingStates = this._pendingStates || []).push(state);
- }
- if (isFunction(callback)) {
- (this._pendingCallbacks = this._pendingCallbacks || []).push(callback);
- }
- if (!this._disable) {
- enqueueRender(this);
- }
- };
- Component.prototype.getState = function getState() {
- var this$1 = this;
- // tslint:disable-next-line:no-this-assignment
- var ref = this;
- var _pendingStates = ref._pendingStates;
- var state = ref.state;
- var props = ref.props;
- if (!_pendingStates.length) {
- return state;
- }
- var stateClone = clone(state);
- var queue = _pendingStates.concat();
- this._pendingStates.length = 0;
- queue.forEach(function (nextState) {
- if (isFunction(nextState)) {
- nextState = nextState.call(this$1, state, props);
- }
- extend(stateClone, nextState);
- });
- return stateClone;
- };
- Component.prototype.forceUpdate = function forceUpdate(callback) {
- if (isFunction(callback)) {
- (this._pendingCallbacks = this._pendingCallbacks || []).push(callback);
- }
- updateComponent(this, true);
- };
- // tslint:disable-next-line
- Component.prototype.render = function render(nextProps, nextState, nextContext) {};
- var PureComponent = function (Component$$1) {
- function PureComponent() {
- Component$$1.apply(this, arguments);
- this.isPureComponent = true;
- }
- if (Component$$1) PureComponent.__proto__ = Component$$1;
- PureComponent.prototype = Object.create(Component$$1 && Component$$1.prototype);
- PureComponent.prototype.constructor = PureComponent;
- PureComponent.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
- return !shallowEqual(this.props, nextProps) || !shallowEqual(this.state, nextState);
- };
- return PureComponent;
- }(Component);
- function render(vnode, container, callback) {
- if (!container) {
- throw new Error(container + " should be a DOM Element");
- }
- var lastVnode = container._component;
- var dom;
- options.roots.push(vnode);
- if (lastVnode !== undefined) {
- options.roots = options.roots.filter(function (item) {
- return item !== lastVnode;
- });
- dom = patch(lastVnode, vnode, container, {});
- } else {
- dom = mountVNode(vnode, {});
- container.appendChild(dom);
- }
- if (container) {
- container._component = vnode;
- }
- flushMount();
- if (callback) {
- callback();
- }
- return isComposite(vnode) ? vnode.component : dom;
- }
- function createVNode(type, props, children, key, namespace, owner, ref) {
- return {
- type: type,
- key: key || null,
- vtype: 2 /* Node */
- , props: props || EMPTY_OBJ,
- children: children,
- namespace: namespace || null,
- _owner: owner,
- dom: null,
- ref: ref || null
- };
- }
- function h(type, props, children) {
- var childNodes;
- if (props.children) {
- if (!children) {
- children = props.children;
- }
- }
- if (isArray(children)) {
- childNodes = [];
- addChildren(childNodes, children, type);
- } else if (isString(children) || isNumber(children)) {
- children = createVText(String(children));
- } else if (!isValidElement(children)) {
- children = EMPTY_CHILDREN;
- }
- props.children = childNodes !== undefined ? childNodes : children;
- return createVNode(type, props, props.children, props.key, props.namespace, props.owner, props.ref);
- }
- function addChildren(childNodes, children, type) {
- if (isString(children) || isNumber(children)) {
- childNodes.push(createVText(String(children)));
- } else if (isValidElement(children)) {
- childNodes.push(children);
- } else if (isArray(children)) {
- for (var i = 0; i < children.length; i++) {
- addChildren(childNodes, children[i], type);
- }
- }
- }
- var ComponentWrapper = function ComponentWrapper(type, props) {
- this.vtype = 4 /* Composite */;
- this.type = type;
- this.name = type.name || type.toString().match(/^function\s*([^\s(]+)/)[1];
- type.displayName = this.name;
- this._owner = props.owner;
- delete props.owner;
- if (this.ref = props.ref) {
- delete props.ref;
- }
- this.props = props;
- this.key = props.key;
- this.dom = null;
- };
- ComponentWrapper.prototype.init = function init(parentContext, parentComponent) {
- return mountComponent(this, parentContext, parentComponent);
- };
- ComponentWrapper.prototype.update = function update(previous, current, parentContext, domNode) {
- return reRenderComponent(previous, this);
- };
- ComponentWrapper.prototype.destroy = function destroy() {
- unmountComponent(this);
- };
- var StateLessComponent = function StateLessComponent(type, props) {
- this.vtype = 8 /* Stateless */;
- this.type = type;
- this._owner = props.owner;
- delete props.owner;
- this.props = props;
- this.key = props.key;
- };
- StateLessComponent.prototype.init = function init(parentContext) {
- return mountStatelessComponent(this, parentContext);
- };
- StateLessComponent.prototype.update = function update(previous, current, parentContext, domNode) {
- var props = current.props;
- var context = current.context;
- var shouldComponentUpdate = props.onShouldComponentUpdate;
- if (isFunction(shouldComponentUpdate) && !shouldComponentUpdate(previous.props, props, context)) {
- current._rendered = previous._rendered;
- return domNode;
- }
- return reRenderStatelessComponent(previous, this, parentContext, domNode);
- };
- StateLessComponent.prototype.destroy = function destroy() {
- unmountStatelessComponent(this);
- };
- function transformPropsForRealTag(type, props) {
- var newProps = {};
- for (var propName in props) {
- var propValue = props[propName];
- if (propName === 'defaultValue') {
- newProps.value = props.value || props.defaultValue;
- continue;
- }
- var svgPropName = SVGPropertyConfig.DOMAttributeNames[propName];
- if (svgPropName && svgPropName !== propName) {
- newProps[svgPropName] = propValue;
- continue;
- }
- newProps[propName] = propValue;
- }
- return newProps;
- }
- /**
- *
- * @param props
- * @param defaultProps
- * defaultProps should respect null but ignore undefined
- * @see: https://facebook.github.io/react/docs/react-component.html#defaultprops
- */
- function transformPropsForComponent(props, defaultProps) {
- var newProps = {};
- for (var propName in props) {
- var propValue = props[propName];
- newProps[propName] = propValue;
- }
- if (defaultProps) {
- for (var propName$1 in defaultProps) {
- if (isUndefined(newProps[propName$1])) {
- newProps[propName$1] = defaultProps[propName$1];
- }
- }
- }
- return newProps;
- }
- function createElement$2(type, properties) {
- var _children = [],
- len = arguments.length - 2;
- while (len-- > 0) _children[len] = arguments[len + 2];
- var children = _children;
- if (_children) {
- if (_children.length === 1) {
- children = _children[0];
- } else if (_children.length === 0) {
- children = undefined;
- }
- }
- var props;
- if (isString(type)) {
- props = transformPropsForRealTag(type, properties);
- props.owner = Current.current;
- return h(type, props, children);
- } else if (isFunction(type)) {
- props = transformPropsForComponent(properties, type.defaultProps);
- if (!props.children || props.children === EMPTY_CHILDREN) {
- props.children = children || EMPTY_CHILDREN;
- }
- props.owner = Current.current;
- return type.prototype && type.prototype.render ? new ComponentWrapper(type, props) : new StateLessComponent(type, props);
- }
- return type;
- }
- function cloneElement(vnode, props) {
- var children = [],
- len = arguments.length - 2;
- while (len-- > 0) children[len] = arguments[len + 2];
- if (isVText(vnode)) {
- vnode.dom = null;
- return vnode;
- }
- if (isString(vnode)) {
- return createVText(vnode);
- }
- var properties = clone(extend(clone(vnode.props), props));
- if (vnode.namespace) {
- properties.namespace = vnode.namespace;
- }
- if (vnode.vtype & 4 /* Composite */ && !isNullOrUndef(vnode.ref)) {
- properties.ref = vnode.ref;
- }
- var childrenTmp = (arguments.length > 2 ? [].slice.call(arguments, 2) : vnode.children || properties.children) || [];
- if (childrenTmp.length) {
- if (childrenTmp.length === 1) {
- childrenTmp = children[0];
- }
- }
- if (isArray(vnode)) {
- return vnode.map(function (item) {
- return cloneElement(item);
- });
- }
- var newVNode = createElement$2(vnode.type, properties);
- if (isArray(childrenTmp)) {
- var _children = childrenTmp.map(function (child) {
- return cloneElement(child, child.props);
- });
- if (_children.length === 0) {
- _children = EMPTY_CHILDREN;
- }
- if (isVNode(newVNode)) {
- newVNode.children = _children;
- }
- newVNode.props.children = _children;
- } else if (childrenTmp) {
- if (isVNode(newVNode)) {
- newVNode.children = childrenTmp;
- }
- newVNode.props.children = cloneElement(childrenTmp, childrenTmp.props);
- }
- return newVNode;
- }
- var Children = {
- map: function map(children, fn, ctx) {
- if (isNullOrUndef(children)) {
- return children;
- }
- children = Children.toArray(children);
- if (ctx && ctx !== children) {
- fn = fn.bind(ctx);
- }
- return children.map(fn);
- },
- forEach: function forEach(children, fn, ctx) {
- if (isNullOrUndef(children)) {
- return;
- }
- children = Children.toArray(children);
- if (ctx && ctx !== children) {
- fn = fn.bind(ctx);
- }
- for (var i = 0, len = children.length; i < len; i++) {
- var child = isInvalid(children[i]) ? null : children[i];
- fn(child, i, children);
- }
- },
- count: function count(children) {
- children = Children.toArray(children);
- return children.length;
- },
- only: function only(children) {
- children = Children.toArray(children);
- if (children.length !== 1) {
- throw new Error('Children.only() expects only one child.');
- }
- return children[0];
- },
- toArray: function toArray(children) {
- if (isNullOrUndef(children)) {
- return [];
- }
- if (isArray(children)) {
- var result = [];
- flatten(children, result);
- return result;
- }
- return EMPTY_CHILDREN.concat(children);
- }
- };
- function flatten(arr, result) {
- for (var i = 0, len = arr.length; i < len; i++) {
- var value = arr[i];
- if (isArray(value)) {
- flatten(value, result);
- } else {
- result.push(value);
- }
- }
- return result;
- }
- // tslint:disable:no-conditional-assignment
- function hydrate(vnode, container, callback) {
- if (container !== null) {
- // lastChild causes less reflow than firstChild
- var dom = container.lastChild;
- // there should be only a single entry for the root
- while (dom) {
- var next = dom.previousSibling;
- container.removeChild(dom);
- dom = next;
- }
- return render(vnode, container, callback);
- }
- }
- function createPortal(children, container) {
- return {
- type: container,
- vtype: 32 /* Portal */
- , children: children,
- dom: null
- };
- }
- function unmountComponentAtNode(dom) {
- var component = dom._component;
- if (isValidElement(component)) {
- unmount(component, dom);
- delete dom._component;
- return true;
- }
- return false;
- }
- function findDOMNode(component) {
- return component && component.dom || component;
- }
- function createFactory(type) {
- return createElement$2.bind(null, type);
- }
- var WrapperComponent = function (Component$$1) {
- function WrapperComponent() {
- Component$$1.apply(this, arguments);
- }
- if (Component$$1) WrapperComponent.__proto__ = Component$$1;
- WrapperComponent.prototype = Object.create(Component$$1 && Component$$1.prototype);
- WrapperComponent.prototype.constructor = WrapperComponent;
- WrapperComponent.prototype.getChildContext = function getChildContext() {
- // tslint:disable-next-line
- return this.props.context;
- };
- WrapperComponent.prototype.render = function render$$1() {
- return this.props.children;
- };
- return WrapperComponent;
- }(Component);
- function unstable_renderSubtreeIntoContainer(parentComponent, vnode, container, callback) {
- // @TODO: should handle props.context?
- var wrapper = createElement$2(WrapperComponent, { context: parentComponent.context }, vnode);
- var rendered = render(wrapper, container);
- if (callback) {
- callback.call(rendered);
- }
- return rendered;
- }
- function isValidElement$1(element) {
- return isValidElement(element) && (element.vtype & (4 /* Composite */ | 2 /* Node */)) > 0;
- }
- var unstable_batchedUpdates = nextTick;
- var nerv = {
- Children: Children,
- Component: Component,
- PureComponent: PureComponent,
- createElement: createElement$2,
- cloneElement: cloneElement,
- render: render,
- nextTick: nextTick,
- options: options,
- findDOMNode: findDOMNode,
- isValidElement: isValidElement$1,
- unmountComponentAtNode: unmountComponentAtNode,
- createPortal: createPortal,
- unstable_renderSubtreeIntoContainer: unstable_renderSubtreeIntoContainer,
- hydrate: hydrate,
- createFactory: createFactory,
- unstable_batchedUpdates: unstable_batchedUpdates
- };
- //exports.Children = Children;
- //exports.Component = Component;
- //exports.PureComponent = PureComponent;
- //exports.createElement = createElement$2;
- //exports.cloneElement = cloneElement;
- //exports.render = render;
- //exports.nextTick = nextTick;
- //exports.options = options;
- //exports.findDOMNode = findDOMNode;
- //exports.isValidElement = isValidElement$1;
- //exports.unmountComponentAtNode = unmountComponentAtNode;
- //exports.createPortal = createPortal;
- //exports.unstable_renderSubtreeIntoContainer = unstable_renderSubtreeIntoContainer;
- //exports.hydrate = hydrate;
- //exports.createFactory = createFactory;
- //exports.unstable_batchedUpdates = unstable_batchedUpdates;
- window.React = window.ReactDOM = nerv;
- //module.exports = nerv;
- //exports['default'] = index;
- //# sourceMappingURL=index.js.map
|