inferno.js 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  3. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  4. (factory((global.Inferno = global.Inferno || {})));
  5. }(this, (function (exports) { 'use strict';
  6. var NO_OP = '$NO_OP';
  7. var ERROR_MSG = 'a runtime error occured! Use Inferno in development environment to find the error.';
  8. // This should be boolean and not reference to window.document
  9. var isBrowser = !!(typeof window !== 'undefined' && window.document);
  10. // this is MUCH faster than .constructor === Array and instanceof Array
  11. // in Node 7 and the later versions of V8, slower in older versions though
  12. var isArray = Array.isArray;
  13. function isStringOrNumber(o) {
  14. var type = typeof o;
  15. return type === 'string' || type === 'number';
  16. }
  17. function isNullOrUndef(o) {
  18. return isUndefined(o) || isNull(o);
  19. }
  20. function isInvalid(o) {
  21. return isNull(o) || o === false || isTrue(o) || isUndefined(o);
  22. }
  23. function isFunction(o) {
  24. return typeof o === 'function';
  25. }
  26. function isString(o) {
  27. return typeof o === 'string';
  28. }
  29. function isNumber(o) {
  30. return typeof o === 'number';
  31. }
  32. function isNull(o) {
  33. return o === null;
  34. }
  35. function isTrue(o) {
  36. return o === true;
  37. }
  38. function isUndefined(o) {
  39. return o === void 0;
  40. }
  41. function isDefined(o) {
  42. return o !== void 0;
  43. }
  44. function isObject(o) {
  45. return typeof o === 'object';
  46. }
  47. function throwError(message) {
  48. if (!message) {
  49. message = ERROR_MSG;
  50. }
  51. throw new Error(("Inferno Error: " + message));
  52. }
  53. function warning(message) {
  54. // tslint:disable-next-line:no-console
  55. console.error(message);
  56. }
  57. function combineFrom(first, second) {
  58. var out = {};
  59. if (first) {
  60. for (var key in first) {
  61. out[key] = first[key];
  62. }
  63. }
  64. if (second) {
  65. for (var key$1 in second) {
  66. out[key$1] = second[key$1];
  67. }
  68. }
  69. return out;
  70. }
  71. function getTagName(input) {
  72. var tagName;
  73. if (isArray(input)) {
  74. var arrayText = input.length > 3 ? input.slice(0, 3).toString() + ',...' : input.toString();
  75. tagName = 'Array(' + arrayText + ')';
  76. }
  77. else if (isStringOrNumber(input)) {
  78. tagName = 'Text(' + input + ')';
  79. }
  80. else if (isInvalid(input)) {
  81. tagName = 'InvalidVNode(' + input + ')';
  82. }
  83. else {
  84. var flags = input.flags;
  85. if (flags & 481 /* Element */) {
  86. tagName = "<" + (input.type) + (input.className ? ' class="' + input.className + '"' : '') + ">";
  87. }
  88. else if (flags & 16 /* Text */) {
  89. tagName = "Text(" + (input.children) + ")";
  90. }
  91. else if (flags & 1024 /* Portal */) {
  92. tagName = "Portal*";
  93. }
  94. else {
  95. var type = input.type;
  96. // Fallback for IE
  97. var componentName = type.name || type.displayName || type.constructor.name || (type.toString().match(/^function\s*([^\s(]+)/) || [])[1];
  98. tagName = "<" + componentName + " />";
  99. }
  100. }
  101. return '>> ' + tagName + '\n';
  102. }
  103. function DEV_ValidateKeys(vNodeTree, vNode, forceKeyed) {
  104. var foundKeys = [];
  105. for (var i = 0, len = vNodeTree.length; i < len; i++) {
  106. var childNode = vNodeTree[i];
  107. if (isArray(childNode)) {
  108. return 'Encountered ARRAY in mount, array must be flattened, or normalize used. Location: \n' + getTagName(childNode);
  109. }
  110. if (isInvalid(childNode)) {
  111. if (forceKeyed) {
  112. return 'Encountered invalid node when preparing to keyed algorithm. Location: \n' + getTagName(childNode);
  113. }
  114. else if (foundKeys.length !== 0) {
  115. return 'Encountered invalid node with mixed keys. Location: \n' + getTagName(childNode);
  116. }
  117. continue;
  118. }
  119. if (typeof childNode === 'object') {
  120. childNode.isValidated = true;
  121. }
  122. var key = childNode.key;
  123. if (!isNullOrUndef(key) && !isStringOrNumber(key)) {
  124. return 'Encountered child vNode where key property is not string or number. Location: \n' + getTagName(childNode);
  125. }
  126. var children = childNode.children;
  127. var childFlags = childNode.childFlags;
  128. if (!isInvalid(children)) {
  129. var val = (void 0);
  130. if (childFlags & 12 /* MultipleChildren */) {
  131. val = DEV_ValidateKeys(children, childNode, childNode.childFlags & 8 /* HasKeyedChildren */);
  132. }
  133. else if (childFlags === 2 /* HasVNodeChildren */) {
  134. val = DEV_ValidateKeys([children], childNode, childNode.childFlags & 8 /* HasKeyedChildren */);
  135. }
  136. if (val) {
  137. val += getTagName(childNode);
  138. return val;
  139. }
  140. }
  141. if (forceKeyed && isNullOrUndef(key)) {
  142. return ('Encountered child without key during keyed algorithm. If this error points to Array make sure children is flat list. Location: \n' +
  143. getTagName(childNode));
  144. }
  145. else if (!forceKeyed && isNullOrUndef(key)) {
  146. if (foundKeys.length !== 0) {
  147. return 'Encountered children with key missing. Location: \n' + getTagName(childNode);
  148. }
  149. continue;
  150. }
  151. if (foundKeys.indexOf(key) > -1) {
  152. return 'Encountered two children with same key: {' + key + '}. Location: \n' + getTagName(childNode);
  153. }
  154. foundKeys.push(key);
  155. }
  156. }
  157. function validateVNodeElementChildren(vNode) {
  158. {
  159. if (vNode.childFlags & 1 /* HasInvalidChildren */) {
  160. return;
  161. }
  162. if (vNode.flags & 64 /* InputElement */) {
  163. throwError("input elements can't have children.");
  164. }
  165. if (vNode.flags & 128 /* TextareaElement */) {
  166. throwError("textarea elements can't have children.");
  167. }
  168. if (vNode.flags & 481 /* Element */) {
  169. var voidTypes = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
  170. var tag = vNode.type.toLowerCase();
  171. if (tag === 'media') {
  172. throwError("media elements can't have children.");
  173. }
  174. var idx = voidTypes.indexOf(tag);
  175. if (idx !== -1) {
  176. throwError(((voidTypes[idx]) + " elements can't have children."));
  177. }
  178. }
  179. }
  180. }
  181. function validateKeys(vNode) {
  182. {
  183. // Checks if there is any key missing or duplicate keys
  184. if (vNode.isValidated === false && vNode.children && vNode.flags & 481 /* Element */) {
  185. var error = DEV_ValidateKeys(Array.isArray(vNode.children) ? vNode.children : [vNode.children], vNode, (vNode.childFlags & 8 /* HasKeyedChildren */) > 0);
  186. if (error) {
  187. throwError(error + getTagName(vNode));
  188. }
  189. }
  190. vNode.isValidated = true;
  191. }
  192. }
  193. var keyPrefix = '$';
  194. function getVNode(childFlags, children, className, flags, key, props, ref, type) {
  195. return {
  196. childFlags: childFlags,
  197. children: children,
  198. className: className,
  199. dom: null,
  200. flags: flags,
  201. isValidated: false,
  202. key: key === void 0 ? null : key,
  203. parentVNode: null,
  204. props: props === void 0 ? null : props,
  205. ref: ref === void 0 ? null : ref,
  206. type: type
  207. };
  208. }
  209. function createVNode(flags, type, className, children, childFlags, props, key, ref) {
  210. {
  211. if (flags & 14 /* Component */) {
  212. throwError('Creating Component vNodes using createVNode is not allowed. Use Inferno.createComponentVNode method.');
  213. }
  214. }
  215. var childFlag = childFlags === void 0 ? 1 /* HasInvalidChildren */ : childFlags;
  216. var vNode = getVNode(childFlag, children, className, flags, key, props, ref, type);
  217. var optsVNode = options.createVNode;
  218. if (typeof optsVNode === 'function') {
  219. optsVNode(vNode);
  220. }
  221. if (childFlag === 0 /* UnknownChildren */) {
  222. normalizeChildren(vNode, vNode.children);
  223. }
  224. {
  225. validateVNodeElementChildren(vNode);
  226. }
  227. return vNode;
  228. }
  229. function createComponentVNode(flags, type, props, key, ref) {
  230. {
  231. if (flags & 1 /* HtmlElement */) {
  232. throwError('Creating element vNodes using createComponentVNode is not allowed. Use Inferno.createVNode method.');
  233. }
  234. }
  235. if ((flags & 2 /* ComponentUnknown */) > 0) {
  236. flags = isDefined(type.prototype) && isFunction(type.prototype.render) ? 4 /* ComponentClass */ : 8 /* ComponentFunction */;
  237. }
  238. // set default props
  239. var defaultProps = type.defaultProps;
  240. if (!isNullOrUndef(defaultProps)) {
  241. if (!props) {
  242. props = {}; // Props can be referenced and modified at application level so always create new object
  243. }
  244. for (var prop in defaultProps) {
  245. if (isUndefined(props[prop])) {
  246. props[prop] = defaultProps[prop];
  247. }
  248. }
  249. }
  250. if ((flags & 8 /* ComponentFunction */) > 0) {
  251. var defaultHooks = type.defaultHooks;
  252. if (!isNullOrUndef(defaultHooks)) {
  253. if (!ref) {
  254. // As ref cannot be referenced from application level, we can use the same refs object
  255. ref = defaultHooks;
  256. }
  257. else {
  258. for (var prop$1 in defaultHooks) {
  259. if (isUndefined(ref[prop$1])) {
  260. ref[prop$1] = defaultHooks[prop$1];
  261. }
  262. }
  263. }
  264. }
  265. }
  266. var vNode = getVNode(1 /* HasInvalidChildren */, null, null, flags, key, props, ref, type);
  267. var optsVNode = options.createVNode;
  268. if (isFunction(optsVNode)) {
  269. optsVNode(vNode);
  270. }
  271. return vNode;
  272. }
  273. function createTextVNode(text, key) {
  274. return getVNode(1 /* HasInvalidChildren */, isNullOrUndef(text) ? '' : text, null, 16 /* Text */, key, null, null, null);
  275. }
  276. function normalizeProps(vNode) {
  277. var props = vNode.props;
  278. if (props) {
  279. if (vNode.flags & 481 /* Element */) {
  280. if (isDefined(props.children) && isNullOrUndef(vNode.children)) {
  281. normalizeChildren(vNode, props.children);
  282. }
  283. if (isDefined(props.className)) {
  284. vNode.className = props.className || null;
  285. props.className = undefined;
  286. }
  287. }
  288. if (isDefined(props.key)) {
  289. vNode.key = props.key;
  290. props.key = undefined;
  291. }
  292. if (isDefined(props.ref)) {
  293. vNode.ref = props.ref;
  294. props.ref = undefined;
  295. }
  296. }
  297. return vNode;
  298. }
  299. function directClone(vNodeToClone) {
  300. var newVNode;
  301. var flags = vNodeToClone.flags;
  302. if (flags & 14 /* Component */) {
  303. var props;
  304. var propsToClone = vNodeToClone.props;
  305. if (!isNull(propsToClone)) {
  306. props = {};
  307. for (var key in propsToClone) {
  308. props[key] = propsToClone[key];
  309. }
  310. }
  311. newVNode = createComponentVNode(flags, vNodeToClone.type, props, vNodeToClone.key, vNodeToClone.ref);
  312. }
  313. else if (flags & 481 /* Element */) {
  314. var children = vNodeToClone.children;
  315. newVNode = createVNode(flags, vNodeToClone.type, vNodeToClone.className, children, 0 /* UnknownChildren */, vNodeToClone.props, vNodeToClone.key, vNodeToClone.ref);
  316. }
  317. else if (flags & 16 /* Text */) {
  318. newVNode = createTextVNode(vNodeToClone.children, vNodeToClone.key);
  319. }
  320. else if (flags & 1024 /* Portal */) {
  321. newVNode = vNodeToClone;
  322. }
  323. return newVNode;
  324. }
  325. function createVoidVNode() {
  326. return createTextVNode('', null);
  327. }
  328. function _normalizeVNodes(nodes, result, index, currentKey) {
  329. for (var len = nodes.length; index < len; index++) {
  330. var n = nodes[index];
  331. if (!isInvalid(n)) {
  332. var newKey = currentKey + keyPrefix + index;
  333. if (isArray(n)) {
  334. _normalizeVNodes(n, result, 0, newKey);
  335. }
  336. else {
  337. if (isStringOrNumber(n)) {
  338. n = createTextVNode(n, newKey);
  339. }
  340. else {
  341. var oldKey = n.key;
  342. var isPrefixedKey = isString(oldKey) && oldKey[0] === keyPrefix;
  343. if (!isNull(n.dom) || isPrefixedKey) {
  344. n = directClone(n);
  345. }
  346. if (isNull(oldKey) || isPrefixedKey) {
  347. n.key = newKey;
  348. }
  349. else {
  350. n.key = currentKey + oldKey;
  351. }
  352. }
  353. result.push(n);
  354. }
  355. }
  356. }
  357. }
  358. function getFlagsForElementVnode(type) {
  359. if (type === 'svg') {
  360. return 32 /* SvgElement */;
  361. }
  362. if (type === 'input') {
  363. return 64 /* InputElement */;
  364. }
  365. if (type === 'select') {
  366. return 256 /* SelectElement */;
  367. }
  368. if (type === 'textarea') {
  369. return 128 /* TextareaElement */;
  370. }
  371. return 1 /* HtmlElement */;
  372. }
  373. function normalizeChildren(vNode, children) {
  374. var newChildren;
  375. var newChildFlags;
  376. // Don't change children to match strict equal (===) true in patching
  377. if (isInvalid(children)) {
  378. newChildFlags = 1 /* HasInvalidChildren */;
  379. newChildren = children;
  380. }
  381. else if (isString(children)) {
  382. newChildFlags = 2 /* HasVNodeChildren */;
  383. newChildren = createTextVNode(children);
  384. }
  385. else if (isNumber(children)) {
  386. newChildFlags = 2 /* HasVNodeChildren */;
  387. newChildren = createTextVNode(children + '');
  388. }
  389. else if (isArray(children)) {
  390. var len = children.length;
  391. if (len === 0) {
  392. newChildren = null;
  393. newChildFlags = 1 /* HasInvalidChildren */;
  394. }
  395. else {
  396. // we assign $ which basically means we've flagged this array for future note
  397. // if it comes back again, we need to clone it, as people are using it
  398. // in an immutable way
  399. // tslint:disable-next-line
  400. if (Object.isFrozen(children) || children['$'] === true) {
  401. children = children.slice();
  402. }
  403. newChildFlags = 8 /* HasKeyedChildren */;
  404. for (var i = 0; i < len; i++) {
  405. var n = children[i];
  406. if (isInvalid(n) || isArray(n)) {
  407. newChildren = newChildren || children.slice(0, i);
  408. _normalizeVNodes(children, newChildren, i, '');
  409. break;
  410. }
  411. else if (isStringOrNumber(n)) {
  412. newChildren = newChildren || children.slice(0, i);
  413. newChildren.push(createTextVNode(n, keyPrefix + i));
  414. }
  415. else {
  416. var key = n.key;
  417. var isNullDom = isNull(n.dom);
  418. var isNullKey = isNull(key);
  419. var isPrefixed = !isNullKey && key[0] === keyPrefix;
  420. if (!isNullDom || isNullKey || isPrefixed) {
  421. newChildren = newChildren || children.slice(0, i);
  422. if (!isNullDom || isPrefixed) {
  423. n = directClone(n);
  424. }
  425. if (isNullKey || isPrefixed) {
  426. n.key = keyPrefix + i;
  427. }
  428. newChildren.push(n);
  429. }
  430. else if (newChildren) {
  431. newChildren.push(n);
  432. }
  433. }
  434. }
  435. newChildren = newChildren || children;
  436. newChildren.$ = true;
  437. }
  438. }
  439. else {
  440. newChildren = children;
  441. if (!isNull(children.dom)) {
  442. newChildren = directClone(children);
  443. }
  444. newChildFlags = 2 /* HasVNodeChildren */;
  445. }
  446. vNode.children = newChildren;
  447. vNode.childFlags = newChildFlags;
  448. {
  449. validateVNodeElementChildren(vNode);
  450. }
  451. return vNode;
  452. }
  453. var options = {
  454. afterMount: null,
  455. afterRender: null,
  456. afterUpdate: null,
  457. beforeRender: null,
  458. beforeUnmount: null,
  459. createVNode: null,
  460. roots: []
  461. };
  462. /**
  463. * Links given data to event as first parameter
  464. * @param {*} data data to be linked, it will be available in function as first parameter
  465. * @param {Function} event Function to be called when event occurs
  466. * @returns {{data: *, event: Function}}
  467. */
  468. function linkEvent(data, event) {
  469. if (isFunction(event)) {
  470. return { data: data, event: event };
  471. }
  472. return null; // Return null when event is invalid, to avoid creating unnecessary event handlers
  473. }
  474. var xlinkNS = 'http://www.w3.org/1999/xlink';
  475. var xmlNS = 'http://www.w3.org/XML/1998/namespace';
  476. var svgNS = 'http://www.w3.org/2000/svg';
  477. var namespaces = {
  478. 'xlink:actuate': xlinkNS,
  479. 'xlink:arcrole': xlinkNS,
  480. 'xlink:href': xlinkNS,
  481. 'xlink:role': xlinkNS,
  482. 'xlink:show': xlinkNS,
  483. 'xlink:title': xlinkNS,
  484. 'xlink:type': xlinkNS,
  485. 'xml:base': xmlNS,
  486. 'xml:lang': xmlNS,
  487. 'xml:space': xmlNS
  488. };
  489. // We need EMPTY_OBJ defined in one place.
  490. // Its used for comparison so we cant inline it into shared
  491. var EMPTY_OBJ = {};
  492. var LIFECYCLE = [];
  493. {
  494. Object.freeze(EMPTY_OBJ);
  495. }
  496. function appendChild(parentDom, dom) {
  497. parentDom.appendChild(dom);
  498. }
  499. function insertOrAppend(parentDom, newNode, nextNode) {
  500. if (isNullOrUndef(nextNode)) {
  501. appendChild(parentDom, newNode);
  502. }
  503. else {
  504. parentDom.insertBefore(newNode, nextNode);
  505. }
  506. }
  507. function documentCreateElement(tag, isSVG) {
  508. if (isSVG === true) {
  509. return document.createElementNS(svgNS, tag);
  510. }
  511. return document.createElement(tag);
  512. }
  513. function replaceChild(parentDom, newDom, lastDom) {
  514. parentDom.replaceChild(newDom, lastDom);
  515. }
  516. function removeChild(parentDom, dom) {
  517. parentDom.removeChild(dom);
  518. }
  519. function callAll(arrayFn) {
  520. var listener;
  521. while ((listener = arrayFn.shift()) !== undefined) {
  522. listener();
  523. }
  524. }
  525. var attachedEventCounts = {};
  526. var attachedEvents = {};
  527. function handleEvent(name, nextEvent, dom) {
  528. var eventsLeft = attachedEventCounts[name];
  529. var eventsObject = dom.$EV;
  530. if (nextEvent) {
  531. if (!eventsLeft) {
  532. attachedEvents[name] = attachEventToDocument(name);
  533. attachedEventCounts[name] = 0;
  534. }
  535. if (!eventsObject) {
  536. eventsObject = dom.$EV = {};
  537. }
  538. if (!eventsObject[name]) {
  539. attachedEventCounts[name]++;
  540. }
  541. eventsObject[name] = nextEvent;
  542. }
  543. else if (eventsObject && eventsObject[name]) {
  544. attachedEventCounts[name]--;
  545. if (eventsLeft === 1) {
  546. document.removeEventListener(normalizeEventName(name), attachedEvents[name]);
  547. attachedEvents[name] = null;
  548. }
  549. eventsObject[name] = nextEvent;
  550. }
  551. }
  552. function dispatchEvents(event, target, isClick, name, eventData) {
  553. var dom = target;
  554. while (!isNull(dom)) {
  555. // Html Nodes can be nested fe: span inside button in that scenario browser does not handle disabled attribute on parent,
  556. // because the event listener is on document.body
  557. // Don't process clicks on disabled elements
  558. if (isClick && dom.disabled) {
  559. return;
  560. }
  561. var eventsObject = dom.$EV;
  562. if (eventsObject) {
  563. var currentEvent = eventsObject[name];
  564. if (currentEvent) {
  565. // linkEvent object
  566. eventData.dom = dom;
  567. if (currentEvent.event) {
  568. currentEvent.event(currentEvent.data, event);
  569. }
  570. else {
  571. currentEvent(event);
  572. }
  573. if (event.cancelBubble) {
  574. return;
  575. }
  576. }
  577. }
  578. dom = dom.parentNode;
  579. }
  580. }
  581. function normalizeEventName(name) {
  582. return name.substr(2).toLowerCase();
  583. }
  584. function stopPropagation() {
  585. this.cancelBubble = true;
  586. this.stopImmediatePropagation();
  587. }
  588. function attachEventToDocument(name) {
  589. var docEvent = function (event) {
  590. var type = event.type;
  591. var isClick = type === 'click' || type === 'dblclick';
  592. if (isClick && event.button !== 0) {
  593. // Firefox incorrectly triggers click event for mid/right mouse buttons.
  594. // This bug has been active for 12 years.
  595. // https://bugzilla.mozilla.org/show_bug.cgi?id=184051
  596. event.preventDefault();
  597. event.stopPropagation();
  598. return false;
  599. }
  600. event.stopPropagation = stopPropagation;
  601. // Event data needs to be object to save reference to currentTarget getter
  602. var eventData = {
  603. dom: document
  604. };
  605. try {
  606. Object.defineProperty(event, 'currentTarget', {
  607. configurable: true,
  608. get: function get() {
  609. return eventData.dom;
  610. }
  611. });
  612. }
  613. catch (e) {
  614. /* safari7 and phantomJS will crash */
  615. }
  616. dispatchEvents(event, event.target, isClick, name, eventData);
  617. };
  618. document.addEventListener(normalizeEventName(name), docEvent);
  619. return docEvent;
  620. }
  621. function isSameInnerHTML(dom, innerHTML) {
  622. var tempdom = document.createElement('i');
  623. tempdom.innerHTML = innerHTML;
  624. return tempdom.innerHTML === dom.innerHTML;
  625. }
  626. function isSamePropsInnerHTML(dom, props) {
  627. return Boolean(props && props.dangerouslySetInnerHTML && props.dangerouslySetInnerHTML.__html && isSameInnerHTML(dom, props.dangerouslySetInnerHTML.__html));
  628. }
  629. function triggerEventListener(props, methodName, e) {
  630. if (props[methodName]) {
  631. var listener = props[methodName];
  632. if (listener.event) {
  633. listener.event(listener.data, e);
  634. }
  635. else {
  636. listener(e);
  637. }
  638. }
  639. else {
  640. var nativeListenerName = methodName.toLowerCase();
  641. if (props[nativeListenerName]) {
  642. props[nativeListenerName](e);
  643. }
  644. }
  645. }
  646. function createWrappedFunction(methodName, applyValue) {
  647. var fnMethod = function (e) {
  648. e.stopPropagation();
  649. var vNode = this.$V;
  650. // If vNode is gone by the time event fires, no-op
  651. if (!vNode) {
  652. return;
  653. }
  654. var props = vNode.props || EMPTY_OBJ;
  655. var dom = vNode.dom;
  656. if (isString(methodName)) {
  657. triggerEventListener(props, methodName, e);
  658. }
  659. else {
  660. for (var i = 0; i < methodName.length; i++) {
  661. triggerEventListener(props, methodName[i], e);
  662. }
  663. }
  664. if (isFunction(applyValue)) {
  665. var newVNode = this.$V;
  666. var newProps = newVNode.props || EMPTY_OBJ;
  667. applyValue(newProps, dom, false, newVNode);
  668. }
  669. };
  670. Object.defineProperty(fnMethod, 'wrapped', {
  671. configurable: false,
  672. enumerable: false,
  673. value: true,
  674. writable: false
  675. });
  676. return fnMethod;
  677. }
  678. function isCheckedType(type) {
  679. return type === 'checkbox' || type === 'radio';
  680. }
  681. var onTextInputChange = createWrappedFunction('onInput', applyValueInput);
  682. var wrappedOnChange = createWrappedFunction(['onClick', 'onChange'], applyValueInput);
  683. /* tslint:disable-next-line:no-empty */
  684. function emptywrapper(event) {
  685. event.stopPropagation();
  686. }
  687. emptywrapper.wrapped = true;
  688. function inputEvents(dom, nextPropsOrEmpty) {
  689. if (isCheckedType(nextPropsOrEmpty.type)) {
  690. dom.onchange = wrappedOnChange;
  691. dom.onclick = emptywrapper;
  692. }
  693. else {
  694. dom.oninput = onTextInputChange;
  695. }
  696. }
  697. function applyValueInput(nextPropsOrEmpty, dom) {
  698. var type = nextPropsOrEmpty.type;
  699. var value = nextPropsOrEmpty.value;
  700. var checked = nextPropsOrEmpty.checked;
  701. var multiple = nextPropsOrEmpty.multiple;
  702. var defaultValue = nextPropsOrEmpty.defaultValue;
  703. var hasValue = !isNullOrUndef(value);
  704. if (type && type !== dom.type) {
  705. dom.setAttribute('type', type);
  706. }
  707. if (!isNullOrUndef(multiple) && multiple !== dom.multiple) {
  708. dom.multiple = multiple;
  709. }
  710. if (!isNullOrUndef(defaultValue) && !hasValue) {
  711. dom.defaultValue = defaultValue + '';
  712. }
  713. if (isCheckedType(type)) {
  714. if (hasValue) {
  715. dom.value = value;
  716. }
  717. if (!isNullOrUndef(checked)) {
  718. dom.checked = checked;
  719. }
  720. }
  721. else {
  722. if (hasValue && dom.value !== value) {
  723. dom.defaultValue = value;
  724. dom.value = value;
  725. }
  726. else if (!isNullOrUndef(checked)) {
  727. dom.checked = checked;
  728. }
  729. }
  730. }
  731. function updateChildOptionGroup(vNode, value) {
  732. var type = vNode.type;
  733. if (type === 'optgroup') {
  734. var children = vNode.children;
  735. var childFlags = vNode.childFlags;
  736. if (childFlags & 12 /* MultipleChildren */) {
  737. for (var i = 0, len = children.length; i < len; i++) {
  738. updateChildOption(children[i], value);
  739. }
  740. }
  741. else if (childFlags === 2 /* HasVNodeChildren */) {
  742. updateChildOption(children, value);
  743. }
  744. }
  745. else {
  746. updateChildOption(vNode, value);
  747. }
  748. }
  749. function updateChildOption(vNode, value) {
  750. var props = vNode.props || EMPTY_OBJ;
  751. var dom = vNode.dom;
  752. // we do this as multiple may have changed
  753. dom.value = props.value;
  754. if ((isArray(value) && value.indexOf(props.value) !== -1) || props.value === value) {
  755. dom.selected = true;
  756. }
  757. else if (!isNullOrUndef(value) || !isNullOrUndef(props.selected)) {
  758. dom.selected = props.selected || false;
  759. }
  760. }
  761. var onSelectChange = createWrappedFunction('onChange', applyValueSelect);
  762. function selectEvents(dom) {
  763. dom.onchange = onSelectChange;
  764. }
  765. function applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode) {
  766. var multiplePropInBoolean = Boolean(nextPropsOrEmpty.multiple);
  767. if (!isNullOrUndef(nextPropsOrEmpty.multiple) && multiplePropInBoolean !== dom.multiple) {
  768. dom.multiple = multiplePropInBoolean;
  769. }
  770. var childFlags = vNode.childFlags;
  771. if ((childFlags & 1 /* HasInvalidChildren */) === 0) {
  772. var children = vNode.children;
  773. var value = nextPropsOrEmpty.value;
  774. if (mounting && isNullOrUndef(value)) {
  775. value = nextPropsOrEmpty.defaultValue;
  776. }
  777. if (childFlags & 12 /* MultipleChildren */) {
  778. for (var i = 0, len = children.length; i < len; i++) {
  779. updateChildOptionGroup(children[i], value);
  780. }
  781. }
  782. else if (childFlags === 2 /* HasVNodeChildren */) {
  783. updateChildOptionGroup(children, value);
  784. }
  785. }
  786. }
  787. var onTextareaInputChange = createWrappedFunction('onInput', applyValueTextArea);
  788. var wrappedOnChange$1 = createWrappedFunction('onChange');
  789. function textAreaEvents(dom, nextPropsOrEmpty) {
  790. dom.oninput = onTextareaInputChange;
  791. if (nextPropsOrEmpty.onChange) {
  792. dom.onchange = wrappedOnChange$1;
  793. }
  794. }
  795. function applyValueTextArea(nextPropsOrEmpty, dom, mounting) {
  796. var value = nextPropsOrEmpty.value;
  797. var domValue = dom.value;
  798. if (isNullOrUndef(value)) {
  799. if (mounting) {
  800. var defaultValue = nextPropsOrEmpty.defaultValue;
  801. if (!isNullOrUndef(defaultValue) && defaultValue !== domValue) {
  802. dom.defaultValue = defaultValue;
  803. dom.value = defaultValue;
  804. }
  805. }
  806. }
  807. else if (domValue !== value) {
  808. /* There is value so keep it controlled */
  809. dom.defaultValue = value;
  810. dom.value = value;
  811. }
  812. }
  813. /**
  814. * There is currently no support for switching same input between controlled and nonControlled
  815. * If that ever becomes a real issue, then re design controlled elements
  816. * Currently user must choose either controlled or non-controlled and stick with that
  817. */
  818. function processElement(flags, vNode, dom, nextPropsOrEmpty, mounting, isControlled) {
  819. if (flags & 64 /* InputElement */) {
  820. applyValueInput(nextPropsOrEmpty, dom);
  821. }
  822. else if (flags & 256 /* SelectElement */) {
  823. applyValueSelect(nextPropsOrEmpty, dom, mounting, vNode);
  824. }
  825. else if (flags & 128 /* TextareaElement */) {
  826. applyValueTextArea(nextPropsOrEmpty, dom, mounting);
  827. }
  828. if (isControlled) {
  829. dom.$V = vNode;
  830. }
  831. }
  832. function addFormElementEventHandlers(flags, dom, nextPropsOrEmpty) {
  833. if (flags & 64 /* InputElement */) {
  834. inputEvents(dom, nextPropsOrEmpty);
  835. }
  836. else if (flags & 256 /* SelectElement */) {
  837. selectEvents(dom);
  838. }
  839. else if (flags & 128 /* TextareaElement */) {
  840. textAreaEvents(dom, nextPropsOrEmpty);
  841. }
  842. }
  843. function isControlledFormElement(nextPropsOrEmpty) {
  844. return nextPropsOrEmpty.type && isCheckedType(nextPropsOrEmpty.type) ? !isNullOrUndef(nextPropsOrEmpty.checked) : !isNullOrUndef(nextPropsOrEmpty.value);
  845. }
  846. function remove(vNode, parentDom) {
  847. unmount(vNode);
  848. if (!isNull(parentDom)) {
  849. removeChild(parentDom, vNode.dom);
  850. // Let carbage collector free memory
  851. vNode.dom = null;
  852. }
  853. }
  854. function unmount(vNode) {
  855. var flags = vNode.flags;
  856. if (flags & 481 /* Element */) {
  857. var ref = vNode.ref;
  858. var props = vNode.props;
  859. if (isFunction(ref)) {
  860. ref(null);
  861. }
  862. var children = vNode.children;
  863. var childFlags = vNode.childFlags;
  864. if (childFlags & 12 /* MultipleChildren */) {
  865. unmountAllChildren(children);
  866. }
  867. else if (childFlags === 2 /* HasVNodeChildren */) {
  868. unmount(children);
  869. }
  870. if (!isNull(props)) {
  871. for (var name in props) {
  872. switch (name) {
  873. case 'onClick':
  874. case 'onDblClick':
  875. case 'onFocusIn':
  876. case 'onFocusOut':
  877. case 'onKeyDown':
  878. case 'onKeyPress':
  879. case 'onKeyUp':
  880. case 'onMouseDown':
  881. case 'onMouseMove':
  882. case 'onMouseUp':
  883. case 'onSubmit':
  884. case 'onTouchEnd':
  885. case 'onTouchMove':
  886. case 'onTouchStart':
  887. handleEvent(name, null, vNode.dom);
  888. break;
  889. default:
  890. break;
  891. }
  892. }
  893. }
  894. }
  895. else if (flags & 14 /* Component */) {
  896. var instance = vNode.children;
  897. var ref$1 = vNode.ref;
  898. if (flags & 4 /* ComponentClass */) {
  899. if (isFunction(options.beforeUnmount)) {
  900. options.beforeUnmount(vNode);
  901. }
  902. if (isFunction(instance.componentWillUnmount)) {
  903. instance.componentWillUnmount();
  904. }
  905. if (isFunction(ref$1)) {
  906. ref$1(null);
  907. }
  908. instance.$UN = true;
  909. unmount(instance.$LI);
  910. }
  911. else {
  912. if (!isNullOrUndef(ref$1) && isFunction(ref$1.onComponentWillUnmount)) {
  913. ref$1.onComponentWillUnmount(vNode.dom, vNode.props || EMPTY_OBJ);
  914. }
  915. unmount(instance);
  916. }
  917. }
  918. else if (flags & 1024 /* Portal */) {
  919. var children$1 = vNode.children;
  920. if (!isNull(children$1) && isObject(children$1)) {
  921. remove(children$1, vNode.type);
  922. }
  923. }
  924. }
  925. function unmountAllChildren(children) {
  926. for (var i = 0, len = children.length; i < len; i++) {
  927. unmount(children[i]);
  928. }
  929. }
  930. function removeAllChildren(dom, children) {
  931. unmountAllChildren(children);
  932. dom.textContent = '';
  933. }
  934. function createLinkEvent(linkEvent, nextValue) {
  935. return function (e) {
  936. linkEvent(nextValue.data, e);
  937. };
  938. }
  939. function patchEvent(name, lastValue, nextValue, dom) {
  940. var nameLowerCase = name.toLowerCase();
  941. if (!isFunction(nextValue) && !isNullOrUndef(nextValue)) {
  942. var linkEvent = nextValue.event;
  943. if (linkEvent && isFunction(linkEvent)) {
  944. dom[nameLowerCase] = createLinkEvent(linkEvent, nextValue);
  945. }
  946. else {
  947. // Development warning
  948. {
  949. throwError(("an event on a VNode \"" + name + "\". was not a function or a valid linkEvent."));
  950. }
  951. }
  952. }
  953. else {
  954. var domEvent = dom[nameLowerCase];
  955. // if the function is wrapped, that means it's been controlled by a wrapper
  956. if (!domEvent || !domEvent.wrapped) {
  957. dom[nameLowerCase] = nextValue;
  958. }
  959. }
  960. }
  961. function getNumberStyleValue(style, value) {
  962. switch (style) {
  963. case 'animationIterationCount':
  964. case 'borderImageOutset':
  965. case 'borderImageSlice':
  966. case 'borderImageWidth':
  967. case 'boxFlex':
  968. case 'boxFlexGroup':
  969. case 'boxOrdinalGroup':
  970. case 'columnCount':
  971. case 'fillOpacity':
  972. case 'flex':
  973. case 'flexGrow':
  974. case 'flexNegative':
  975. case 'flexOrder':
  976. case 'flexPositive':
  977. case 'flexShrink':
  978. case 'floodOpacity':
  979. case 'fontWeight':
  980. case 'gridColumn':
  981. case 'gridRow':
  982. case 'lineClamp':
  983. case 'lineHeight':
  984. case 'opacity':
  985. case 'order':
  986. case 'orphans':
  987. case 'stopOpacity':
  988. case 'strokeDasharray':
  989. case 'strokeDashoffset':
  990. case 'strokeMiterlimit':
  991. case 'strokeOpacity':
  992. case 'strokeWidth':
  993. case 'tabSize':
  994. case 'widows':
  995. case 'zIndex':
  996. case 'zoom':
  997. return value;
  998. default:
  999. return value + 'px';
  1000. }
  1001. }
  1002. // We are assuming here that we come from patchProp routine
  1003. // -nextAttrValue cannot be null or undefined
  1004. function patchStyle(lastAttrValue, nextAttrValue, dom) {
  1005. var domStyle = dom.style;
  1006. var style;
  1007. var value;
  1008. if (isString(nextAttrValue)) {
  1009. domStyle.cssText = nextAttrValue;
  1010. return;
  1011. }
  1012. if (!isNullOrUndef(lastAttrValue) && !isString(lastAttrValue)) {
  1013. for (style in nextAttrValue) {
  1014. // do not add a hasOwnProperty check here, it affects performance
  1015. value = nextAttrValue[style];
  1016. if (value !== lastAttrValue[style]) {
  1017. domStyle[style] = isNumber(value) ? getNumberStyleValue(style, value) : value;
  1018. }
  1019. }
  1020. for (style in lastAttrValue) {
  1021. if (isNullOrUndef(nextAttrValue[style])) {
  1022. domStyle[style] = '';
  1023. }
  1024. }
  1025. }
  1026. else {
  1027. for (style in nextAttrValue) {
  1028. value = nextAttrValue[style];
  1029. domStyle[style] = isNumber(value) ? getNumberStyleValue(style, value) : value;
  1030. }
  1031. }
  1032. }
  1033. function patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode) {
  1034. switch (prop) {
  1035. case 'onClick':
  1036. case 'onDblClick':
  1037. case 'onFocusIn':
  1038. case 'onFocusOut':
  1039. case 'onKeyDown':
  1040. case 'onKeyPress':
  1041. case 'onKeyUp':
  1042. case 'onMouseDown':
  1043. case 'onMouseMove':
  1044. case 'onMouseUp':
  1045. case 'onSubmit':
  1046. case 'onTouchEnd':
  1047. case 'onTouchMove':
  1048. case 'onTouchStart':
  1049. handleEvent(prop, nextValue, dom);
  1050. break;
  1051. case 'children':
  1052. case 'childrenType':
  1053. case 'className':
  1054. case 'defaultValue':
  1055. case 'key':
  1056. case 'multiple':
  1057. case 'ref':
  1058. return;
  1059. case 'allowfullscreen':
  1060. case 'autoFocus':
  1061. case 'autoplay':
  1062. case 'capture':
  1063. case 'checked':
  1064. case 'controls':
  1065. case 'default':
  1066. case 'disabled':
  1067. case 'hidden':
  1068. case 'indeterminate':
  1069. case 'loop':
  1070. case 'muted':
  1071. case 'novalidate':
  1072. case 'open':
  1073. case 'readOnly':
  1074. case 'required':
  1075. case 'reversed':
  1076. case 'scoped':
  1077. case 'seamless':
  1078. case 'selected':
  1079. prop = prop === 'autoFocus' ? prop.toLowerCase() : prop;
  1080. dom[prop] = !!nextValue;
  1081. break;
  1082. case 'defaultChecked':
  1083. case 'value':
  1084. case 'volume':
  1085. if (hasControlledValue && prop === 'value') {
  1086. return;
  1087. }
  1088. var value = isNullOrUndef(nextValue) ? '' : nextValue;
  1089. if (dom[prop] !== value) {
  1090. dom[prop] = value;
  1091. }
  1092. break;
  1093. case 'dangerouslySetInnerHTML':
  1094. var lastHtml = (lastValue && lastValue.__html) || '';
  1095. var nextHtml = (nextValue && nextValue.__html) || '';
  1096. if (lastHtml !== nextHtml) {
  1097. if (!isNullOrUndef(nextHtml) && !isSameInnerHTML(dom, nextHtml)) {
  1098. if (!isNull(lastVNode)) {
  1099. if (lastVNode.childFlags & 12 /* MultipleChildren */) {
  1100. unmountAllChildren(lastVNode.children);
  1101. }
  1102. else if (lastVNode.childFlags === 2 /* HasVNodeChildren */) {
  1103. unmount(lastVNode.children);
  1104. }
  1105. lastVNode.children = null;
  1106. lastVNode.childFlags = 1 /* HasInvalidChildren */;
  1107. }
  1108. dom.innerHTML = nextHtml;
  1109. }
  1110. }
  1111. break;
  1112. default:
  1113. if (prop[0] === 'o' && prop[1] === 'n') {
  1114. patchEvent(prop, lastValue, nextValue, dom);
  1115. }
  1116. else if (isNullOrUndef(nextValue)) {
  1117. dom.removeAttribute(prop);
  1118. }
  1119. else if (prop === 'style') {
  1120. patchStyle(lastValue, nextValue, dom);
  1121. }
  1122. else if (isSVG && namespaces[prop]) {
  1123. // We optimize for NS being boolean. Its 99.9% time false
  1124. // If we end up in this path we can read property again
  1125. dom.setAttributeNS(namespaces[prop], prop, nextValue);
  1126. }
  1127. else {
  1128. dom.setAttribute(prop, nextValue);
  1129. }
  1130. break;
  1131. }
  1132. }
  1133. function mountProps(vNode, flags, props, dom, isSVG) {
  1134. var hasControlledValue = false;
  1135. var isFormElement = (flags & 448 /* FormElement */) > 0;
  1136. if (isFormElement) {
  1137. hasControlledValue = isControlledFormElement(props);
  1138. if (hasControlledValue) {
  1139. addFormElementEventHandlers(flags, dom, props);
  1140. }
  1141. }
  1142. for (var prop in props) {
  1143. // do not add a hasOwnProperty check here, it affects performance
  1144. patchProp(prop, null, props[prop], dom, isSVG, hasControlledValue, null);
  1145. }
  1146. if (isFormElement) {
  1147. processElement(flags, vNode, dom, props, true, hasControlledValue);
  1148. }
  1149. }
  1150. function createClassComponentInstance(vNode, Component, props, context) {
  1151. var instance = new Component(props, context);
  1152. vNode.children = instance;
  1153. instance.$V = vNode;
  1154. instance.$BS = false;
  1155. instance.context = context;
  1156. if (instance.props === EMPTY_OBJ) {
  1157. instance.props = props;
  1158. }
  1159. instance.$UN = false;
  1160. if (isFunction(instance.componentWillMount)) {
  1161. instance.$BR = true;
  1162. instance.componentWillMount();
  1163. if (instance.$PSS) {
  1164. var state = instance.state;
  1165. var pending = instance.$PS;
  1166. if (isNull(state)) {
  1167. instance.state = pending;
  1168. }
  1169. else {
  1170. for (var key in pending) {
  1171. state[key] = pending[key];
  1172. }
  1173. }
  1174. instance.$PSS = false;
  1175. instance.$PS = null;
  1176. }
  1177. instance.$BR = false;
  1178. }
  1179. if (isFunction(options.beforeRender)) {
  1180. options.beforeRender(instance);
  1181. }
  1182. var input = handleComponentInput(instance.render(props, instance.state, context), vNode);
  1183. var childContext;
  1184. if (isFunction(instance.getChildContext)) {
  1185. childContext = instance.getChildContext();
  1186. }
  1187. if (isNullOrUndef(childContext)) {
  1188. instance.$CX = context;
  1189. }
  1190. else {
  1191. instance.$CX = combineFrom(context, childContext);
  1192. }
  1193. if (isFunction(options.afterRender)) {
  1194. options.afterRender(instance);
  1195. }
  1196. instance.$LI = input;
  1197. return instance;
  1198. }
  1199. function handleComponentInput(input, componentVNode) {
  1200. // Development validation
  1201. {
  1202. if (isArray(input)) {
  1203. throwError('a valid Inferno VNode (or null) must be returned from a component render. You may have returned an array or an invalid object.');
  1204. }
  1205. }
  1206. if (isInvalid(input)) {
  1207. input = createVoidVNode();
  1208. }
  1209. else if (isStringOrNumber(input)) {
  1210. input = createTextVNode(input, null);
  1211. }
  1212. else {
  1213. if (input.dom) {
  1214. input = directClone(input);
  1215. }
  1216. if (input.flags & 14 /* Component */) {
  1217. // if we have an input that is also a component, we run into a tricky situation
  1218. // where the root vNode needs to always have the correct DOM entry
  1219. // we can optimise this in the future, but this gets us out of a lot of issues
  1220. input.parentVNode = componentVNode;
  1221. }
  1222. }
  1223. return input;
  1224. }
  1225. function mount(vNode, parentDom, lifecycle, context, isSVG) {
  1226. var flags = vNode.flags;
  1227. if (flags & 481 /* Element */) {
  1228. return mountElement(vNode, parentDom, lifecycle, context, isSVG);
  1229. }
  1230. if (flags & 14 /* Component */) {
  1231. return mountComponent(vNode, parentDom, lifecycle, context, isSVG, (flags & 4 /* ComponentClass */) > 0);
  1232. }
  1233. if (flags & 512 /* Void */ || flags & 16 /* Text */) {
  1234. return mountText(vNode, parentDom);
  1235. }
  1236. if (flags & 1024 /* Portal */) {
  1237. mount(vNode.children, vNode.type, lifecycle, context, false);
  1238. return (vNode.dom = mountText(createVoidVNode(), parentDom));
  1239. }
  1240. // Development validation, in production we don't need to throw because it crashes anyway
  1241. {
  1242. if (typeof vNode === 'object') {
  1243. throwError(("mount() received an object that's not a valid VNode, you should stringify it first, fix createVNode flags or call normalizeChildren. Object: \"" + (JSON.stringify(vNode)) + "\"."));
  1244. }
  1245. else {
  1246. throwError(("mount() expects a valid VNode, instead it received an object with the type \"" + (typeof vNode) + "\"."));
  1247. }
  1248. }
  1249. }
  1250. function mountText(vNode, parentDom) {
  1251. var dom = (vNode.dom = document.createTextNode(vNode.children));
  1252. if (!isNull(parentDom)) {
  1253. appendChild(parentDom, dom);
  1254. }
  1255. return dom;
  1256. }
  1257. function mountElement(vNode, parentDom, lifecycle, context, isSVG) {
  1258. var flags = vNode.flags;
  1259. var children = vNode.children;
  1260. var props = vNode.props;
  1261. var className = vNode.className;
  1262. var ref = vNode.ref;
  1263. var childFlags = vNode.childFlags;
  1264. isSVG = isSVG || (flags & 32 /* SvgElement */) > 0;
  1265. var dom = documentCreateElement(vNode.type, isSVG);
  1266. vNode.dom = dom;
  1267. if (!isNullOrUndef(className) && className !== '') {
  1268. if (isSVG) {
  1269. dom.setAttribute('class', className);
  1270. }
  1271. else {
  1272. dom.className = className;
  1273. }
  1274. }
  1275. {
  1276. validateKeys(vNode);
  1277. }
  1278. if (!isNull(parentDom)) {
  1279. appendChild(parentDom, dom);
  1280. }
  1281. if ((childFlags & 1 /* HasInvalidChildren */) === 0) {
  1282. var childrenIsSVG = isSVG === true && vNode.type !== 'foreignObject';
  1283. if (childFlags === 2 /* HasVNodeChildren */) {
  1284. mount(children, dom, lifecycle, context, childrenIsSVG);
  1285. }
  1286. else if (childFlags & 12 /* MultipleChildren */) {
  1287. mountArrayChildren(children, dom, lifecycle, context, childrenIsSVG);
  1288. }
  1289. }
  1290. if (!isNull(props)) {
  1291. mountProps(vNode, flags, props, dom, isSVG);
  1292. }
  1293. {
  1294. if (isString(ref)) {
  1295. throwError('string "refs" are not supported in Inferno 1.0. Use callback "refs" instead.');
  1296. }
  1297. }
  1298. if (isFunction(ref)) {
  1299. mountRef(dom, ref, lifecycle);
  1300. }
  1301. return dom;
  1302. }
  1303. function mountArrayChildren(children, dom, lifecycle, context, isSVG) {
  1304. for (var i = 0, len = children.length; i < len; i++) {
  1305. var child = children[i];
  1306. if (!isNull(child.dom)) {
  1307. children[i] = child = directClone(child);
  1308. }
  1309. mount(child, dom, lifecycle, context, isSVG);
  1310. }
  1311. }
  1312. function mountComponent(vNode, parentDom, lifecycle, context, isSVG, isClass) {
  1313. var dom;
  1314. var type = vNode.type;
  1315. var props = vNode.props || EMPTY_OBJ;
  1316. var ref = vNode.ref;
  1317. if (isClass) {
  1318. var instance = createClassComponentInstance(vNode, type, props, context);
  1319. vNode.dom = dom = mount(instance.$LI, null, lifecycle, instance.$CX, isSVG);
  1320. mountClassComponentCallbacks(vNode, ref, instance, lifecycle);
  1321. instance.$UPD = false;
  1322. }
  1323. else {
  1324. var input = handleComponentInput(type(props, context), vNode);
  1325. vNode.children = input;
  1326. vNode.dom = dom = mount(input, null, lifecycle, context, isSVG);
  1327. mountFunctionalComponentCallbacks(props, ref, dom, lifecycle);
  1328. }
  1329. if (!isNull(parentDom)) {
  1330. appendChild(parentDom, dom);
  1331. }
  1332. return dom;
  1333. }
  1334. function createClassMountCallback(instance, hasAfterMount, afterMount, vNode, hasDidMount) {
  1335. return function () {
  1336. instance.$UPD = true;
  1337. if (hasAfterMount) {
  1338. afterMount(vNode);
  1339. }
  1340. if (hasDidMount) {
  1341. instance.componentDidMount();
  1342. }
  1343. instance.$UPD = false;
  1344. };
  1345. }
  1346. function mountClassComponentCallbacks(vNode, ref, instance, lifecycle) {
  1347. if (isFunction(ref)) {
  1348. ref(instance);
  1349. }
  1350. else {
  1351. {
  1352. if (isStringOrNumber(ref)) {
  1353. throwError('string "refs" are not supported in Inferno 1.0. Use callback "refs" instead.');
  1354. }
  1355. else if (!isNullOrUndef(ref) && isObject(ref) && vNode.flags & 4 /* ComponentClass */) {
  1356. throwError('functional component lifecycle events are not supported on ES2015 class components.');
  1357. }
  1358. }
  1359. }
  1360. var hasDidMount = isFunction(instance.componentDidMount);
  1361. var afterMount = options.afterMount;
  1362. var hasAfterMount = isFunction(afterMount);
  1363. if (hasDidMount || hasAfterMount) {
  1364. lifecycle.push(createClassMountCallback(instance, hasAfterMount, afterMount, vNode, hasDidMount));
  1365. }
  1366. }
  1367. // Create did mount callback lazily to avoid creating function context if not needed
  1368. function createOnMountCallback(ref, dom, props) {
  1369. return function () { return ref.onComponentDidMount(dom, props); };
  1370. }
  1371. function mountFunctionalComponentCallbacks(props, ref, dom, lifecycle) {
  1372. if (!isNullOrUndef(ref)) {
  1373. if (isFunction(ref.onComponentWillMount)) {
  1374. ref.onComponentWillMount(props);
  1375. }
  1376. if (isFunction(ref.onComponentDidMount)) {
  1377. lifecycle.push(createOnMountCallback(ref, dom, props));
  1378. }
  1379. }
  1380. }
  1381. function mountRef(dom, value, lifecycle) {
  1382. lifecycle.push(function () { return value(dom); });
  1383. }
  1384. function hydrateComponent(vNode, dom, lifecycle, context, isSVG, isClass) {
  1385. var type = vNode.type;
  1386. var ref = vNode.ref;
  1387. var props = vNode.props || EMPTY_OBJ;
  1388. if (isClass) {
  1389. var instance = createClassComponentInstance(vNode, type, props, context);
  1390. var input = instance.$LI;
  1391. hydrateVNode(input, dom, lifecycle, instance.$CX, isSVG);
  1392. vNode.dom = input.dom;
  1393. mountClassComponentCallbacks(vNode, ref, instance, lifecycle);
  1394. instance.$UPD = false; // Mount finished allow going sync
  1395. }
  1396. else {
  1397. var input$1 = handleComponentInput(type(props, context), vNode);
  1398. hydrateVNode(input$1, dom, lifecycle, context, isSVG);
  1399. vNode.children = input$1;
  1400. vNode.dom = input$1.dom;
  1401. mountFunctionalComponentCallbacks(props, ref, dom, lifecycle);
  1402. }
  1403. }
  1404. function hydrateElement(vNode, dom, lifecycle, context, isSVG) {
  1405. var children = vNode.children;
  1406. var props = vNode.props;
  1407. var className = vNode.className;
  1408. var flags = vNode.flags;
  1409. var ref = vNode.ref;
  1410. isSVG = isSVG || (flags & 32 /* SvgElement */) > 0;
  1411. if (dom.nodeType !== 1 || dom.tagName.toLowerCase() !== vNode.type) {
  1412. {
  1413. warning("Inferno hydration: Server-side markup doesn't match client-side markup or Initial render target is not empty");
  1414. }
  1415. var newDom = mountElement(vNode, null, lifecycle, context, isSVG);
  1416. vNode.dom = newDom;
  1417. replaceChild(dom.parentNode, newDom, dom);
  1418. }
  1419. else {
  1420. vNode.dom = dom;
  1421. var childNode = dom.firstChild;
  1422. var childFlags = vNode.childFlags;
  1423. if ((childFlags & 1 /* HasInvalidChildren */) === 0) {
  1424. var nextSibling = null;
  1425. while (childNode) {
  1426. nextSibling = childNode.nextSibling;
  1427. if (childNode.nodeType === 8) {
  1428. if (childNode.data === '!') {
  1429. dom.replaceChild(document.createTextNode(''), childNode);
  1430. }
  1431. else {
  1432. dom.removeChild(childNode);
  1433. }
  1434. }
  1435. childNode = nextSibling;
  1436. }
  1437. childNode = dom.firstChild;
  1438. if (childFlags === 2 /* HasVNodeChildren */) {
  1439. if (isNull(childNode)) {
  1440. mount(children, dom, lifecycle, context, isSVG);
  1441. }
  1442. else {
  1443. nextSibling = childNode.nextSibling;
  1444. hydrateVNode(children, childNode, lifecycle, context, isSVG);
  1445. childNode = nextSibling;
  1446. }
  1447. }
  1448. else if (childFlags & 12 /* MultipleChildren */) {
  1449. for (var i = 0, len = children.length; i < len; i++) {
  1450. var child = children[i];
  1451. if (isNull(childNode)) {
  1452. mount(child, dom, lifecycle, context, isSVG);
  1453. }
  1454. else {
  1455. nextSibling = childNode.nextSibling;
  1456. hydrateVNode(child, childNode, lifecycle, context, isSVG);
  1457. childNode = nextSibling;
  1458. }
  1459. }
  1460. }
  1461. // clear any other DOM nodes, there should be only a single entry for the root
  1462. while (childNode) {
  1463. nextSibling = childNode.nextSibling;
  1464. dom.removeChild(childNode);
  1465. childNode = nextSibling;
  1466. }
  1467. }
  1468. else if (!isNull(dom.firstChild) && !isSamePropsInnerHTML(dom, props)) {
  1469. dom.textContent = ''; // dom has content, but VNode has no children remove everything from DOM
  1470. if (flags & 448 /* FormElement */) {
  1471. // If element is form element, we need to clear defaultValue also
  1472. dom.defaultValue = '';
  1473. }
  1474. }
  1475. if (!isNull(props)) {
  1476. mountProps(vNode, flags, props, dom, isSVG);
  1477. }
  1478. if (isNullOrUndef(className)) {
  1479. if (dom.className !== '') {
  1480. dom.removeAttribute('class');
  1481. }
  1482. }
  1483. else if (isSVG) {
  1484. dom.setAttribute('class', className);
  1485. }
  1486. else {
  1487. dom.className = className;
  1488. }
  1489. if (isFunction(ref)) {
  1490. mountRef(dom, ref, lifecycle);
  1491. }
  1492. else {
  1493. {
  1494. if (isString(ref)) {
  1495. throwError('string "refs" are not supported in Inferno 1.0. Use callback "refs" instead.');
  1496. }
  1497. }
  1498. }
  1499. }
  1500. }
  1501. function hydrateText(vNode, dom) {
  1502. if (dom.nodeType !== 3) {
  1503. var newDom = mountText(vNode, null);
  1504. vNode.dom = newDom;
  1505. replaceChild(dom.parentNode, newDom, dom);
  1506. }
  1507. else {
  1508. var text = vNode.children;
  1509. if (dom.nodeValue !== text) {
  1510. dom.nodeValue = text;
  1511. }
  1512. vNode.dom = dom;
  1513. }
  1514. }
  1515. function hydrateVNode(vNode, dom, lifecycle, context, isSVG) {
  1516. var flags = vNode.flags;
  1517. if (flags & 14 /* Component */) {
  1518. hydrateComponent(vNode, dom, lifecycle, context, isSVG, (flags & 4 /* ComponentClass */) > 0);
  1519. }
  1520. else if (flags & 481 /* Element */) {
  1521. hydrateElement(vNode, dom, lifecycle, context, isSVG);
  1522. }
  1523. else if (flags & 16 /* Text */) {
  1524. hydrateText(vNode, dom);
  1525. }
  1526. else if (flags & 512 /* Void */) {
  1527. vNode.dom = dom;
  1528. }
  1529. else {
  1530. {
  1531. throwError(("hydrate() expects a valid VNode, instead it received an object with the type \"" + (typeof vNode) + "\"."));
  1532. }
  1533. throwError();
  1534. }
  1535. }
  1536. function hydrate(input, parentDom, callback) {
  1537. var dom = parentDom.firstChild;
  1538. if (!isNull(dom)) {
  1539. if (!isInvalid(input)) {
  1540. hydrateVNode(input, dom, LIFECYCLE, EMPTY_OBJ, false);
  1541. }
  1542. dom = parentDom.firstChild;
  1543. // clear any other DOM nodes, there should be only a single entry for the root
  1544. while ((dom = dom.nextSibling)) {
  1545. parentDom.removeChild(dom);
  1546. }
  1547. }
  1548. if (LIFECYCLE.length > 0) {
  1549. callAll(LIFECYCLE);
  1550. }
  1551. if (!parentDom.$V) {
  1552. options.roots.push(parentDom);
  1553. }
  1554. parentDom.$V = input;
  1555. if (isFunction(callback)) {
  1556. callback();
  1557. }
  1558. }
  1559. function replaceWithNewNode(lastNode, nextNode, parentDom, lifecycle, context, isSVG) {
  1560. unmount(lastNode);
  1561. replaceChild(parentDom, mount(nextNode, null, lifecycle, context, isSVG), lastNode.dom);
  1562. }
  1563. function patch(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG) {
  1564. if (lastVNode !== nextVNode) {
  1565. var nextFlags = nextVNode.flags;
  1566. if (lastVNode.flags !== nextFlags || nextFlags & 2048 /* ReCreate */) {
  1567. replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG);
  1568. }
  1569. else if (nextFlags & 481 /* Element */) {
  1570. patchElement(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG);
  1571. }
  1572. else if (nextFlags & 14 /* Component */) {
  1573. patchComponent(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, (nextFlags & 4 /* ComponentClass */) > 0);
  1574. }
  1575. else if (nextFlags & 16 /* Text */) {
  1576. patchText(lastVNode, nextVNode, parentDom);
  1577. }
  1578. else if (nextFlags & 512 /* Void */) {
  1579. nextVNode.dom = lastVNode.dom;
  1580. }
  1581. else {
  1582. // Portal
  1583. patchPortal(lastVNode, nextVNode, lifecycle, context);
  1584. }
  1585. }
  1586. }
  1587. function patchPortal(lastVNode, nextVNode, lifecycle, context) {
  1588. var lastContainer = lastVNode.type;
  1589. var nextContainer = nextVNode.type;
  1590. var nextChildren = nextVNode.children;
  1591. patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastVNode.children, nextChildren, lastContainer, lifecycle, context, false);
  1592. nextVNode.dom = lastVNode.dom;
  1593. if (lastContainer !== nextContainer && !isInvalid(nextChildren)) {
  1594. var node = nextChildren.dom;
  1595. lastContainer.removeChild(node);
  1596. nextContainer.appendChild(node);
  1597. }
  1598. }
  1599. function patchElement(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG) {
  1600. var nextTag = nextVNode.type;
  1601. if (lastVNode.type !== nextTag) {
  1602. replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG);
  1603. }
  1604. else {
  1605. var dom = lastVNode.dom;
  1606. var nextFlags = nextVNode.flags;
  1607. var lastProps = lastVNode.props;
  1608. var nextProps = nextVNode.props;
  1609. var isFormElement = false;
  1610. var hasControlledValue = false;
  1611. var nextPropsOrEmpty;
  1612. nextVNode.dom = dom;
  1613. isSVG = isSVG || (nextFlags & 32 /* SvgElement */) > 0;
  1614. // inlined patchProps -- starts --
  1615. if (lastProps !== nextProps) {
  1616. var lastPropsOrEmpty = lastProps || EMPTY_OBJ;
  1617. nextPropsOrEmpty = nextProps || EMPTY_OBJ;
  1618. if (nextPropsOrEmpty !== EMPTY_OBJ) {
  1619. isFormElement = (nextFlags & 448 /* FormElement */) > 0;
  1620. if (isFormElement) {
  1621. hasControlledValue = isControlledFormElement(nextPropsOrEmpty);
  1622. }
  1623. for (var prop in nextPropsOrEmpty) {
  1624. var lastValue = lastPropsOrEmpty[prop];
  1625. var nextValue = nextPropsOrEmpty[prop];
  1626. if (lastValue !== nextValue) {
  1627. patchProp(prop, lastValue, nextValue, dom, isSVG, hasControlledValue, lastVNode);
  1628. }
  1629. }
  1630. }
  1631. if (lastPropsOrEmpty !== EMPTY_OBJ) {
  1632. for (var prop$1 in lastPropsOrEmpty) {
  1633. // do not add a hasOwnProperty check here, it affects performance
  1634. if (!nextPropsOrEmpty.hasOwnProperty(prop$1) && !isNullOrUndef(lastPropsOrEmpty[prop$1])) {
  1635. patchProp(prop$1, lastPropsOrEmpty[prop$1], null, dom, isSVG, hasControlledValue, lastVNode);
  1636. }
  1637. }
  1638. }
  1639. }
  1640. var lastChildren = lastVNode.children;
  1641. var nextChildren = nextVNode.children;
  1642. var nextRef = nextVNode.ref;
  1643. var lastClassName = lastVNode.className;
  1644. var nextClassName = nextVNode.className;
  1645. if (lastChildren !== nextChildren) {
  1646. {
  1647. validateKeys(nextVNode);
  1648. }
  1649. patchChildren(lastVNode.childFlags, nextVNode.childFlags, lastChildren, nextChildren, dom, lifecycle, context, isSVG && nextTag !== 'foreignObject');
  1650. }
  1651. if (isFormElement) {
  1652. processElement(nextFlags, nextVNode, dom, nextPropsOrEmpty, false, hasControlledValue);
  1653. }
  1654. // inlined patchProps -- ends --
  1655. if (lastClassName !== nextClassName) {
  1656. if (isNullOrUndef(nextClassName)) {
  1657. dom.removeAttribute('class');
  1658. }
  1659. else if (isSVG) {
  1660. dom.setAttribute('class', nextClassName);
  1661. }
  1662. else {
  1663. dom.className = nextClassName;
  1664. }
  1665. }
  1666. if (isFunction(nextRef) && lastVNode.ref !== nextRef) {
  1667. mountRef(dom, nextRef, lifecycle);
  1668. }
  1669. else {
  1670. {
  1671. if (isString(nextRef)) {
  1672. throwError('string "refs" are not supported in Inferno 1.0. Use callback "refs" instead.');
  1673. }
  1674. }
  1675. }
  1676. }
  1677. }
  1678. function patchChildren(lastChildFlags, nextChildFlags, lastChildren, nextChildren, parentDOM, lifecycle, context, isSVG) {
  1679. switch (lastChildFlags) {
  1680. case 2 /* HasVNodeChildren */:
  1681. switch (nextChildFlags) {
  1682. case 2 /* HasVNodeChildren */:
  1683. patch(lastChildren, nextChildren, parentDOM, lifecycle, context, isSVG);
  1684. break;
  1685. case 1 /* HasInvalidChildren */:
  1686. remove(lastChildren, parentDOM);
  1687. break;
  1688. default:
  1689. remove(lastChildren, parentDOM);
  1690. mountArrayChildren(nextChildren, parentDOM, lifecycle, context, isSVG);
  1691. break;
  1692. }
  1693. break;
  1694. case 1 /* HasInvalidChildren */:
  1695. switch (nextChildFlags) {
  1696. case 2 /* HasVNodeChildren */:
  1697. mount(nextChildren, parentDOM, lifecycle, context, isSVG);
  1698. break;
  1699. case 1 /* HasInvalidChildren */:
  1700. break;
  1701. default:
  1702. mountArrayChildren(nextChildren, parentDOM, lifecycle, context, isSVG);
  1703. break;
  1704. }
  1705. break;
  1706. default:
  1707. if (nextChildFlags & 12 /* MultipleChildren */) {
  1708. var lastLength = lastChildren.length;
  1709. var nextLength = nextChildren.length;
  1710. // Fast path's for both algorithms
  1711. if (lastLength === 0) {
  1712. if (nextLength > 0) {
  1713. mountArrayChildren(nextChildren, parentDOM, lifecycle, context, isSVG);
  1714. }
  1715. }
  1716. else if (nextLength === 0) {
  1717. removeAllChildren(parentDOM, lastChildren);
  1718. }
  1719. else if (nextChildFlags === 8 /* HasKeyedChildren */ && lastChildFlags === 8 /* HasKeyedChildren */) {
  1720. patchKeyedChildren(lastChildren, nextChildren, parentDOM, lifecycle, context, isSVG, lastLength, nextLength);
  1721. }
  1722. else {
  1723. patchNonKeyedChildren(lastChildren, nextChildren, parentDOM, lifecycle, context, isSVG, lastLength, nextLength);
  1724. }
  1725. }
  1726. else if (nextChildFlags === 1 /* HasInvalidChildren */) {
  1727. removeAllChildren(parentDOM, lastChildren);
  1728. }
  1729. else {
  1730. removeAllChildren(parentDOM, lastChildren);
  1731. mount(nextChildren, parentDOM, lifecycle, context, isSVG);
  1732. }
  1733. break;
  1734. }
  1735. }
  1736. function updateClassComponent(instance, nextState, nextVNode, nextProps, parentDom, lifecycle, context, isSVG, force, fromSetState) {
  1737. var lastState = instance.state;
  1738. var lastProps = instance.props;
  1739. nextVNode.children = instance;
  1740. var lastInput = instance.$LI;
  1741. var renderOutput;
  1742. if (instance.$UN) {
  1743. {
  1744. throwError('Inferno Error: Can only update a mounted or mounting component. This usually means you called setState() or forceUpdate() on an unmounted component. This is a no-op.');
  1745. }
  1746. return;
  1747. }
  1748. if (lastProps !== nextProps || nextProps === EMPTY_OBJ) {
  1749. if (!fromSetState && isFunction(instance.componentWillReceiveProps)) {
  1750. instance.$BR = true;
  1751. instance.componentWillReceiveProps(nextProps, context);
  1752. // If instance component was removed during its own update do nothing...
  1753. if (instance.$UN) {
  1754. return;
  1755. }
  1756. instance.$BR = false;
  1757. }
  1758. if (instance.$PSS) {
  1759. nextState = combineFrom(nextState, instance.$PS);
  1760. instance.$PSS = false;
  1761. instance.$PS = null;
  1762. }
  1763. }
  1764. /* Update if scu is not defined, or it returns truthy value or force */
  1765. var hasSCU = isFunction(instance.shouldComponentUpdate);
  1766. if (force || !hasSCU || (hasSCU && instance.shouldComponentUpdate(nextProps, nextState, context))) {
  1767. if (isFunction(instance.componentWillUpdate)) {
  1768. instance.$BS = true;
  1769. instance.componentWillUpdate(nextProps, nextState, context);
  1770. instance.$BS = false;
  1771. }
  1772. instance.props = nextProps;
  1773. instance.state = nextState;
  1774. instance.context = context;
  1775. if (isFunction(options.beforeRender)) {
  1776. options.beforeRender(instance);
  1777. }
  1778. renderOutput = instance.render(nextProps, nextState, context);
  1779. if (isFunction(options.afterRender)) {
  1780. options.afterRender(instance);
  1781. }
  1782. var didUpdate = renderOutput !== NO_OP;
  1783. var childContext;
  1784. if (isFunction(instance.getChildContext)) {
  1785. childContext = instance.getChildContext();
  1786. }
  1787. if (isNullOrUndef(childContext)) {
  1788. childContext = context;
  1789. }
  1790. else {
  1791. childContext = combineFrom(context, childContext);
  1792. }
  1793. instance.$CX = childContext;
  1794. if (didUpdate) {
  1795. var nextInput = (instance.$LI = handleComponentInput(renderOutput, nextVNode));
  1796. patch(lastInput, nextInput, parentDom, lifecycle, childContext, isSVG);
  1797. if (isFunction(instance.componentDidUpdate)) {
  1798. instance.componentDidUpdate(lastProps, lastState);
  1799. }
  1800. if (isFunction(options.afterUpdate)) {
  1801. options.afterUpdate(nextVNode);
  1802. }
  1803. }
  1804. }
  1805. else {
  1806. instance.props = nextProps;
  1807. instance.state = nextState;
  1808. instance.context = context;
  1809. }
  1810. nextVNode.dom = instance.$LI.dom;
  1811. }
  1812. function patchComponent(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG, isClass) {
  1813. var nextType = nextVNode.type;
  1814. var lastKey = lastVNode.key;
  1815. var nextKey = nextVNode.key;
  1816. if (lastVNode.type !== nextType || lastKey !== nextKey) {
  1817. replaceWithNewNode(lastVNode, nextVNode, parentDom, lifecycle, context, isSVG);
  1818. }
  1819. else {
  1820. var nextProps = nextVNode.props || EMPTY_OBJ;
  1821. if (isClass) {
  1822. var instance = lastVNode.children;
  1823. instance.$UPD = true;
  1824. updateClassComponent(instance, instance.state, nextVNode, nextProps, parentDom, lifecycle, context, isSVG, false, false);
  1825. instance.$V = nextVNode;
  1826. instance.$UPD = false;
  1827. }
  1828. else {
  1829. var shouldUpdate = true;
  1830. var lastProps = lastVNode.props;
  1831. var nextHooks = nextVNode.ref;
  1832. var nextHooksDefined = !isNullOrUndef(nextHooks);
  1833. var lastInput = lastVNode.children;
  1834. nextVNode.dom = lastVNode.dom;
  1835. nextVNode.children = lastInput;
  1836. if (nextHooksDefined && isFunction(nextHooks.onComponentShouldUpdate)) {
  1837. shouldUpdate = nextHooks.onComponentShouldUpdate(lastProps, nextProps);
  1838. }
  1839. if (shouldUpdate !== false) {
  1840. if (nextHooksDefined && isFunction(nextHooks.onComponentWillUpdate)) {
  1841. nextHooks.onComponentWillUpdate(lastProps, nextProps);
  1842. }
  1843. var nextInput = nextType(nextProps, context);
  1844. if (nextInput !== NO_OP) {
  1845. nextInput = handleComponentInput(nextInput, nextVNode);
  1846. patch(lastInput, nextInput, parentDom, lifecycle, context, isSVG);
  1847. nextVNode.children = nextInput;
  1848. nextVNode.dom = nextInput.dom;
  1849. if (nextHooksDefined && isFunction(nextHooks.onComponentDidUpdate)) {
  1850. nextHooks.onComponentDidUpdate(lastProps, nextProps);
  1851. }
  1852. }
  1853. }
  1854. else if (lastInput.flags & 14 /* Component */) {
  1855. lastInput.parentVNode = nextVNode;
  1856. }
  1857. }
  1858. }
  1859. }
  1860. function patchText(lastVNode, nextVNode, parentDom) {
  1861. var nextText = nextVNode.children;
  1862. var textNode = parentDom.firstChild;
  1863. var dom;
  1864. // Guard against external change on DOM node.
  1865. if (isNull(textNode)) {
  1866. parentDom.textContent = nextText;
  1867. dom = parentDom.firstChild;
  1868. }
  1869. else {
  1870. dom = lastVNode.dom;
  1871. if (nextText !== lastVNode.children) {
  1872. dom.nodeValue = nextText;
  1873. }
  1874. }
  1875. nextVNode.dom = dom;
  1876. }
  1877. function patchNonKeyedChildren(lastChildren, nextChildren, dom, lifecycle, context, isSVG, lastChildrenLength, nextChildrenLength) {
  1878. var commonLength = lastChildrenLength > nextChildrenLength ? nextChildrenLength : lastChildrenLength;
  1879. var i = 0;
  1880. for (; i < commonLength; i++) {
  1881. var nextChild = nextChildren[i];
  1882. if (nextChild.dom) {
  1883. nextChild = nextChildren[i] = directClone(nextChild);
  1884. }
  1885. patch(lastChildren[i], nextChild, dom, lifecycle, context, isSVG);
  1886. }
  1887. if (lastChildrenLength < nextChildrenLength) {
  1888. for (i = commonLength; i < nextChildrenLength; i++) {
  1889. var nextChild$1 = nextChildren[i];
  1890. if (nextChild$1.dom) {
  1891. nextChild$1 = nextChildren[i] = directClone(nextChild$1);
  1892. }
  1893. mount(nextChild$1, dom, lifecycle, context, isSVG);
  1894. }
  1895. }
  1896. else if (lastChildrenLength > nextChildrenLength) {
  1897. for (i = commonLength; i < lastChildrenLength; i++) {
  1898. remove(lastChildren[i], dom);
  1899. }
  1900. }
  1901. }
  1902. function patchKeyedChildren(a, b, dom, lifecycle, context, isSVG, aLength, bLength) {
  1903. var aEnd = aLength - 1;
  1904. var bEnd = bLength - 1;
  1905. var aStart = 0;
  1906. var bStart = 0;
  1907. var i;
  1908. var j;
  1909. var aNode;
  1910. var bNode;
  1911. var nextNode;
  1912. var nextPos;
  1913. var node;
  1914. var aStartNode = a[aStart];
  1915. var bStartNode = b[bStart];
  1916. var aEndNode = a[aEnd];
  1917. var bEndNode = b[bEnd];
  1918. if (bStartNode.dom) {
  1919. b[bStart] = bStartNode = directClone(bStartNode);
  1920. }
  1921. if (bEndNode.dom) {
  1922. b[bEnd] = bEndNode = directClone(bEndNode);
  1923. }
  1924. // Step 1
  1925. // tslint:disable-next-line
  1926. outer: {
  1927. // Sync nodes with the same key at the beginning.
  1928. while (aStartNode.key === bStartNode.key) {
  1929. patch(aStartNode, bStartNode, dom, lifecycle, context, isSVG);
  1930. aStart++;
  1931. bStart++;
  1932. if (aStart > aEnd || bStart > bEnd) {
  1933. break outer;
  1934. }
  1935. aStartNode = a[aStart];
  1936. bStartNode = b[bStart];
  1937. if (bStartNode.dom) {
  1938. b[bStart] = bStartNode = directClone(bStartNode);
  1939. }
  1940. }
  1941. // Sync nodes with the same key at the end.
  1942. while (aEndNode.key === bEndNode.key) {
  1943. patch(aEndNode, bEndNode, dom, lifecycle, context, isSVG);
  1944. aEnd--;
  1945. bEnd--;
  1946. if (aStart > aEnd || bStart > bEnd) {
  1947. break outer;
  1948. }
  1949. aEndNode = a[aEnd];
  1950. bEndNode = b[bEnd];
  1951. if (bEndNode.dom) {
  1952. b[bEnd] = bEndNode = directClone(bEndNode);
  1953. }
  1954. }
  1955. }
  1956. if (aStart > aEnd) {
  1957. if (bStart <= bEnd) {
  1958. nextPos = bEnd + 1;
  1959. nextNode = nextPos < bLength ? b[nextPos].dom : null;
  1960. while (bStart <= bEnd) {
  1961. node = b[bStart];
  1962. if (node.dom) {
  1963. b[bStart] = node = directClone(node);
  1964. }
  1965. bStart++;
  1966. insertOrAppend(dom, mount(node, null, lifecycle, context, isSVG), nextNode);
  1967. }
  1968. }
  1969. }
  1970. else if (bStart > bEnd) {
  1971. while (aStart <= aEnd) {
  1972. remove(a[aStart++], dom);
  1973. }
  1974. }
  1975. else {
  1976. var aLeft = aEnd - aStart + 1;
  1977. var bLeft = bEnd - bStart + 1;
  1978. var sources = new Array(bLeft);
  1979. for (i = 0; i < bLeft; i++) {
  1980. sources[i] = -1;
  1981. }
  1982. var moved = false;
  1983. var pos = 0;
  1984. var patched = 0;
  1985. // When sizes are small, just loop them through
  1986. if (bLeft <= 4 || aLeft * bLeft <= 16) {
  1987. for (i = aStart; i <= aEnd; i++) {
  1988. aNode = a[i];
  1989. if (patched < bLeft) {
  1990. for (j = bStart; j <= bEnd; j++) {
  1991. bNode = b[j];
  1992. if (aNode.key === bNode.key) {
  1993. sources[j - bStart] = i;
  1994. if (pos > j) {
  1995. moved = true;
  1996. }
  1997. else {
  1998. pos = j;
  1999. }
  2000. if (bNode.dom) {
  2001. b[j] = bNode = directClone(bNode);
  2002. }
  2003. patch(aNode, bNode, dom, lifecycle, context, isSVG);
  2004. patched++;
  2005. a[i] = null;
  2006. break;
  2007. }
  2008. }
  2009. }
  2010. }
  2011. }
  2012. else {
  2013. var keyIndex = {};
  2014. // Map keys by their index in array
  2015. for (i = bStart; i <= bEnd; i++) {
  2016. keyIndex[b[i].key] = i;
  2017. }
  2018. // Try to patch same keys
  2019. for (i = aStart; i <= aEnd; i++) {
  2020. aNode = a[i];
  2021. if (patched < bLeft) {
  2022. j = keyIndex[aNode.key];
  2023. if (isDefined(j)) {
  2024. bNode = b[j];
  2025. sources[j - bStart] = i;
  2026. if (pos > j) {
  2027. moved = true;
  2028. }
  2029. else {
  2030. pos = j;
  2031. }
  2032. if (bNode.dom) {
  2033. b[j] = bNode = directClone(bNode);
  2034. }
  2035. patch(aNode, bNode, dom, lifecycle, context, isSVG);
  2036. patched++;
  2037. a[i] = null;
  2038. }
  2039. }
  2040. }
  2041. }
  2042. // fast-path: if nothing patched remove all old and add all new
  2043. if (aLeft === aLength && patched === 0) {
  2044. removeAllChildren(dom, a);
  2045. mountArrayChildren(b, dom, lifecycle, context, isSVG);
  2046. }
  2047. else {
  2048. i = aLeft - patched;
  2049. while (i > 0) {
  2050. aNode = a[aStart++];
  2051. if (!isNull(aNode)) {
  2052. remove(aNode, dom);
  2053. i--;
  2054. }
  2055. }
  2056. if (moved) {
  2057. var seq = lis_algorithm(sources);
  2058. j = seq.length - 1;
  2059. for (i = bLeft - 1; i >= 0; i--) {
  2060. if (sources[i] === -1) {
  2061. pos = i + bStart;
  2062. node = b[pos];
  2063. if (node.dom) {
  2064. b[pos] = node = directClone(node);
  2065. }
  2066. nextPos = pos + 1;
  2067. insertOrAppend(dom, mount(node, null, lifecycle, context, isSVG), nextPos < bLength ? b[nextPos].dom : null);
  2068. }
  2069. else if (j < 0 || i !== seq[j]) {
  2070. pos = i + bStart;
  2071. node = b[pos];
  2072. nextPos = pos + 1;
  2073. insertOrAppend(dom, node.dom, nextPos < bLength ? b[nextPos].dom : null);
  2074. }
  2075. else {
  2076. j--;
  2077. }
  2078. }
  2079. }
  2080. else if (patched !== bLeft) {
  2081. // when patched count doesn't match b length we need to insert those new ones
  2082. // loop backwards so we can use insertBefore
  2083. for (i = bLeft - 1; i >= 0; i--) {
  2084. if (sources[i] === -1) {
  2085. pos = i + bStart;
  2086. node = b[pos];
  2087. if (node.dom) {
  2088. b[pos] = node = directClone(node);
  2089. }
  2090. nextPos = pos + 1;
  2091. insertOrAppend(dom, mount(node, null, lifecycle, context, isSVG), nextPos < bLength ? b[nextPos].dom : null);
  2092. }
  2093. }
  2094. }
  2095. }
  2096. }
  2097. }
  2098. // // https://en.wikipedia.org/wiki/Longest_increasing_subsequence
  2099. function lis_algorithm(arr) {
  2100. var p = arr.slice();
  2101. var result = [0];
  2102. var i;
  2103. var j;
  2104. var u;
  2105. var v;
  2106. var c;
  2107. var len = arr.length;
  2108. for (i = 0; i < len; i++) {
  2109. var arrI = arr[i];
  2110. if (arrI !== -1) {
  2111. j = result[result.length - 1];
  2112. if (arr[j] < arrI) {
  2113. p[i] = j;
  2114. result.push(i);
  2115. continue;
  2116. }
  2117. u = 0;
  2118. v = result.length - 1;
  2119. while (u < v) {
  2120. c = ((u + v) / 2) | 0;
  2121. if (arr[result[c]] < arrI) {
  2122. u = c + 1;
  2123. }
  2124. else {
  2125. v = c;
  2126. }
  2127. }
  2128. if (arrI < arr[result[u]]) {
  2129. if (u > 0) {
  2130. p[i] = result[u - 1];
  2131. }
  2132. result[u] = i;
  2133. }
  2134. }
  2135. }
  2136. u = result.length;
  2137. v = result[u - 1];
  2138. while (u-- > 0) {
  2139. result[u] = v;
  2140. v = p[v];
  2141. }
  2142. return result;
  2143. }
  2144. var roots = options.roots;
  2145. {
  2146. if (isBrowser && document.body === null) {
  2147. warning('Inferno warning: you cannot initialize inferno without "document.body". Wait on "DOMContentLoaded" event, add script to bottom of body, or use async/defer attributes on script tag.');
  2148. }
  2149. }
  2150. var documentBody = isBrowser ? document.body : null;
  2151. function render(input, parentDom, callback) {
  2152. // Development warning
  2153. {
  2154. if (documentBody === parentDom) {
  2155. throwError('you cannot render() to the "document.body". Use an empty element as a container instead.');
  2156. }
  2157. }
  2158. if (input === NO_OP) {
  2159. return;
  2160. }
  2161. var rootLen = roots.length;
  2162. var rootInput;
  2163. var index;
  2164. for (index = 0; index < rootLen; index++) {
  2165. if (roots[index] === parentDom) {
  2166. rootInput = parentDom.$V;
  2167. break;
  2168. }
  2169. }
  2170. if (isUndefined(rootInput)) {
  2171. if (!isInvalid(input)) {
  2172. if (input.dom) {
  2173. input = directClone(input);
  2174. }
  2175. if (isNull(parentDom.firstChild)) {
  2176. mount(input, parentDom, LIFECYCLE, EMPTY_OBJ, false);
  2177. parentDom.$V = input;
  2178. roots.push(parentDom);
  2179. }
  2180. else {
  2181. hydrate(input, parentDom);
  2182. }
  2183. rootInput = input;
  2184. }
  2185. }
  2186. else {
  2187. if (isNullOrUndef(input)) {
  2188. remove(rootInput, parentDom);
  2189. roots.splice(index, 1);
  2190. }
  2191. else {
  2192. if (input.dom) {
  2193. input = directClone(input);
  2194. }
  2195. patch(rootInput, input, parentDom, LIFECYCLE, EMPTY_OBJ, false);
  2196. rootInput = parentDom.$V = input;
  2197. }
  2198. }
  2199. if (LIFECYCLE.length > 0) {
  2200. callAll(LIFECYCLE);
  2201. }
  2202. if (isFunction(callback)) {
  2203. callback();
  2204. }
  2205. if (rootInput && rootInput.flags & 14 /* Component */) {
  2206. return rootInput.children;
  2207. }
  2208. }
  2209. function createRenderer(parentDom) {
  2210. return function renderer(lastInput, nextInput) {
  2211. if (!parentDom) {
  2212. parentDom = lastInput;
  2213. }
  2214. render(nextInput, parentDom);
  2215. };
  2216. }
  2217. function createPortal(children, container) {
  2218. return createVNode(1024 /* Portal */, container, null, children, 0 /* UnknownChildren */, null, isInvalid(children) ? null : children.key, null);
  2219. }
  2220. var resolvedPromise = typeof Promise === 'undefined' ? null : Promise.resolve();
  2221. var fallbackMethod = typeof requestAnimationFrame === 'undefined' ? setTimeout : requestAnimationFrame;
  2222. function nextTick(fn) {
  2223. if (resolvedPromise) {
  2224. return resolvedPromise.then(fn);
  2225. }
  2226. return fallbackMethod(fn);
  2227. }
  2228. function queueStateChanges(component, newState, callback) {
  2229. if (isFunction(newState)) {
  2230. newState = newState(component.state, component.props, component.context);
  2231. }
  2232. var pending = component.$PS;
  2233. if (isNullOrUndef(pending)) {
  2234. component.$PS = newState;
  2235. }
  2236. else {
  2237. for (var stateKey in newState) {
  2238. pending[stateKey] = newState[stateKey];
  2239. }
  2240. }
  2241. if (!component.$PSS && !component.$BR) {
  2242. if (!component.$UPD) {
  2243. component.$PSS = true;
  2244. component.$UPD = true;
  2245. applyState(component, false, callback);
  2246. component.$UPD = false;
  2247. }
  2248. else {
  2249. // Async
  2250. var queue = component.$QU;
  2251. if (isNull(queue)) {
  2252. queue = component.$QU = [];
  2253. nextTick(promiseCallback(component, queue));
  2254. }
  2255. if (isFunction(callback)) {
  2256. queue.push(callback);
  2257. }
  2258. }
  2259. }
  2260. else {
  2261. component.$PSS = true;
  2262. if (component.$BR && isFunction(callback)) {
  2263. LIFECYCLE.push(callback.bind(component));
  2264. }
  2265. }
  2266. }
  2267. function promiseCallback(component, queue) {
  2268. return function () {
  2269. component.$QU = null;
  2270. component.$UPD = true;
  2271. applyState(component, false, function () {
  2272. for (var i = 0, len = queue.length; i < len; i++) {
  2273. queue[i].call(component);
  2274. }
  2275. });
  2276. component.$UPD = false;
  2277. };
  2278. }
  2279. function applyState(component, force, callback) {
  2280. if (component.$UN) {
  2281. return;
  2282. }
  2283. if (force || !component.$BR) {
  2284. component.$PSS = false;
  2285. var pendingState = component.$PS;
  2286. var prevState = component.state;
  2287. var nextState = combineFrom(prevState, pendingState);
  2288. var props = component.props;
  2289. var context = component.context;
  2290. component.$PS = null;
  2291. var vNode = component.$V;
  2292. var lastInput = component.$LI;
  2293. var parentDom = lastInput.dom && lastInput.dom.parentNode;
  2294. updateClassComponent(component, nextState, vNode, props, parentDom, LIFECYCLE, context, (vNode.flags & 32 /* SvgElement */) > 0, force, true);
  2295. if (component.$UN) {
  2296. return;
  2297. }
  2298. if ((component.$LI.flags & 1024 /* Portal */) === 0) {
  2299. var dom = component.$LI.dom;
  2300. while (!isNull((vNode = vNode.parentVNode))) {
  2301. if ((vNode.flags & 14 /* Component */) > 0) {
  2302. vNode.dom = dom;
  2303. }
  2304. }
  2305. }
  2306. if (LIFECYCLE.length > 0) {
  2307. callAll(LIFECYCLE);
  2308. }
  2309. }
  2310. else {
  2311. component.state = component.$PS;
  2312. component.$PS = null;
  2313. }
  2314. if (isFunction(callback)) {
  2315. callback.call(component);
  2316. }
  2317. }
  2318. var Component = function Component(props, context) {
  2319. this.state = null;
  2320. // Internal properties
  2321. this.$BR = false; // BLOCK RENDER
  2322. this.$BS = true; // BLOCK STATE
  2323. this.$PSS = false; // PENDING SET STATE
  2324. this.$PS = null; // PENDING STATE (PARTIAL or FULL)
  2325. this.$LI = null; // LAST INPUT
  2326. this.$V = null; // VNODE
  2327. this.$UN = false; // UNMOUNTED
  2328. this.$CX = null; // CHILDCONTEXT
  2329. this.$UPD = true; // UPDATING
  2330. this.$QU = null; // QUEUE
  2331. /** @type {object} */
  2332. this.props = props || EMPTY_OBJ;
  2333. /** @type {object} */
  2334. this.context = context || EMPTY_OBJ; // context should not be mutable
  2335. };
  2336. Component.prototype.forceUpdate = function forceUpdate (callback) {
  2337. if (this.$UN) {
  2338. return;
  2339. }
  2340. applyState(this, true, callback);
  2341. };
  2342. Component.prototype.setState = function setState (newState, callback) {
  2343. if (this.$UN) {
  2344. return;
  2345. }
  2346. if (!this.$BS) {
  2347. queueStateChanges(this, newState, callback);
  2348. }
  2349. else {
  2350. // Development warning
  2351. {
  2352. throwError('cannot update state via setState() in componentWillUpdate() or constructor.');
  2353. }
  2354. return;
  2355. }
  2356. };
  2357. // tslint:disable-next-line:no-empty
  2358. Component.prototype.render = function render (nextProps, nextState, nextContext) { };
  2359. // Public
  2360. Component.defaultProps = null;
  2361. {
  2362. /* tslint:disable-next-line:no-empty */
  2363. var testFunc = function testFn() { };
  2364. if ((testFunc.name || testFunc.toString()).indexOf('testFn') === -1) {
  2365. warning("It looks like you're using a minified copy of the development build " +
  2366. 'of Inferno. When deploying Inferno apps to production, make sure to use ' +
  2367. 'the production build which skips development warnings and is faster. ' +
  2368. 'See http://infernojs.org for more details.');
  2369. }
  2370. }
  2371. var version = "4.0.4";
  2372. exports.Component = Component;
  2373. exports.EMPTY_OBJ = EMPTY_OBJ;
  2374. exports.NO_OP = NO_OP;
  2375. exports.createComponentVNode = createComponentVNode;
  2376. exports.createPortal = createPortal;
  2377. exports.createRenderer = createRenderer;
  2378. exports.createTextVNode = createTextVNode;
  2379. exports.createVNode = createVNode;
  2380. exports.directClone = directClone;
  2381. exports.getFlagsForElementVnode = getFlagsForElementVnode;
  2382. exports.getNumberStyleValue = getNumberStyleValue;
  2383. exports.hydrate = hydrate;
  2384. exports.linkEvent = linkEvent;
  2385. exports.normalizeProps = normalizeProps;
  2386. exports.options = options;
  2387. exports.render = render;
  2388. exports.version = version;
  2389. Object.defineProperty(exports, '__esModule', { value: true });
  2390. })));