├── .babelrc ├── .gitignore ├── README.md ├── dist ├── components │ ├── angular-app.html │ ├── angular-app.js │ ├── angular-app.js.map │ ├── react-app.html │ ├── react-app.js │ └── react-app.js.map ├── index.html ├── main.js ├── main.js.map ├── polyfills.js └── polyfills.js.map ├── package-lock.json ├── package.json ├── src ├── application.js ├── components │ ├── angular-app.html │ ├── angular-app │ │ ├── angular-app.js │ │ ├── app.component.js │ │ ├── app.module.js │ │ ├── index.html │ │ └── main.js │ ├── react-app.html │ └── react-app │ │ ├── App.js │ │ ├── index.html │ │ ├── main.js │ │ └── react-app.js ├── index.html ├── main.js └── polyfills.js └── webpack.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | "targets": { 7 | "browsers": [ 8 | "> 2%", 9 | "last 1 version" 10 | ] 11 | } 12 | } 13 | ], 14 | "@babel/preset-react" 15 | ], 16 | "plugins": [ 17 | "@babel/transform-runtime", 18 | "@babel/plugin-proposal-object-rest-spread", 19 | "@babel/plugin-proposal-class-properties" 20 | ] 21 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | *.log 4 | .npmrc 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Web components of Angular and React live together 2 | 3 | * `npm i` 4 | * `npm start` 5 | 6 | ### Error Handling 7 | For demo purpose each application will randomly fail with 50% probability 8 | 9 | This is done just in order to show how errors can be handled and passed to container. 10 | -------------------------------------------------------------------------------- /dist/components/angular-app.html: -------------------------------------------------------------------------------- 1 | 9 | 10 | -------------------------------------------------------------------------------- /dist/components/react-app.html: -------------------------------------------------------------------------------- 1 | 9 | 10 | -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Web components loader 6 | 7 | 8 | 9 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /dist/main.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | /******/ 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | /******/ 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) { 10 | /******/ return installedModules[moduleId].exports; 11 | /******/ } 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ i: moduleId, 15 | /******/ l: false, 16 | /******/ exports: {} 17 | /******/ }; 18 | /******/ 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | /******/ 22 | /******/ // Flag the module as loaded 23 | /******/ module.l = true; 24 | /******/ 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | /******/ 29 | /******/ 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | /******/ 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | /******/ 36 | /******/ // define getter function for harmony exports 37 | /******/ __webpack_require__.d = function(exports, name, getter) { 38 | /******/ if(!__webpack_require__.o(exports, name)) { 39 | /******/ Object.defineProperty(exports, name, { 40 | /******/ configurable: false, 41 | /******/ enumerable: true, 42 | /******/ get: getter 43 | /******/ }); 44 | /******/ } 45 | /******/ }; 46 | /******/ 47 | /******/ // getDefaultExport function for compatibility with non-harmony modules 48 | /******/ __webpack_require__.n = function(module) { 49 | /******/ var getter = module && module.__esModule ? 50 | /******/ function getDefault() { return module['default']; } : 51 | /******/ function getModuleExports() { return module; }; 52 | /******/ __webpack_require__.d(getter, 'a', getter); 53 | /******/ return getter; 54 | /******/ }; 55 | /******/ 56 | /******/ // Object.prototype.hasOwnProperty.call 57 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 58 | /******/ 59 | /******/ // __webpack_public_path__ 60 | /******/ __webpack_require__.p = ""; 61 | /******/ 62 | /******/ // Load entry module and return exports 63 | /******/ return __webpack_require__(__webpack_require__.s = 173); 64 | /******/ }) 65 | /************************************************************************/ 66 | /******/ ({ 67 | 68 | /***/ 11: 69 | /***/ (function(module, exports, __webpack_require__) { 70 | 71 | var global = __webpack_require__(6); 72 | var core = __webpack_require__(7); 73 | var ctx = __webpack_require__(31); 74 | var hide = __webpack_require__(12); 75 | var PROTOTYPE = 'prototype'; 76 | 77 | var $export = function (type, name, source) { 78 | var IS_FORCED = type & $export.F; 79 | var IS_GLOBAL = type & $export.G; 80 | var IS_STATIC = type & $export.S; 81 | var IS_PROTO = type & $export.P; 82 | var IS_BIND = type & $export.B; 83 | var IS_WRAP = type & $export.W; 84 | var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); 85 | var expProto = exports[PROTOTYPE]; 86 | var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]; 87 | var key, own, out; 88 | if (IS_GLOBAL) source = name; 89 | for (key in source) { 90 | // contains in native 91 | own = !IS_FORCED && target && target[key] !== undefined; 92 | if (own && key in exports) continue; 93 | // export native or passed 94 | out = own ? target[key] : source[key]; 95 | // prevent global pollution for namespaces 96 | exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] 97 | // bind timers to global for call from export context 98 | : IS_BIND && own ? ctx(out, global) 99 | // wrap global constructors for prevent change them in library 100 | : IS_WRAP && target[key] == out ? (function (C) { 101 | var F = function (a, b, c) { 102 | if (this instanceof C) { 103 | switch (arguments.length) { 104 | case 0: return new C(); 105 | case 1: return new C(a); 106 | case 2: return new C(a, b); 107 | } return new C(a, b, c); 108 | } return C.apply(this, arguments); 109 | }; 110 | F[PROTOTYPE] = C[PROTOTYPE]; 111 | return F; 112 | // make static versions for prototype methods 113 | })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; 114 | // export proto methods to core.%CONSTRUCTOR%.methods.%NAME% 115 | if (IS_PROTO) { 116 | (exports.virtual || (exports.virtual = {}))[key] = out; 117 | // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% 118 | if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out); 119 | } 120 | } 121 | }; 122 | // type bitmap 123 | $export.F = 1; // forced 124 | $export.G = 2; // global 125 | $export.S = 4; // static 126 | $export.P = 8; // proto 127 | $export.B = 16; // bind 128 | $export.W = 32; // wrap 129 | $export.U = 64; // safe 130 | $export.R = 128; // real proto method for `library` 131 | module.exports = $export; 132 | 133 | 134 | /***/ }), 135 | 136 | /***/ 12: 137 | /***/ (function(module, exports, __webpack_require__) { 138 | 139 | var dP = __webpack_require__(9); 140 | var createDesc = __webpack_require__(21); 141 | module.exports = __webpack_require__(8) ? function (object, key, value) { 142 | return dP.f(object, key, createDesc(1, value)); 143 | } : function (object, key, value) { 144 | object[key] = value; 145 | return object; 146 | }; 147 | 148 | 149 | /***/ }), 150 | 151 | /***/ 13: 152 | /***/ (function(module, exports) { 153 | 154 | module.exports = function (it) { 155 | return typeof it === 'object' ? it !== null : typeof it === 'function'; 156 | }; 157 | 158 | 159 | /***/ }), 160 | 161 | /***/ 15: 162 | /***/ (function(module, exports) { 163 | 164 | module.exports = function (exec) { 165 | try { 166 | return !!exec(); 167 | } catch (e) { 168 | return true; 169 | } 170 | }; 171 | 172 | 173 | /***/ }), 174 | 175 | /***/ 16: 176 | /***/ (function(module, exports, __webpack_require__) { 177 | 178 | var isObject = __webpack_require__(13); 179 | module.exports = function (it) { 180 | if (!isObject(it)) throw TypeError(it + ' is not an object!'); 181 | return it; 182 | }; 183 | 184 | 185 | /***/ }), 186 | 187 | /***/ 173: 188 | /***/ (function(module, exports, __webpack_require__) { 189 | 190 | "use strict"; 191 | 192 | 193 | var _application = __webpack_require__(174); 194 | 195 | document.addEventListener('DOMContentLoaded', function () { 196 | (0, _application.render)(_application.Application, document.getElementById('app')); 197 | }); 198 | 199 | /***/ }), 200 | 201 | /***/ 174: 202 | /***/ (function(module, exports, __webpack_require__) { 203 | 204 | "use strict"; 205 | 206 | 207 | var _interopRequireDefault = __webpack_require__(29); 208 | 209 | Object.defineProperty(exports, "__esModule", { 210 | value: true 211 | }); 212 | exports.render = render; 213 | exports.Application = void 0; 214 | 215 | var _classCallCheck2 = _interopRequireDefault(__webpack_require__(30)); 216 | 217 | var _createClass2 = _interopRequireDefault(__webpack_require__(49)); 218 | 219 | var Application = 220 | /*#__PURE__*/ 221 | function () { 222 | function Application() { 223 | var _this = this; 224 | 225 | (0, _classCallCheck2.default)(this, Application); 226 | Object.defineProperty(this, "root", { 227 | configurable: true, 228 | enumerable: true, 229 | writable: true, 230 | value: null 231 | }); 232 | Object.defineProperty(this, "title", { 233 | configurable: true, 234 | enumerable: true, 235 | writable: true, 236 | value: 'Web Components' 237 | }); 238 | Object.defineProperty(this, "container", { 239 | configurable: true, 240 | enumerable: true, 241 | writable: true, 242 | value: null 243 | }); 244 | Object.defineProperty(this, "errorMode", { 245 | configurable: true, 246 | enumerable: true, 247 | writable: true, 248 | value: false 249 | }); 250 | Object.defineProperty(this, "loadedApp", { 251 | configurable: true, 252 | enumerable: true, 253 | writable: true, 254 | value: null 255 | }); 256 | Object.defineProperty(this, "handleInputChange", { 257 | configurable: true, 258 | enumerable: true, 259 | writable: true, 260 | value: function value(event) { 261 | if (event.target.id === 'title') { 262 | _this.title = event.target.value; 263 | 264 | _this.updateLoadedApp(); 265 | 266 | return; 267 | } 268 | 269 | if (event.target.name !== 'errorMode') { 270 | return false; 271 | } 272 | 273 | _this.errorMode = event.target.value === '1'; 274 | 275 | _this.updateLoadedApp(); 276 | } 277 | }); 278 | Object.defineProperty(this, "handleButtonClick", { 279 | configurable: true, 280 | enumerable: true, 281 | writable: true, 282 | value: function value(event) { 283 | if (event.target.nodeName !== 'BUTTON') { 284 | return; 285 | } 286 | 287 | _this.loadApp(event.target.dataset.app); 288 | } 289 | }); 290 | } 291 | 292 | (0, _createClass2.default)(Application, [{ 293 | key: "bootstrap", 294 | value: function bootstrap(root) { 295 | this.root = root; 296 | this.root.innerHTML = "\n
\n

