Skip to content

Commit

Permalink
fix: 修复了link标签在非head时样式丢失的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
bailicangdu committed Dec 30, 2021
1 parent eea0d55 commit 06cb05b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 0 additions & 3 deletions dev/children/react16/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
</script> -->
<!-- <link rel="stylesheet" href="http://127.0.0.1:8080/test.css" global> -->
<!-- <script defer src="http://127.0.0.1:8080/test.js"></script> -->
<!-- <script>
console.log(6666666, this)
</script> -->
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
6 changes: 5 additions & 1 deletion src/source/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,11 @@ export function fetchLinkSuccess (
styleLink.__MICRO_APP_LINK_PATH__ = url
styleLink.setAttribute('data-origin-href', url)

microAppHead.replaceChild(scopedCSS(styleLink, app), info.placeholder!)
if (info.placeholder!.parentNode) {
info.placeholder!.parentNode.replaceChild(scopedCSS(styleLink, app), info.placeholder!)
} else {
microAppHead.appendChild(scopedCSS(styleLink, app))
}

info.placeholder = null
info.code = data
Expand Down

0 comments on commit 06cb05b

Please sign in to comment.