-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[webview_flutter_wkwebview] Fixes JSON.stringify() cannot serialize cyclic structures #6274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
6057b1d
a37f7bf
182afac
ee66a4a
a709175
b7a3661
f7ac9bd
ae1a4a2
979d8ee
fd9bbcf
c32dedd
3700600
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -639,11 +639,18 @@ class WebKitWebViewController extends PlatformWebViewController { | |
| const WKUserScript overrideScript = WKUserScript( | ||
| ''' | ||
| function removeCyclicObject() { | ||
|
||
| const objects = new WeakSet(); | ||
| const levelObjects = []; | ||
|
||
| return function (k, v) { | ||
| if (typeof v !== "object" || v === null) { return v; } | ||
| if (objects.has(v)) { return; } | ||
| objects.add(v); | ||
| const currentParentObj = this; | ||
| while ( | ||
| levelObjects.length > 0 && | ||
| levelObjects[levelObjects.length - 1] !== currentParentObj | ||
| ) { | ||
| levelObjects.pop(); | ||
| } | ||
| if (levelObjects.includes(v)) { return; } | ||
| levelObjects.push(v); | ||
| return v; | ||
| }; | ||
| } | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment briefly explaining the approach at a high level so readers don't need to reverse-engineer what is being done here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.