From df715039e441615ffafd030149c836223c97fd3e Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 9 Jan 2019 18:01:14 -0300 Subject: [PATCH 1/2] Boot components when dom content is loaded --- lib/strategies/mutation_observer.js | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/strategies/mutation_observer.js b/lib/strategies/mutation_observer.js index 296a742..4056ef6 100644 --- a/lib/strategies/mutation_observer.js +++ b/lib/strategies/mutation_observer.js @@ -64,6 +64,11 @@ export function defineElement ( }) observers[name] = true + + window.addEventListener('DOMContentLoaded', () => { + const node = document.querySelector(name); + if (node) checkForMount(node, name, events); + }); } /** diff --git a/package.json b/package.json index 71223ba..7007145 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "remount", "description": "Mount React components to the DOM using custom elements", - "version": "0.9.4", + "version": "0.9.5", "author": "Rico Sta. Cruz ", "bugs": { "url": "https://github.com/rstacruz/remount/issues" From 5780b062832fc6ab25f79ccb64d194264f336e9b Mon Sep 17 00:00:00 2001 From: Paulo Reis Date: Wed, 9 Jan 2019 18:31:58 -0300 Subject: [PATCH 2/2] Change document.querySelector to getElementsByTagName --- lib/strategies/mutation_observer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/strategies/mutation_observer.js b/lib/strategies/mutation_observer.js index 4056ef6..5bfe8ba 100644 --- a/lib/strategies/mutation_observer.js +++ b/lib/strategies/mutation_observer.js @@ -66,8 +66,8 @@ export function defineElement ( observers[name] = true window.addEventListener('DOMContentLoaded', () => { - const node = document.querySelector(name); - if (node) checkForMount(node, name, events); + const nodes = document.getElementsByTagName(name); + [...nodes].forEach(node => checkForMount(node, name, events)) }); }