Hello web-components

\n\n
\n \n \n
\n
\n\n
\n
\n

Separately Running Multiple Apps

\n \n \n
\n \n
\n

Rendering Apps in Same Container

\n\n
\n

Error Mode

\n Disabled\n Enabled\n
\n\n
\n \n \n
\n
\n
\n
\n "); 297 | this.container = this.root.querySelector('.container'); 298 | this.root.addEventListener('keyup', this.handleInputChange); 299 | this.root.addEventListener('change', this.handleInputChange); 300 | this.root.addEventListener('click', this.handleButtonClick); 301 | } 302 | }, { 303 | key: "updateLoadedApp", 304 | value: function updateLoadedApp() { 305 | if (this.loadedApp) { 306 | this.loadedApp.setAttribute('title', this.title); 307 | 308 | if (this.errorMode) { 309 | this.loadedApp.setAttribute('error-mode', ''); 310 | } else { 311 | this.loadedApp.removeAttribute('error-mode'); 312 | } 313 | } 314 | } 315 | }, { 316 | key: "loadApp", 317 | value: function loadApp(app) { 318 | var _this2 = this; 319 | 320 | this.container.innerHTML = ''; 321 | this.loadedApp = document.createElement(app); 322 | 323 | if (this.errorMode) { 324 | this.loadedApp.setAttribute('error-mode', ''); 325 | } 326 | 327 | this.loadedApp.setAttribute('title', this.title); 328 | this.loadedApp.addEventListener('load', function (load) { 329 | console.log('loaded', load); 330 | }); 331 | this.loadedApp.addEventListener('error', function (err) { 332 | console.error('error', err); 333 | 334 | _this2.loadedApp.parentNode.removeChild(_this2.loadedApp); 335 | 336 | _this2.loadedApp = null; 337 | 338 | _this2.container.appendChild(_this2.getError(err.detail)); 339 | }); 340 | this.container.appendChild(this.loadedApp); 341 | } 342 | }, { 343 | key: "getError", 344 | value: function getError(err) { 345 | var message = document.createElement('p'); 346 | message.innerHTML = err.stack.split('\n').join('
'); 347 | return message; 348 | } 349 | }]); 350 | return Application; 351 | }(); 352 | 353 | exports.Application = Application; 354 | 355 | function render(Component, element) { 356 | var component = new Component(); 357 | component.bootstrap(element); 358 | } 359 | 360 | /***/ }), 361 | 362 | /***/ 21: 363 | /***/ (function(module, exports) { 364 | 365 | module.exports = function (bitmap, value) { 366 | return { 367 | enumerable: !(bitmap & 1), 368 | configurable: !(bitmap & 2), 369 | writable: !(bitmap & 4), 370 | value: value 371 | }; 372 | }; 373 | 374 | 375 | /***/ }), 376 | 377 | /***/ 25: 378 | /***/ (function(module, exports, __webpack_require__) { 379 | 380 | // 7.1.1 ToPrimitive(input [, PreferredType]) 381 | var isObject = __webpack_require__(13); 382 | // instead of the ES6 spec version, we didn't implement @@toPrimitive case 383 | // and the second argument - flag - preferred type is a string 384 | module.exports = function (it, S) { 385 | if (!isObject(it)) return it; 386 | var fn, val; 387 | if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; 388 | if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; 389 | if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; 390 | throw TypeError("Can't convert object to primitive value"); 391 | }; 392 | 393 | 394 | /***/ }), 395 | 396 | /***/ 29: 397 | /***/ (function(module, exports) { 398 | 399 | function _interopRequireDefault(obj) { 400 | return obj && obj.__esModule ? obj : { 401 | default: obj 402 | }; 403 | } 404 | 405 | module.exports = _interopRequireDefault; 406 | 407 | /***/ }), 408 | 409 | /***/ 30: 410 | /***/ (function(module, exports) { 411 | 412 | function _classCallCheck(instance, Constructor) { 413 | if (!(instance instanceof Constructor)) { 414 | throw new TypeError("Cannot call a class as a function"); 415 | } 416 | } 417 | 418 | module.exports = _classCallCheck; 419 | 420 | /***/ }), 421 | 422 | /***/ 31: 423 | /***/ (function(module, exports, __webpack_require__) { 424 | 425 | // optional / simple context binding 426 | var aFunction = __webpack_require__(57); 427 | module.exports = function (fn, that, length) { 428 | aFunction(fn); 429 | if (that === undefined) return fn; 430 | switch (length) { 431 | case 1: return function (a) { 432 | return fn.call(that, a); 433 | }; 434 | case 2: return function (a, b) { 435 | return fn.call(that, a, b); 436 | }; 437 | case 3: return function (a, b, c) { 438 | return fn.call(that, a, b, c); 439 | }; 440 | } 441 | return function (/* ...args */) { 442 | return fn.apply(that, arguments); 443 | }; 444 | }; 445 | 446 | 447 | /***/ }), 448 | 449 | /***/ 32: 450 | /***/ (function(module, exports, __webpack_require__) { 451 | 452 | module.exports = !__webpack_require__(8) && !__webpack_require__(15)(function () { 453 | return Object.defineProperty(__webpack_require__(33)('div'), 'a', { get: function () { return 7; } }).a != 7; 454 | }); 455 | 456 | 457 | /***/ }), 458 | 459 | /***/ 33: 460 | /***/ (function(module, exports, __webpack_require__) { 461 | 462 | var isObject = __webpack_require__(13); 463 | var document = __webpack_require__(6).document; 464 | // typeof document.createElement is 'object' in old IE 465 | var is = isObject(document) && isObject(document.createElement); 466 | module.exports = function (it) { 467 | return is ? document.createElement(it) : {}; 468 | }; 469 | 470 | 471 | /***/ }), 472 | 473 | /***/ 49: 474 | /***/ (function(module, exports, __webpack_require__) { 475 | 476 | var _Object$defineProperty = __webpack_require__(54); 477 | 478 | function _defineProperties(target, props) { 479 | for (var i = 0; i < props.length; i++) { 480 | var descriptor = props[i]; 481 | descriptor.enumerable = descriptor.enumerable || false; 482 | descriptor.configurable = true; 483 | if ("value" in descriptor) descriptor.writable = true; 484 | 485 | _Object$defineProperty(target, descriptor.key, descriptor); 486 | } 487 | } 488 | 489 | function _createClass(Constructor, protoProps, staticProps) { 490 | if (protoProps) _defineProperties(Constructor.prototype, protoProps); 491 | if (staticProps) _defineProperties(Constructor, staticProps); 492 | return Constructor; 493 | } 494 | 495 | module.exports = _createClass; 496 | 497 | /***/ }), 498 | 499 | /***/ 54: 500 | /***/ (function(module, exports, __webpack_require__) { 501 | 502 | module.exports = __webpack_require__(55); 503 | 504 | /***/ }), 505 | 506 | /***/ 55: 507 | /***/ (function(module, exports, __webpack_require__) { 508 | 509 | __webpack_require__(56); 510 | var $Object = __webpack_require__(7).Object; 511 | module.exports = function defineProperty(it, key, desc) { 512 | return $Object.defineProperty(it, key, desc); 513 | }; 514 | 515 | 516 | /***/ }), 517 | 518 | /***/ 56: 519 | /***/ (function(module, exports, __webpack_require__) { 520 | 521 | var $export = __webpack_require__(11); 522 | // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) 523 | $export($export.S + $export.F * !__webpack_require__(8), 'Object', { defineProperty: __webpack_require__(9).f }); 524 | 525 | 526 | /***/ }), 527 | 528 | /***/ 57: 529 | /***/ (function(module, exports) { 530 | 531 | module.exports = function (it) { 532 | if (typeof it != 'function') throw TypeError(it + ' is not a function!'); 533 | return it; 534 | }; 535 | 536 | 537 | /***/ }), 538 | 539 | /***/ 6: 540 | /***/ (function(module, exports) { 541 | 542 | // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 543 | var global = module.exports = typeof window != 'undefined' && window.Math == Math 544 | ? window : typeof self != 'undefined' && self.Math == Math ? self 545 | // eslint-disable-next-line no-new-func 546 | : Function('return this')(); 547 | if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef 548 | 549 | 550 | /***/ }), 551 | 552 | /***/ 7: 553 | /***/ (function(module, exports) { 554 | 555 | var core = module.exports = { version: '2.5.1' }; 556 | if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef 557 | 558 | 559 | /***/ }), 560 | 561 | /***/ 8: 562 | /***/ (function(module, exports, __webpack_require__) { 563 | 564 | // Thank's IE8 for his funny defineProperty 565 | module.exports = !__webpack_require__(15)(function () { 566 | return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; 567 | }); 568 | 569 | 570 | /***/ }), 571 | 572 | /***/ 9: 573 | /***/ (function(module, exports, __webpack_require__) { 574 | 575 | var anObject = __webpack_require__(16); 576 | var IE8_DOM_DEFINE = __webpack_require__(32); 577 | var toPrimitive = __webpack_require__(25); 578 | var dP = Object.defineProperty; 579 | 580 | exports.f = __webpack_require__(8) ? Object.defineProperty : function defineProperty(O, P, Attributes) { 581 | anObject(O); 582 | P = toPrimitive(P, true); 583 | anObject(Attributes); 584 | if (IE8_DOM_DEFINE) try { 585 | return dP(O, P, Attributes); 586 | } catch (e) { /* empty */ } 587 | if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); 588 | if ('value' in Attributes) O[P] = Attributes.value; 589 | return O; 590 | }; 591 | 592 | 593 | /***/ }) 594 | 595 | /******/ }); 596 | //# sourceMappingURL=main.js.map -------------------------------------------------------------------------------- /dist/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["webpack:///webpack/bootstrap 624a5b2fe611efced739","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_export.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_hide.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_is-object.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_fails.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_an-object.js","webpack:///./src/main.js","webpack:///./src/application.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_property-desc.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_to-primitive.js","webpack:///./node_modules/@babel/runtime/helpers/interopRequireDefault.js","webpack:///./node_modules/@babel/runtime/helpers/classCallCheck.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_ctx.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_ie8-dom-define.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_dom-create.js","webpack:///./node_modules/@babel/runtime/helpers/createClass.js","webpack:///./node_modules/@babel/runtime/core-js/object/define-property.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/fn/object/define-property.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/es6.object.define-property.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_a-function.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_global.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_core.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_descriptors.js","webpack:///./node_modules/@babel/runtime/node_modules/core-js/library/modules/_object-dp.js"],"names":["document","addEventListener","getElementById","Application","event","target","id","title","value","updateLoadedApp","name","errorMode","nodeName","loadApp","dataset","app","root","innerHTML","container","querySelector","handleInputChange","handleButtonClick","loadedApp","setAttribute","removeAttribute","createElement","load","console","log","err","error","parentNode","removeChild","appendChild","getError","detail","message","stack","split","join","render","Component","element","component","bootstrap"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAK;AACL;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;AAEA;AACA;;;;;;;;AC7DA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iEAAiE;AACjE;AACA,kFAAkF;AAClF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,WAAW;AACX,SAAS;AACT;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA,+CAA+C;AAC/C;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,eAAe;AACf,eAAe;AACf,eAAe;AACf,gBAAgB;AAChB;;;;;;;;AC5DA;AACA;AACA;AACA;AACA,CAAC;AACD;AACA;AACA;;;;;;;;ACPA;AACA;AACA;;;;;;;;ACFA;AACA;AACA;AACA,GAAG;AACH;AACA;AACA;;;;;;;;ACNA;AACA;AACA;AACA;AACA;;;;;;;;;;;ACJA;;AAEAA,SAASC,gBAAT,CAA0B,kBAA1B,EAA8C,YAAM;AAChD,qDAAoBD,SAASE,cAAT,CAAwB,KAAxB,CAApB;AACH,CAFD,E;;;;;;;;;;;;;;;;;;;;;;ICFaC,W;;;;;;;;;;;aACF;;;;;;aACC;;;;;;aACI;;;;;;aACA;;;;;;aACA;;;;;;aA8CQ,eAACC,KAAD,EAAW;AAC3B,YAAIA,MAAMC,MAAN,CAAaC,EAAb,KAAoB,OAAxB,EAAiC;AAC7B,gBAAKC,KAAL,GAAaH,MAAMC,MAAN,CAAaG,KAA1B;;AACA,gBAAKC,eAAL;;AACA;AACH;;AAED,YAAIL,MAAMC,MAAN,CAAaK,IAAb,KAAsB,WAA1B,EAAuC;AACnC,iBAAO,KAAP;AACH;;AAED,cAAKC,SAAL,GAAiBP,MAAMC,MAAN,CAAaG,KAAb,KAAuB,GAAxC;;AAEA,cAAKC,eAAL;AACH;;;;;;aAEmB,eAACL,KAAD,EAAW;AAC3B,YAAIA,MAAMC,MAAN,CAAaO,QAAb,KAA0B,QAA9B,EAAwC;AACpC;AACH;;AAED,cAAKC,OAAL,CAAaT,MAAMC,MAAN,CAAaS,OAAb,CAAqBC,GAAlC;AACH;;;;;;8BAlESC,I,EAAM;AACZ,WAAKA,IAAL,GAAYA,IAAZ;AAEA,WAAKA,IAAL,CAAUC,SAAV,2QAMoD,KAAKV,KANzD;AAmCA,WAAKW,SAAL,GAAiB,KAAKF,IAAL,CAAUG,aAAV,CAAwB,YAAxB,CAAjB;AACA,WAAKH,IAAL,CAAUf,gBAAV,CAA2B,OAA3B,EAAoC,KAAKmB,iBAAzC;AACA,WAAKJ,IAAL,CAAUf,gBAAV,CAA2B,QAA3B,EAAqC,KAAKmB,iBAA1C;AACA,WAAKJ,IAAL,CAAUf,gBAAV,CAA2B,OAA3B,EAAoC,KAAKoB,iBAAzC;AACH;;;sCA0BiB;AACd,UAAI,KAAKC,SAAT,EAAoB;AAChB,aAAKA,SAAL,CAAeC,YAAf,CAA4B,OAA5B,EAAqC,KAAKhB,KAA1C;;AAEA,YAAI,KAAKI,SAAT,EAAoB;AAChB,eAAKW,SAAL,CAAeC,YAAf,CAA4B,YAA5B,EAA0C,EAA1C;AACH,SAFD,MAEO;AACH,eAAKD,SAAL,CAAeE,eAAf,CAA+B,YAA/B;AACH;AACJ;AACJ;;;4BAEOT,G,EAAK;AAAA;;AACT,WAAKG,SAAL,CAAeD,SAAf,GAA2B,EAA3B;AAEA,WAAKK,SAAL,GAAiBtB,SAASyB,aAAT,CAAuBV,GAAvB,CAAjB;;AAEA,UAAI,KAAKJ,SAAT,EAAoB;AAChB,aAAKW,SAAL,CAAeC,YAAf,CAA4B,YAA5B,EAA0C,EAA1C;AACH;;AAED,WAAKD,SAAL,CAAeC,YAAf,CAA4B,OAA5B,EAAqC,KAAKhB,KAA1C;AAEA,WAAKe,SAAL,CAAerB,gBAAf,CAAgC,MAAhC,EAAwC,UAACyB,IAAD,EAAU;AAC9CC,gBAAQC,GAAR,CAAY,QAAZ,EAAsBF,IAAtB;AACH,OAFD;AAIA,WAAKJ,SAAL,CAAerB,gBAAf,CAAgC,OAAhC,EAAyC,UAAC4B,GAAD,EAAS;AAC9CF,gBAAQG,KAAR,CAAc,OAAd,EAAuBD,GAAvB;;AAEA,eAAKP,SAAL,CAAeS,UAAf,CAA0BC,WAA1B,CAAsC,OAAKV,SAA3C;;AACA,eAAKA,SAAL,GAAiB,IAAjB;;AACA,eAAKJ,SAAL,CAAee,WAAf,CAA2B,OAAKC,QAAL,CAAcL,IAAIM,MAAlB,CAA3B;AACH,OAND;AAQA,WAAKjB,SAAL,CAAee,WAAf,CAA2B,KAAKX,SAAhC;AACH;;;6BAEQO,G,EAAK;AACV,UAAMO,UAAUpC,SAASyB,aAAT,CAAuB,GAAvB,CAAhB;AACAW,cAAQnB,SAAR,GAAoBY,IAAIQ,KAAJ,CAAUC,KAAV,CAAgB,IAAhB,EAAsBC,IAAtB,CAA2B,OAA3B,CAApB;AACA,aAAOH,OAAP;AACH;;;;;;;AAGE,SAASI,MAAT,CAAgBC,SAAhB,EAA2BC,OAA3B,EAAoC;AACvC,MAAMC,YAAY,IAAIF,SAAJ,EAAlB;AACAE,YAAUC,SAAV,CAAoBF,OAApB;AACH,C;;;;;;;AC3HD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACPA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACXA;AACA;AACA;AACA;AACA;;AAEA,wC;;;;;;;ACNA;AACA;AACA;AACA;AACA;;AAEA,iC;;;;;;;ACNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACnBA;AACA,qEAAsE,mBAAmB,UAAU,EAAE,EAAE;AACvG,CAAC;;;;;;;;ACFD;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;ACNA;;AAEA;AACA,iBAAiB,kBAAkB;AACnC;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA,8B;;;;;;;ACnBA,yC;;;;;;;ACAA;AACA;AACA;AACA;AACA;;;;;;;;ACJA;AACA;AACA,oEAAuE,2CAA4C;;;;;;;;ACFnH;AACA;AACA;AACA;;;;;;;;ACHA;AACA;AACA;AACA;AACA;AACA,yCAAyC;;;;;;;;ACLzC,6BAA6B;AAC7B,uCAAuC;;;;;;;;ACDvC;AACA;AACA,iCAAiC,QAAQ,mBAAmB,UAAU,EAAE,EAAE;AAC1E,CAAC;;;;;;;;ACHD;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,GAAG,YAAY;AACf;AACA;AACA;AACA","file":"main.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 173);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 624a5b2fe611efced739","var global = require('./_global');\nvar core = require('./_core');\nvar ctx = require('./_ctx');\nvar hide = require('./_hide');\nvar PROTOTYPE = 'prototype';\n\nvar $export = function (type, name, source) {\n var IS_FORCED = type & $export.F;\n var IS_GLOBAL = type & $export.G;\n var IS_STATIC = type & $export.S;\n var IS_PROTO = type & $export.P;\n var IS_BIND = type & $export.B;\n var IS_WRAP = type & $export.W;\n var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});\n var expProto = exports[PROTOTYPE];\n var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];\n var key, own, out;\n if (IS_GLOBAL) source = name;\n for (key in source) {\n // contains in native\n own = !IS_FORCED && target && target[key] !== undefined;\n if (own && key in exports) continue;\n // export native or passed\n out = own ? target[key] : source[key];\n // prevent global pollution for namespaces\n exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]\n // bind timers to global for call from export context\n : IS_BIND && own ? ctx(out, global)\n // wrap global constructors for prevent change them in library\n : IS_WRAP && target[key] == out ? (function (C) {\n var F = function (a, b, c) {\n if (this instanceof C) {\n switch (arguments.length) {\n case 0: return new C();\n case 1: return new C(a);\n case 2: return new C(a, b);\n } return new C(a, b, c);\n } return C.apply(this, arguments);\n };\n F[PROTOTYPE] = C[PROTOTYPE];\n return F;\n // make static versions for prototype methods\n })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;\n // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%\n if (IS_PROTO) {\n (exports.virtual || (exports.virtual = {}))[key] = out;\n // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%\n if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);\n }\n }\n};\n// type bitmap\n$export.F = 1; // forced\n$export.G = 2; // global\n$export.S = 4; // static\n$export.P = 8; // proto\n$export.B = 16; // bind\n$export.W = 32; // wrap\n$export.U = 64; // safe\n$export.R = 128; // real proto method for `library`\nmodule.exports = $export;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_export.js\n// module id = 11\n// module chunks = 0 1 2","var dP = require('./_object-dp');\nvar createDesc = require('./_property-desc');\nmodule.exports = require('./_descriptors') ? function (object, key, value) {\n return dP.f(object, key, createDesc(1, value));\n} : function (object, key, value) {\n object[key] = value;\n return object;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_hide.js\n// module id = 12\n// module chunks = 0 1 2","module.exports = function (it) {\n return typeof it === 'object' ? it !== null : typeof it === 'function';\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_is-object.js\n// module id = 13\n// module chunks = 0 1 2","module.exports = function (exec) {\n try {\n return !!exec();\n } catch (e) {\n return true;\n }\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_fails.js\n// module id = 15\n// module chunks = 0 1 2","var isObject = require('./_is-object');\nmodule.exports = function (it) {\n if (!isObject(it)) throw TypeError(it + ' is not an object!');\n return it;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_an-object.js\n// module id = 16\n// module chunks = 0 1 2","import { Application, render } from './application';\n\ndocument.addEventListener('DOMContentLoaded', () => {\n render(Application, document.getElementById('app'));\n});\n\n\n\n// WEBPACK FOOTER //\n// ./src/main.js","export class Application {\n root = null;\n title = 'Web Components';\n container = null;\n errorMode = false;\n loadedApp = null;\n\n bootstrap(root) {\n this.root = root;\n\n this.root.innerHTML = `\n
\n

