Skip to content

Commit

Permalink
Merge pull request #895 from yuxuan-ctrl/dev
Browse files Browse the repository at this point in the history
fix: fix iframe module incomptible with monaco
  • Loading branch information
bailicangdu authored Sep 18, 2023
2 parents d1a079b + 3f43988 commit f3422ff
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/sandbox/iframe/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ function patchDocumentPrototype (appName: string, microAppWindow: microAppWindow
const rawMicroGetElementsByClassName = microRootDocument.prototype.getElementsByClassName
const rawMicroGetElementsByTagName = microRootDocument.prototype.getElementsByTagName
const rawMicroGetElementsByName = microRootDocument.prototype.getElementsByName
const rawMicroElementFromPoint = microRootDocument.prototype.elementFromPoint
const rawMicroCaretRangeFromPoint = microRootDocument.prototype.caretRangeFromPoint

microRootDocument.prototype.caretRangeFromPoint = function caretRangeFromPoint (
x: number,
y: number,
): Range {
// 这里this指向document才可以获取到子应用的document实例,range才可以被成功生成
const element = rawMicroElementFromPoint.call(document, x, y)
const range = rawMicroCaretRangeFromPoint.call(document, x, y)
updateElementInfo(element, appName)
return range
}

microRootDocument.prototype.createElement = function createElement (
tagName: string,
Expand Down

0 comments on commit f3422ff

Please sign in to comment.