|
1 | 1 | (function webpackUniversalModuleDefinition(root, factory) {
|
2 | 2 | if(typeof exports === 'object' && typeof module === 'object')
|
3 |
| - module.exports = factory(); |
| 3 | + module.exports = factory(require("preact")); |
4 | 4 | else if(typeof define === 'function' && define.amd)
|
5 |
| - define([], factory); |
| 5 | + define(["preact"], factory); |
6 | 6 | else if(typeof exports === 'object')
|
7 |
| - exports["PreactRailsUJS"] = factory(); |
| 7 | + exports["PreactRailsUJS"] = factory(require("preact")); |
8 | 8 | else
|
9 |
| - root["PreactRailsUJS"] = factory(); |
10 |
| -})(window, function() { |
| 9 | + root["PreactRailsUJS"] = factory(root["Preact"]); |
| 10 | +})(window, function(__WEBPACK_EXTERNAL_MODULE_preact__) { |
11 | 11 | return /******/ (function(modules) { // webpackBootstrap
|
12 | 12 | /******/ // The module cache
|
13 | 13 | /******/ var installedModules = {};
|
@@ -103,7 +103,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
103 | 103 | /*! no static exports found */
|
104 | 104 | /***/ (function(module, exports, __webpack_require__) {
|
105 | 105 |
|
106 |
| -eval("//var preact = require(\"preact\")\nvar constructorFromGlobal = __webpack_require__(/*! ./src/getConstructor/fromGlobal */ \"./src/getConstructor/fromGlobal.js\")\nvar constructorFromRequireContextWithGlobalFallback = __webpack_require__(/*! ./src/getConstructor/fromRequireContextWithGlobalFallback */ \"./src/getConstructor/fromRequireContextWithGlobalFallback.js\")\n\nvar PreactRailsUJS = {\n CLASS_NAME_ATTR: 'data-preact-class',\n PROPS_ATTR: 'data-preact-props',\n\n findDOMNodes: function() {\n return document.querySelectorAll('['+PreactRailsUJS.CLASS_NAME_ATTR+']')\n },\n\n getConstructor: constructorFromGlobal,\n\n useContext: function(requireContext) {\n this.getConstructor = constructorFromRequireContextWithGlobalFallback(requireContext)\n },\n\n mountComponents: function() {\n console.log('mountcomponent loaded')\n var nodes = PreactRailsUJS.findDOMNodes()\n for (var i = 0; i < nodes.length; ++i) {\n var node = nodes[i]\n //PreactRailsUJS.clearChildNodes(node)\n var className = node.getAttribute(PreactRailsUJS.CLASS_NAME_ATTR)\n var constructor = PreactRailsUJS.getConstructor(className)\n var propsJson = node.getAttribute(PreactRailsUJS.PROPS_ATTR)\n var props = propsJson && JSON.parse(propsJson)\n preact.render(preact.h(constructor, props), node)\n }\n },\n\n clearChildNodes: function(node) {\n while (node.firstChild) {\n node.removeChild(node.firstChild);\n }\n },\n\n handleEvent: function(eventName, callback) {\n document.addEventListener(eventName, callback);\n },\n\n removeEvent: function(eventName, callback) {\n document.removeEventListener(eventName, callback);\n }\n\n}\n\nPreactRailsUJS.handleEvent('DOMContentLoaded', PreactRailsUJS.mountComponents)\n\nmodule.exports = PreactRailsUJS\n\n\n//# sourceURL=webpack://PreactRailsUJS/./index.js?"); |
| 106 | +eval("var preact = __webpack_require__(/*! preact */ \"preact\")\nvar constructorFromGlobal = __webpack_require__(/*! ./src/getConstructor/fromGlobal */ \"./src/getConstructor/fromGlobal.js\")\nvar constructorFromRequireContextWithGlobalFallback = __webpack_require__(/*! ./src/getConstructor/fromRequireContextWithGlobalFallback */ \"./src/getConstructor/fromRequireContextWithGlobalFallback.js\")\n\nvar PreactRailsUJS = {\n CLASS_NAME_ATTR: 'data-preact-class',\n PROPS_ATTR: 'data-preact-props',\n\n findDOMNodes: function() {\n return document.querySelectorAll('['+PreactRailsUJS.CLASS_NAME_ATTR+']')\n },\n\n getConstructor: constructorFromGlobal,\n\n useContext: function(requireContext) {\n this.getConstructor = constructorFromRequireContextWithGlobalFallback(requireContext)\n },\n\n mountComponents: function() {\n var nodes = PreactRailsUJS.findDOMNodes()\n for (var i = 0; i < nodes.length; ++i) {\n var node = nodes[i]\n PreactRailsUJS.clearChildNodes(node)\n var className = node.getAttribute(PreactRailsUJS.CLASS_NAME_ATTR)\n var constructor = PreactRailsUJS.getConstructor(className)\n var propsJson = node.getAttribute(PreactRailsUJS.PROPS_ATTR)\n var props = propsJson && JSON.parse(propsJson)\n preact.render(preact.h(constructor, props), node)\n }\n },\n\n clearChildNodes: function(node) {\n while (node.firstChild) {\n node.removeChild(node.firstChild);\n }\n },\n\n handleEvent: function(eventName, callback) {\n document.addEventListener(eventName, callback);\n },\n\n removeEvent: function(eventName, callback) {\n document.removeEventListener(eventName, callback);\n }\n\n}\n\nPreactRailsUJS.handleEvent('DOMContentLoaded', PreactRailsUJS.mountComponents)\n\nmodule.exports = PreactRailsUJS\n\n\n//# sourceURL=webpack://PreactRailsUJS/./index.js?"); |
107 | 107 |
|
108 | 108 | /***/ }),
|
109 | 109 |
|
@@ -138,6 +138,17 @@ eval("// Load React components by requiring them from \"components/\", for examp
|
138 | 138 |
|
139 | 139 | eval("// Make a function which:\n// - First tries to require the name\n// - Then falls back to global lookup\nvar fromGlobal = __webpack_require__(/*! ./fromGlobal */ \"./src/getConstructor/fromGlobal.js\")\nvar fromRequireContext = __webpack_require__(/*! ./fromRequireContext */ \"./src/getConstructor/fromRequireContext.js\")\n\nmodule.exports = function(reqctx) {\n var fromCtx = fromRequireContext(reqctx)\n return function(className) {\n var component;\n try {\n // `require` will raise an error if this className isn't found:\n component = fromCtx(className)\n } catch (firstErr) {\n // fallback to global:\n try {\n component = fromGlobal(className)\n } catch (secondErr) {\n console.error(firstErr)\n console.error(secondErr)\n }\n }\n return component\n }\n}\n\n\n//# sourceURL=webpack://PreactRailsUJS/./src/getConstructor/fromRequireContextWithGlobalFallback.js?");
|
140 | 140 |
|
| 141 | +/***/ }), |
| 142 | + |
| 143 | +/***/ "preact": |
| 144 | +/*!******************************************************************************************!*\ |
| 145 | + !*** external {"root":"Preact","commonjs2":"preact","commonjs":"preact","amd":"preact"} ***! |
| 146 | + \******************************************************************************************/ |
| 147 | +/*! no static exports found */ |
| 148 | +/***/ (function(module, exports) { |
| 149 | + |
| 150 | +eval("module.exports = __WEBPACK_EXTERNAL_MODULE_preact__;\n\n//# sourceURL=webpack://PreactRailsUJS/external_%7B%22root%22:%22Preact%22,%22commonjs2%22:%22preact%22,%22commonjs%22:%22preact%22,%22amd%22:%22preact%22%7D?"); |
| 151 | + |
141 | 152 | /***/ })
|
142 | 153 |
|
143 | 154 | /******/ });
|
|
0 commit comments