Hello web-components

\n\n
\n \n \n
\n
\n\n
\n
\n

Separately Running Multiple Apps

\n \n \n
\n \n
\n

Rendering Apps in Same Container

\n\n
\n

Error Mode

\n Disabled\n Enabled\n
\n\n
\n \n \n
\n
\n
\n
\n `;\n\n this.container = this.root.querySelector('.container');\n this.root.addEventListener('keyup', this.handleInputChange);\n this.root.addEventListener('change', this.handleInputChange);\n this.root.addEventListener('click', this.handleButtonClick);\n }\n\n handleInputChange = (event) => {\n if (event.target.id === 'title') {\n this.title = event.target.value;\n this.updateLoadedApp();\n return;\n }\n\n if (event.target.name !== 'errorMode') {\n return false;\n }\n\n this.errorMode = event.target.value === '1';\n\n this.updateLoadedApp();\n };\n\n handleButtonClick = (event) => {\n if (event.target.nodeName !== 'BUTTON') {\n return;\n }\n\n this.loadApp(event.target.dataset.app);\n };\n\n updateLoadedApp() {\n if (this.loadedApp) {\n this.loadedApp.setAttribute('title', this.title);\n\n if (this.errorMode) {\n this.loadedApp.setAttribute('error-mode', '');\n } else {\n this.loadedApp.removeAttribute('error-mode');\n }\n }\n }\n\n loadApp(app) {\n this.container.innerHTML = '';\n\n this.loadedApp = document.createElement(app);\n\n if (this.errorMode) {\n this.loadedApp.setAttribute('error-mode', '');\n }\n\n this.loadedApp.setAttribute('title', this.title);\n\n this.loadedApp.addEventListener('load', (load) => {\n console.log('loaded', load);\n });\n\n this.loadedApp.addEventListener('error', (err) => {\n console.error('error', err);\n\n this.loadedApp.parentNode.removeChild(this.loadedApp);\n this.loadedApp = null;\n this.container.appendChild(this.getError(err.detail));\n });\n\n this.container.appendChild(this.loadedApp);\n }\n\n getError(err) {\n const message = document.createElement('p');\n message.innerHTML = err.stack.split('\\n').join('
');\n return message;\n }\n}\n\nexport function render(Component, element) {\n const component = new Component();\n component.bootstrap(element);\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/application.js","module.exports = function (bitmap, value) {\n return {\n enumerable: !(bitmap & 1),\n configurable: !(bitmap & 2),\n writable: !(bitmap & 4),\n value: value\n };\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_property-desc.js\n// module id = 21\n// module chunks = 0 1 2","// 7.1.1 ToPrimitive(input [, PreferredType])\nvar isObject = require('./_is-object');\n// instead of the ES6 spec version, we didn't implement @@toPrimitive case\n// and the second argument - flag - preferred type is a string\nmodule.exports = function (it, S) {\n if (!isObject(it)) return it;\n var fn, val;\n if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;\n if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;\n if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;\n throw TypeError(\"Can't convert object to primitive value\");\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_to-primitive.js\n// module id = 25\n// module chunks = 0 1 2","function _interopRequireDefault(obj) {\n return obj && obj.__esModule ? obj : {\n default: obj\n };\n}\n\nmodule.exports = _interopRequireDefault;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/helpers/interopRequireDefault.js\n// module id = 29\n// module chunks = 0 1 2","function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\n\nmodule.exports = _classCallCheck;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/helpers/classCallCheck.js\n// module id = 30\n// module chunks = 0 1 2","// optional / simple context binding\nvar aFunction = require('./_a-function');\nmodule.exports = function (fn, that, length) {\n aFunction(fn);\n if (that === undefined) return fn;\n switch (length) {\n case 1: return function (a) {\n return fn.call(that, a);\n };\n case 2: return function (a, b) {\n return fn.call(that, a, b);\n };\n case 3: return function (a, b, c) {\n return fn.call(that, a, b, c);\n };\n }\n return function (/* ...args */) {\n return fn.apply(that, arguments);\n };\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_ctx.js\n// module id = 31\n// module chunks = 0 1 2","module.exports = !require('./_descriptors') && !require('./_fails')(function () {\n return Object.defineProperty(require('./_dom-create')('div'), 'a', { get: function () { return 7; } }).a != 7;\n});\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_ie8-dom-define.js\n// module id = 32\n// module chunks = 0 1 2","var isObject = require('./_is-object');\nvar document = require('./_global').document;\n// typeof document.createElement is 'object' in old IE\nvar is = isObject(document) && isObject(document.createElement);\nmodule.exports = function (it) {\n return is ? document.createElement(it) : {};\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_dom-create.js\n// module id = 33\n// module chunks = 0 1 2","var _Object$defineProperty = require(\"../core-js/object/define-property\");\n\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n\n _Object$defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\n\nmodule.exports = _createClass;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/helpers/createClass.js\n// module id = 49\n// module chunks = 0 1 2","module.exports = require(\"core-js/library/fn/object/define-property\");\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/core-js/object/define-property.js\n// module id = 54\n// module chunks = 0 1 2","require('../../modules/es6.object.define-property');\nvar $Object = require('../../modules/_core').Object;\nmodule.exports = function defineProperty(it, key, desc) {\n return $Object.defineProperty(it, key, desc);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/fn/object/define-property.js\n// module id = 55\n// module chunks = 0 1 2","var $export = require('./_export');\n// 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)\n$export($export.S + $export.F * !require('./_descriptors'), 'Object', { defineProperty: require('./_object-dp').f });\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/es6.object.define-property.js\n// module id = 56\n// module chunks = 0 1 2","module.exports = function (it) {\n if (typeof it != 'function') throw TypeError(it + ' is not a function!');\n return it;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_a-function.js\n// module id = 57\n// module chunks = 0 1 2","// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028\nvar global = module.exports = typeof window != 'undefined' && window.Math == Math\n ? window : typeof self != 'undefined' && self.Math == Math ? self\n // eslint-disable-next-line no-new-func\n : Function('return this')();\nif (typeof __g == 'number') __g = global; // eslint-disable-line no-undef\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_global.js\n// module id = 6\n// module chunks = 0 1 2","var core = module.exports = { version: '2.5.1' };\nif (typeof __e == 'number') __e = core; // eslint-disable-line no-undef\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_core.js\n// module id = 7\n// module chunks = 0 1 2","// Thank's IE8 for his funny defineProperty\nmodule.exports = !require('./_fails')(function () {\n return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;\n});\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_descriptors.js\n// module id = 8\n// module chunks = 0 1 2","var anObject = require('./_an-object');\nvar IE8_DOM_DEFINE = require('./_ie8-dom-define');\nvar toPrimitive = require('./_to-primitive');\nvar dP = Object.defineProperty;\n\nexports.f = require('./_descriptors') ? Object.defineProperty : function defineProperty(O, P, Attributes) {\n anObject(O);\n P = toPrimitive(P, true);\n anObject(Attributes);\n if (IE8_DOM_DEFINE) try {\n return dP(O, P, Attributes);\n } catch (e) { /* empty */ }\n if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');\n if ('value' in Attributes) O[P] = Attributes.value;\n return O;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@babel/runtime/node_modules/core-js/library/modules/_object-dp.js\n// module id = 9\n// module chunks = 0 1 2"],"sourceRoot":""} -------------------------------------------------------------------------------- /dist/polyfills.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | /******/ 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | /******/ 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) { 10 | /******/ return installedModules[moduleId].exports; 11 | /******/ } 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ i: moduleId, 15 | /******/ l: false, 16 | /******/ exports: {} 17 | /******/ }; 18 | /******/ 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | /******/ 22 | /******/ // Flag the module as loaded 23 | /******/ module.l = true; 24 | /******/ 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | /******/ 29 | /******/ 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | /******/ 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | /******/ 36 | /******/ // define getter function for harmony exports 37 | /******/ __webpack_require__.d = function(exports, name, getter) { 38 | /******/ if(!__webpack_require__.o(exports, name)) { 39 | /******/ Object.defineProperty(exports, name, { 40 | /******/ configurable: false, 41 | /******/ enumerable: true, 42 | /******/ get: getter 43 | /******/ }); 44 | /******/ } 45 | /******/ }; 46 | /******/ 47 | /******/ // getDefaultExport function for compatibility with non-harmony modules 48 | /******/ __webpack_require__.n = function(module) { 49 | /******/ var getter = module && module.__esModule ? 50 | /******/ function getDefault() { return module['default']; } : 51 | /******/ function getModuleExports() { return module; }; 52 | /******/ __webpack_require__.d(getter, 'a', getter); 53 | /******/ return getter; 54 | /******/ }; 55 | /******/ 56 | /******/ // Object.prototype.hasOwnProperty.call 57 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 58 | /******/ 59 | /******/ // __webpack_public_path__ 60 | /******/ __webpack_require__.p = ""; 61 | /******/ 62 | /******/ // Load entry module and return exports 63 | /******/ return __webpack_require__(__webpack_require__.s = 170); 64 | /******/ }) 65 | /************************************************************************/ 66 | /******/ ({ 67 | 68 | /***/ 170: 69 | /***/ (function(module, exports, __webpack_require__) { 70 | 71 | "use strict"; 72 | 73 | 74 | __webpack_require__(171); 75 | 76 | __webpack_require__(172); 77 | 78 | /***/ }), 79 | 80 | /***/ 171: 81 | /***/ (function(module, exports) { 82 | 83 | (function () { 84 | 'use strict'; 85 | 86 | (()=>{'use strict';if(!window.customElements)return;const a=window.HTMLElement,b=window.customElements.define,c=window.customElements.get,d=new Map,e=new Map;let f=!1,g=!1;window.HTMLElement=function(){if(!f){const a=d.get(this.constructor),b=c.call(window.customElements,a);g=!0;const e=new b;return e}f=!1;},window.HTMLElement.prototype=a.prototype;Object.defineProperty(window,'customElements',{value:window.customElements,configurable:!0,writable:!0}),Object.defineProperty(window.customElements,'define',{value:(c,h)=>{const i=h.prototype,j=class extends a{constructor(){super(),Object.setPrototypeOf(this,i),g||(f=!0,h.call(this)),g=!1;}},k=j.prototype;j.observedAttributes=h.observedAttributes,k.connectedCallback=i.connectedCallback,k.disconnectedCallback=i.disconnectedCallback,k.attributeChangedCallback=i.attributeChangedCallback,k.adoptedCallback=i.adoptedCallback,d.set(h,c),e.set(c,h),b.call(window.customElements,c,j);},configurable:!0,writable:!0}),Object.defineProperty(window.customElements,'get',{value:(a)=>e.get(a),configurable:!0,writable:!0});})(); 87 | 88 | /** 89 | @license 90 | Copyright (c) 2017 The Polymer Project Authors. All rights reserved. 91 | This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt 92 | The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt 93 | The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt 94 | Code distributed by Google as part of the polymer project is also 95 | subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt 96 | */ 97 | 98 | }()); 99 | 100 | 101 | /***/ }), 102 | 103 | /***/ 172: 104 | /***/ (function(module, exports) { 105 | 106 | (function(){ 107 | 'use strict';var h=new function(){};var aa=new Set("annotation-xml color-profile font-face font-face-src font-face-uri font-face-format font-face-name missing-glyph".split(" "));function n(b){var a=aa.has(b);b=/^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/.test(b);return!a&&b}function p(b){var a=b.isConnected;if(void 0!==a)return a;for(;b&&!(b.__CE_isImportDocument||b instanceof Document);)b=b.parentNode||(window.ShadowRoot&&b instanceof ShadowRoot?b.host:void 0);return!(!b||!(b.__CE_isImportDocument||b instanceof Document))} 108 | function q(b,a){for(;a&&a!==b&&!a.nextSibling;)a=a.parentNode;return a&&a!==b?a.nextSibling:null} 109 | function t(b,a,c){c=c?c:new Set;for(var d=b;d;){if(d.nodeType===Node.ELEMENT_NODE){var e=d;a(e);var f=e.localName;if("link"===f&&"import"===e.getAttribute("rel")){d=e.import;if(d instanceof Node&&!c.has(d))for(c.add(d),d=d.firstChild;d;d=d.nextSibling)t(d,a,c);d=q(b,e);continue}else if("template"===f){d=q(b,e);continue}if(e=e.__CE_shadowRoot)for(e=e.firstChild;e;e=e.nextSibling)t(e,a,c)}d=d.firstChild?d.firstChild:q(b,d)}}function u(b,a,c){b[a]=c};function v(){this.a=new Map;this.o=new Map;this.f=[];this.b=!1}function ba(b,a,c){b.a.set(a,c);b.o.set(c.constructor,c)}function w(b,a){b.b=!0;b.f.push(a)}function x(b,a){b.b&&t(a,function(a){return y(b,a)})}function y(b,a){if(b.b&&!a.__CE_patched){a.__CE_patched=!0;for(var c=0;c{'use strict';if(!window.customElements)return;const a=window.HTMLElement,b=window.customElements.define,c=window.customElements.get,d=new Map,e=new Map;let f=!1,g=!1;window.HTMLElement=function(){if(!f){const a=d.get(this.constructor),b=c.call(window.customElements,a);g=!0;const e=new b;return e}f=!1;},window.HTMLElement.prototype=a.prototype;Object.defineProperty(window,'customElements',{value:window.customElements,configurable:!0,writable:!0}),Object.defineProperty(window.customElements,'define',{value:(c,h)=>{const i=h.prototype,j=class extends a{constructor(){super(),Object.setPrototypeOf(this,i),g||(f=!0,h.call(this)),g=!1;}},k=j.prototype;j.observedAttributes=h.observedAttributes,k.connectedCallback=i.connectedCallback,k.disconnectedCallback=i.disconnectedCallback,k.attributeChangedCallback=i.attributeChangedCallback,k.adoptedCallback=i.adoptedCallback,d.set(h,c),e.set(c,h),b.call(window.customElements,c,j);},configurable:!0,writable:!0}),Object.defineProperty(window.customElements,'get',{value:(a)=>e.get(a),configurable:!0,writable:!0});})();\n\n/**\n@license\nCopyright (c) 2017 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\nThe complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\nThe complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\nCode distributed by Google as part of the polymer project is also\nsubject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*/\n\n}());\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js\n// module id = 171\n// module chunks = 3","(function(){\n'use strict';var h=new function(){};var aa=new Set(\"annotation-xml color-profile font-face font-face-src font-face-uri font-face-format font-face-name missing-glyph\".split(\" \"));function n(b){var a=aa.has(b);b=/^[a-z][.0-9_a-z]*-[\\-.0-9_a-z]*$/.test(b);return!a&&b}function p(b){var a=b.isConnected;if(void 0!==a)return a;for(;b&&!(b.__CE_isImportDocument||b instanceof Document);)b=b.parentNode||(window.ShadowRoot&&b instanceof ShadowRoot?b.host:void 0);return!(!b||!(b.__CE_isImportDocument||b instanceof Document))}\nfunction q(b,a){for(;a&&a!==b&&!a.nextSibling;)a=a.parentNode;return a&&a!==b?a.nextSibling:null}\nfunction t(b,a,c){c=c?c:new Set;for(var d=b;d;){if(d.nodeType===Node.ELEMENT_NODE){var e=d;a(e);var f=e.localName;if(\"link\"===f&&\"import\"===e.getAttribute(\"rel\")){d=e.import;if(d instanceof Node&&!c.has(d))for(c.add(d),d=d.firstChild;d;d=d.nextSibling)t(d,a,c);d=q(b,e);continue}else if(\"template\"===f){d=q(b,e);continue}if(e=e.__CE_shadowRoot)for(e=e.firstChild;e;e=e.nextSibling)t(e,a,c)}d=d.firstChild?d.firstChild:q(b,d)}}function u(b,a,c){b[a]=c};function v(){this.a=new Map;this.o=new Map;this.f=[];this.b=!1}function ba(b,a,c){b.a.set(a,c);b.o.set(c.constructor,c)}function w(b,a){b.b=!0;b.f.push(a)}function x(b,a){b.b&&t(a,function(a){return y(b,a)})}function y(b,a){if(b.b&&!a.__CE_patched){a.__CE_patched=!0;for(var c=0;c 13 |

Hello web-components

14 | 15 |
16 | 17 | 18 |
19 | 20 | 21 |
22 |
23 |

Separately Running Multiple Apps

24 | 25 | 26 |
27 | 28 |
29 |

Rendering Apps in Same Container

30 | 31 |
32 |

Error Mode

33 | Disabled 34 | Enabled 35 |
36 | 37 |
38 | 39 | 40 |
41 |
42 |
43 |
44 | `; 45 | 46 | this.container = this.root.querySelector('.container'); 47 | this.root.addEventListener('keyup', this.handleInputChange); 48 | this.root.addEventListener('change', this.handleInputChange); 49 | this.root.addEventListener('click', this.handleButtonClick); 50 | } 51 | 52 | handleInputChange = (event) => { 53 | if (event.target.id === 'title') { 54 | this.title = event.target.value; 55 | this.updateLoadedApp(); 56 | return; 57 | } 58 | 59 | if (event.target.name !== 'errorMode') { 60 | return false; 61 | } 62 | 63 | this.errorMode = event.target.value === '1'; 64 | 65 | this.updateLoadedApp(); 66 | }; 67 | 68 | handleButtonClick = (event) => { 69 | if (event.target.nodeName !== 'BUTTON') { 70 | return; 71 | } 72 | 73 | this.loadApp(event.target.dataset.app); 74 | }; 75 | 76 | updateLoadedApp() { 77 | if (this.loadedApp) { 78 | this.loadedApp.setAttribute('title', this.title); 79 | 80 | if (this.errorMode) { 81 | this.loadedApp.setAttribute('error-mode', ''); 82 | } else { 83 | this.loadedApp.removeAttribute('error-mode'); 84 | } 85 | } 86 | } 87 | 88 | loadApp(app) { 89 | this.container.innerHTML = ''; 90 | 91 | this.loadedApp = document.createElement(app); 92 | 93 | if (this.errorMode) { 94 | this.loadedApp.setAttribute('error-mode', ''); 95 | } 96 | 97 | this.loadedApp.setAttribute('title', this.title); 98 | 99 | this.loadedApp.addEventListener('load', (load) => { 100 | console.log('loaded', load); 101 | }); 102 | 103 | this.loadedApp.addEventListener('error', (err) => { 104 | console.error('error', err); 105 | 106 | this.loadedApp.parentNode.removeChild(this.loadedApp); 107 | this.loadedApp = null; 108 | this.container.appendChild(this.getError(err.detail)); 109 | }); 110 | 111 | this.container.appendChild(this.loadedApp); 112 | } 113 | 114 | getError(err) { 115 | const message = document.createElement('p'); 116 | message.innerHTML = err.stack.split('\n').join('
'); 117 | return message; 118 | } 119 | } 120 | 121 | export function render(Component, element) { 122 | const component = new Component(); 123 | component.bootstrap(element); 124 | } 125 | -------------------------------------------------------------------------------- /src/components/angular-app.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/components/angular-app/angular-app.js: -------------------------------------------------------------------------------- 1 | import * as angular from 'angular'; 2 | import { AppModule, html } from './app.module'; 3 | 4 | export class AngularApp extends HTMLElement { 5 | static name = 'angular-app'; 6 | 7 | static get observedAttributes() { 8 | return ['error-mode', 'title']; 9 | } 10 | 11 | get title() { 12 | return this.getAttribute('title'); 13 | } 14 | 15 | get errorMode() { 16 | return this.hasAttribute('error-mode'); 17 | } 18 | 19 | set errorMode(val) { 20 | // Reflect the value of the open property as an HTML attribute. 21 | if (val) { 22 | this.setAttribute('error-mode', ''); 23 | } else { 24 | this.removeAttribute('error-mode'); 25 | } 26 | } 27 | 28 | produceError(e) { 29 | this.dispatchEvent(new CustomEvent('error', {detail: e})); 30 | } 31 | 32 | constructor() { 33 | super(); 34 | 35 | console.log('AngularApp constructor', this); 36 | } 37 | 38 | connectedCallback() { 39 | try { 40 | if (this.errorMode) { 41 | throw new Error('Application failed at load'); 42 | } 43 | } catch (e) { 44 | this.produceError(e); 45 | return; 46 | } 47 | 48 | console.log('AngularApp connected'); 49 | 50 | this.innerHTML = html; 51 | 52 | const name = `${AppModule}.instance`; 53 | 54 | // create new module as we attaching `run` callback 55 | angular.module(name, [AppModule]) 56 | .value('config', {title: this.title}) 57 | .run(() => { 58 | console.log(`Angular module ${AppModule} instance is running`); 59 | this.dispatchEvent(new Event('load')); 60 | }); 61 | 62 | this.$injector = angular.bootstrap(this, [name], { 63 | strictDi: true 64 | }); 65 | } 66 | 67 | disconnectedCallback() { 68 | console.log('AngularApp disconnected'); 69 | } 70 | 71 | attributeChangedCallback(attrName, oldVal, newVal) { 72 | console.log('AngularApp attributeChanged', attrName, oldVal, newVal); 73 | 74 | if (!this.$injector) { 75 | return; 76 | } 77 | 78 | switch (attrName) { 79 | case 'title': 80 | const element = angular.element(this); 81 | const config = element.injector().get('config'); 82 | config.title = this.title; 83 | element.scope().$apply(); 84 | return; 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/components/angular-app/app.component.js: -------------------------------------------------------------------------------- 1 | export class AppComponent { 2 | static component = { 3 | template: ` 4 |
5 |

Title: {{ $ctrl.config.title }}

6 |

Greeting: {{ $ctrl.hello }}

7 |
8 | `, 9 | controller: AppComponent, 10 | }; 11 | 12 | static $inject = ['$http', 'config']; 13 | 14 | hello = 'Angular Web Component'; 15 | 16 | constructor($http, config) { 17 | this.$http = $http; 18 | this.config = config; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/components/angular-app/app.module.js: -------------------------------------------------------------------------------- 1 | import * as angular from 'angular'; 2 | import { AppComponent } from './app.component'; 3 | 4 | export const html = ''; 5 | 6 | export const AppModule = angular.module('app', []) 7 | .component('app', AppComponent.component) 8 | .name; 9 | -------------------------------------------------------------------------------- /src/components/angular-app/index.html: -------------------------------------------------------------------------------- 1 | 9 | 10 | -------------------------------------------------------------------------------- /src/components/angular-app/main.js: -------------------------------------------------------------------------------- 1 | import { AngularApp } from './angular-app'; 2 | 3 | window.customElements.define(AngularApp.name, AngularApp); 4 | -------------------------------------------------------------------------------- /src/components/react-app.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/components/react-app/App.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | 3 | export class App extends Component { 4 | state = { 5 | hello: 'React Web Component' 6 | }; 7 | 8 | render() { 9 | return ( 10 |
11 |

Title: {this.props.title}

12 |

Greeting: {this.state.hello}

13 |
14 | ) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/components/react-app/index.html: -------------------------------------------------------------------------------- 1 | 9 | 10 | -------------------------------------------------------------------------------- /src/components/react-app/main.js: -------------------------------------------------------------------------------- 1 | import { ReactApp } from './react-app'; 2 | 3 | window.customElements.define(ReactApp.name, ReactApp); 4 | -------------------------------------------------------------------------------- /src/components/react-app/react-app.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { render } from 'react-dom'; 3 | import { App } from './App'; 4 | 5 | export class ReactApp extends HTMLElement { 6 | static name = 'react-app'; 7 | 8 | static get observedAttributes() { 9 | return ['error-mode', 'title']; 10 | } 11 | 12 | getTitle() { 13 | return this.getAttribute('title'); 14 | } 15 | 16 | get errorMode() { 17 | return this.hasAttribute('error-mode'); 18 | } 19 | 20 | set errorMode(val) { 21 | if (val) { 22 | this.setAttribute('error-mode', ''); 23 | } else { 24 | this.removeAttribute('error-mode'); 25 | } 26 | } 27 | 28 | produceError(e) { 29 | this.dispatchEvent(new CustomEvent('error', {detail: e})); 30 | } 31 | 32 | constructor() { 33 | super(); 34 | 35 | console.log('ReactApp constructor', this); 36 | } 37 | 38 | connectedCallback() { 39 | try { 40 | if (this.errorMode) { 41 | throw new Error('Application failed at load'); 42 | } 43 | } catch (e) { 44 | this.produceError(e); 45 | return; 46 | } 47 | 48 | console.log('ReactApp connected'); 49 | 50 | this.render(); 51 | } 52 | 53 | render() { 54 | render(, this); 55 | } 56 | 57 | disconnectedCallback() { 58 | console.log('ReactApp disconnected',); 59 | } 60 | 61 | attributeChangedCallback(attrName, oldVal, newVal) { 62 | console.log('ReactApp attributeChanged', attrName, oldVal, newVal); 63 | 64 | switch (attrName) { 65 | case 'title': 66 | this.render(); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Web components loader 6 | 7 | 8 | 9 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import { Application, render } from './application'; 2 | 3 | document.addEventListener('DOMContentLoaded', () => { 4 | render(Application, document.getElementById('app')); 5 | }); 6 | -------------------------------------------------------------------------------- /src/polyfills.js: -------------------------------------------------------------------------------- 1 | import '@webcomponents/webcomponentsjs/custom-elements-es5-adapter'; 2 | import '@webcomponents/custom-elements'; 3 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 3 | 4 | module.exports = (env) => { 5 | const prod = env && env.production; 6 | 7 | return { 8 | entry: { 9 | polyfills: root('src/polyfills.js'), 10 | main: root('src/main.js'), 11 | 'components/react-app': root('src/components/react-app/main.js'), 12 | 'components/angular-app': root('src/components/angular-app/main.js'), 13 | }, 14 | output: { 15 | path: root('dist'), 16 | filename: prod ? '[name].[chunkhash].js' : '[name].js', 17 | }, 18 | resolve: { 19 | extensions: ['.js'] 20 | }, 21 | devServer: { 22 | port: 4300, 23 | }, 24 | devtool: 'source-map', 25 | module: { 26 | rules: [ 27 | { 28 | test: /\.js$/, 29 | exclude: /node_modules/, 30 | use: { 31 | loader: 'babel-loader', 32 | options: { 33 | cacheDirectory: true 34 | } 35 | } 36 | } 37 | ] 38 | }, 39 | plugins: [ 40 | new HtmlWebpackPlugin({ 41 | filename: 'index.html', 42 | template: root('src/index.html'), 43 | inject: false, 44 | }), 45 | new HtmlWebpackPlugin({ 46 | chunks: ['components/angular-app'], 47 | filename: 'components/angular-app.html', 48 | template: root('src/components/angular-app/index.html'), 49 | inject: false, 50 | }), 51 | new HtmlWebpackPlugin({ 52 | chunks: ['components/react-app'], 53 | filename: 'components/react-app.html', 54 | template: root('src/components/react-app/index.html'), 55 | inject: false, 56 | }), 57 | ] 58 | }; 59 | }; 60 | 61 | function root(file) { 62 | return path.resolve(__dirname, file); 63 | } 64 | --------------------------------------------------------------------------------