UNPKG

rn-web-cli

Version:

React Native for Web

1 lines 4.63 kB
{"version":3,"sources":["node_modules\\react-dom\\lib\\ReactRef.js"],"names":["ReactOwner","require","ReactRef","attachRef","ref","component","owner","getPublicInstance","addComponentAsRefTo","detachRef","removeComponentAsRefFrom","attachRefs","instance","element","_owner","shouldUpdateRefs","prevElement","nextElement","prevRef","prevOwner","nextRef","nextOwner","detachRefs","module","exports"],"mappings":";;;;;;;;;;;AAWA;;AAEA,GAAIA,YAAaC,QAAQ,cAAR,CAAjB;;AAEA,GAAIC,UAAW,EAAf;;AAEA,QAASC,UAAT,CAAmBC,GAAnB,CAAwBC,SAAxB,CAAmCC,KAAnC,CAA0C;AACxC,GAAI,MAAOF,IAAP,GAAe,UAAnB,CAA+B;AAC7BA,IAAIC,UAAUE,iBAAV,EAAJ;AACD,CAFD,IAEO;;AAELP,WAAWQ,mBAAX,CAA+BH,SAA/B,CAA0CD,GAA1C,CAA+CE,KAA/C;AACD;AACF;;AAED,QAASG,UAAT,CAAmBL,GAAnB,CAAwBC,SAAxB,CAAmCC,KAAnC,CAA0C;AACxC,GAAI,MAAOF,IAAP,GAAe,UAAnB,CAA+B;AAC7BA,IAAI,IAAJ;AACD,CAFD,IAEO;;AAELJ,WAAWU,wBAAX,CAAoCL,SAApC,CAA+CD,GAA/C,CAAoDE,KAApD;AACD;AACF;;AAEDJ,SAASS,UAAT,CAAsB,SAAUC,QAAV,CAAoBC,OAApB,CAA6B;AACjD,GAAIA,UAAY,IAAZ,EAAoB,MAAOA,QAAP,GAAmB,QAA3C,CAAqD;AACnD;AACD;AACD,GAAIT,KAAMS,QAAQT,GAAlB;AACA,GAAIA,KAAO,IAAX,CAAiB;AACfD,UAAUC,GAAV,CAAeQ,QAAf,CAAyBC,QAAQC,MAAjC;AACD;AACF,CARD;;AAUAZ,SAASa,gBAAT,CAA4B,SAAUC,WAAV,CAAuBC,WAAvB,CAAoC;;;;;;;;;;;;;AAa9D,GAAIC,SAAU,IAAd;AACA,GAAIC,WAAY,IAAhB;AACA,GAAIH,cAAgB,IAAhB,EAAwB,MAAOA,YAAP,GAAuB,QAAnD,CAA6D;AAC3DE,QAAUF,YAAYZ,GAAtB;AACAe,UAAYH,YAAYF,MAAxB;AACD;;AAED,GAAIM,SAAU,IAAd;AACA,GAAIC,WAAY,IAAhB;AACA,GAAIJ,cAAgB,IAAhB,EAAwB,MAAOA,YAAP,GAAuB,QAAnD,CAA6D;AAC3DG,QAAUH,YAAYb,GAAtB;AACAiB,UAAYJ,YAAYH,MAAxB;AACD;;AAED,MAAOI,WAAYE,OAAZ;;AAEP,MAAOA,QAAP,GAAmB,QAAnB,EAA+BC,YAAcF,SAF7C;AAGD,CA9BD;;AAgCAjB,SAASoB,UAAT,CAAsB,SAAUV,QAAV,CAAoBC,OAApB,CAA6B;AACjD,GAAIA,UAAY,IAAZ,EAAoB,MAAOA,QAAP,GAAmB,QAA3C,CAAqD;AACnD;AACD;AACD,GAAIT,KAAMS,QAAQT,GAAlB;AACA,GAAIA,KAAO,IAAX,CAAiB;AACfK,UAAUL,GAAV,CAAeQ,QAAf,CAAyBC,QAAQC,MAAjC;AACD;AACF,CARD;;AAUAS,OAAOC,OAAP,CAAiBtB,QAAjB","file":"ReactRef.js","sourceRoot":"D:/Work/Office/react-native-on-web/cli/tmpl/project","sourcesContent":["/**\n * Copyright 2013-present, Facebook, Inc.\n * All rights reserved.\n *\n * This source code is licensed under the BSD-style license found in the\n * LICENSE file in the root directory of this source tree. An additional grant\n * of patent rights can be found in the PATENTS file in the same directory.\n *\n * \n */\n\n'use strict';\n\nvar ReactOwner = require('./ReactOwner');\n\nvar ReactRef = {};\n\nfunction attachRef(ref, component, owner) {\n if (typeof ref === 'function') {\n ref(component.getPublicInstance());\n } else {\n // Legacy ref\n ReactOwner.addComponentAsRefTo(component, ref, owner);\n }\n}\n\nfunction detachRef(ref, component, owner) {\n if (typeof ref === 'function') {\n ref(null);\n } else {\n // Legacy ref\n ReactOwner.removeComponentAsRefFrom(component, ref, owner);\n }\n}\n\nReactRef.attachRefs = function (instance, element) {\n if (element === null || typeof element !== 'object') {\n return;\n }\n var ref = element.ref;\n if (ref != null) {\n attachRef(ref, instance, element._owner);\n }\n};\n\nReactRef.shouldUpdateRefs = function (prevElement, nextElement) {\n // If either the owner or a `ref` has changed, make sure the newest owner\n // has stored a reference to `this`, and the previous owner (if different)\n // has forgotten the reference to `this`. We use the element instead\n // of the public this.props because the post processing cannot determine\n // a ref. The ref conceptually lives on the element.\n\n // TODO: Should this even be possible? The owner cannot change because\n // it's forbidden by shouldUpdateReactComponent. The ref can change\n // if you swap the keys of but not the refs. Reconsider where this check\n // is made. It probably belongs where the key checking and\n // instantiateReactComponent is done.\n\n var prevRef = null;\n var prevOwner = null;\n if (prevElement !== null && typeof prevElement === 'object') {\n prevRef = prevElement.ref;\n prevOwner = prevElement._owner;\n }\n\n var nextRef = null;\n var nextOwner = null;\n if (nextElement !== null && typeof nextElement === 'object') {\n nextRef = nextElement.ref;\n nextOwner = nextElement._owner;\n }\n\n return prevRef !== nextRef ||\n // If owner changes but we have an unchanged function ref, don't update refs\n typeof nextRef === 'string' && nextOwner !== prevOwner;\n};\n\nReactRef.detachRefs = function (instance, element) {\n if (element === null || typeof element !== 'object') {\n return;\n }\n var ref = element.ref;\n if (ref != null) {\n detachRef(ref, instance, element._owner);\n }\n};\n\nmodule.exports = ReactRef;"]}