Skip to content

Commit 261495d

Browse files
committed
Update initializer to remove the markers and anything in between
1 parent 4a7471c commit 261495d

3 files changed

Lines changed: 30 additions & 11 deletions

File tree

addon/instance-initializers/clear-double-boot.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// When using `ember serve` when fastboot addon is installed the application
2-
// output will already be rendered to the DOM when the actual JavaScript
3-
// loads. Ember does not automatically clear its `rootElement` so this
4-
// leads to the "double" applications being visible at once (only the
1+
// When using `ember serve` when fastboot addon is installed the application
2+
// output will already be rendered to the DOM when the actual JavaScript
3+
// loads. Ember does not automatically clear its `rootElement` so this
4+
// leads to the "double" applications being visible at once (only the
55
// "bottom" one is running via JS and is interactive).
66
//
77
// This removes any pre-rendered ember-view elements, so that the booting
@@ -15,12 +15,18 @@ export default {
1515
var originalDidCreateRootView = instance.didCreateRootView;
1616

1717
instance.didCreateRootView = function() {
18-
let elements = document.querySelectorAll(instance.rootElement + ' .ember-view');
19-
for (let i = 0; i < elements.length; i++) {
20-
let element = elements[i];
21-
element.parentNode.removeChild(element);
18+
let current = document.getElementById('fastboot-body-start');
19+
if (current) {
20+
let endMarker = document.getElementById('fastboot-body-end');
21+
let parent = current.parentElement;
22+
let nextNode;
23+
do {
24+
nextNode = current.nextSibling;
25+
parent.removeChild(current);
26+
current = nextNode;
27+
} while(nextNode && nextNode !== endMarker);
28+
parent.removeChild(endMarker);
2229
}
23-
2430
originalDidCreateRootView.apply(instance, arguments);
2531
};
2632
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"ember-cli-lodash-subset": "2.0.1",
3030
"ember-cli-version-checker": "^2.1.0",
3131
"ember-cli-preprocess-registry": "^3.1.0",
32-
"fastboot": "git+https://[email protected]/ember-fastboot/fastboot.git#f17668a7bbb57f8f45acd279b704de9ba716f39c",
32+
"fastboot": "^1.1.3",
3333
"fastboot-express-middleware": "^1.1.0",
3434
"fastboot-transform": "^0.1.2",
3535
"fs-extra": "^4.0.2",

yarn.lock

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2904,7 +2904,7 @@ fastboot-transform@^0.1.2:
29042904
dependencies:
29052905
broccoli-stew "^1.5.0"
29062906

2907-
fastboot@^1.1.2, "fastboot@git+https://[email protected]/ember-fastboot/fastboot.git#f17668a7bbb57f8f45acd279b704de9ba716f39c":
2907+
fastboot@^1.1.2:
29082908
version "1.1.2"
29092909
resolved "git+https://[email protected]/ember-fastboot/fastboot.git#f17668a7bbb57f8f45acd279b704de9ba716f39c"
29102910
dependencies:
@@ -2917,6 +2917,19 @@ fastboot@^1.1.2, "fastboot@git+https://[email protected]/ember-fastboot/fastboot.gi
29172917
simple-dom "^1.0.0"
29182918
source-map-support "^0.5.0"
29192919

2920+
fastboot@^1.1.3:
2921+
version "1.1.3"
2922+
resolved "https://registry.yarnpkg.com/fastboot/-/fastboot-1.1.3.tgz#56c5f56415c5ae8de2db539c0d3ecbcd65538f8b"
2923+
dependencies:
2924+
chalk "^2.0.1"
2925+
cookie "^0.3.1"
2926+
debug "^3.0.0"
2927+
exists-sync "0.0.4"
2928+
najax "^1.0.2"
2929+
rsvp "^4.7.0"
2930+
simple-dom "^1.0.0"
2931+
source-map-support "^0.5.0"
2932+
29202933
faye-websocket@~0.10.0:
29212934
version "0.10.0"
29222935
resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4"

0 commit comments

Comments
 (0)