Skip to content

Commit 2385e24

Browse files
committed
fixed bundle
1 parent c98cd28 commit 2385e24

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

packages/mgt-components/src/utils/FluentComponents.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export const registerFluentComponents = (...fluentComponents) => {
99

1010
const registry = {
1111
register(container: any) {
12+
if (!container) {
13+
return;
14+
}
15+
1216
for (const component of fluentComponents) {
1317
component().register(container);
1418
}

packages/mgt/src/bundle/mgt-loader.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* -------------------------------------------------------------------------------------------
66
*/
77

8-
(function() {
8+
(async function () {
99
'use strict';
1010

1111
var rootPath = getScriptPath();
@@ -15,6 +15,8 @@
1515
window.WebComponents = window.WebComponents || {};
1616
window.WebComponents.root = rootPath + 'wc/';
1717

18+
await waitUntilReady();
19+
1820
addScript(rootPath + 'wc/webcomponents-loader.js');
1921
addScript(rootPath + 'mgt.es6.js');
2022
} else {
@@ -48,6 +50,19 @@
4850
return true;
4951
}
5052

53+
function waitUntilReady() {
54+
55+
return new Promise(function (resolve, reject) {
56+
if (document.body) {
57+
resolve();
58+
}
59+
60+
document.addEventListener('DOMContentLoaded', function () {
61+
resolve();
62+
})
63+
});
64+
};
65+
5166
function addScript(src, onload) {
5267
// TODO: support async loading
5368

@@ -58,7 +73,7 @@
5873
// tag.addEventListener("load", onload);
5974
// }
6075

61-
document.write(tag.outerHTML);
62-
// document.head.appendChild(tag);
76+
// document.write(tag.outerHTML);
77+
document.head.appendChild(tag);
6378
}
6479
})();

0 commit comments

Comments
 (0)