-
Notifications
You must be signed in to change notification settings - Fork 6k
[web] retrieve hostElement for an implicit view #53296
Changes from all commits
98f0685
adb379b
e48806c
cdb4678
812a40e
b22fcf1
6045c9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -99,6 +99,11 @@ class FlutterViewManager { | |||||
return _jsViewOptions[viewId]; | ||||||
} | ||||||
|
||||||
/// Returns the DOM element in which the Flutter view associated to [viewId] is embedded. | ||||||
DomElement? getHostElement(int viewId) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a clear definition of "host element"? If not, then the docs seem recursive. The name
The docs should explain which one this function returns. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd expect the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is what we have for engine/lib/web_ui/lib/src/engine/view_embedder/embedding_strategy/embedding_strategy.dart Lines 29 to 30 in 928d34f
Also in the Flutter docs:
I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doc in the code can be more specific though. How about updating doc for the /// The dom element in which the Flutter view is embedded.
/// This element is the direct parent element of the <flutter-view> element. And then for the current function just leave it like this: /// Returns the dom element in which the Flutter view associated to [viewId] is embedded (if any). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @p-mazhnik is the "(if any)" true? I think there's always a "parent element of the flutter view" (unless viewId is wrong) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I meant that there might not be a Flutter view associated with the provided
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The revised doc comment is clearer. Thank you! However, it is more important to get the docs right in |
||||||
return _viewData[viewId]?.embeddingStrategy.hostElement; | ||||||
} | ||||||
|
||||||
EngineFlutterView? findViewForElement(DomElement? element) { | ||||||
const String viewRootSelector = | ||||||
'${DomManager.flutterViewTagName}[${GlobalHtmlAttributes.flutterViewIdAttributeName}]'; | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,13 +17,19 @@ class FlutterViewManagerProxy { | |
// The proxied viewManager instance. | ||
final FlutterViewManager _viewManager; | ||
|
||
/// Returns the `hostElement` configuration value passed from JS when `viewId` was added. | ||
/// Returns the host element for [viewId]. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add one empty line between paragraphs. |
||
/// | ||
/// In the full-page mode, the host element is the `<body>` element of the page | ||
/// and the view is the one and only [PlatformDispatcher.implicitView]. | ||
/// | ||
/// In the add-to-app mode, the host element is the value of `hostElement` | ||
/// provided when creating the view. | ||
/// | ||
/// This is useful for plugins and apps to have a safe DOM Element where they | ||
/// can add their own custom HTML elements (for example: file inputs for the | ||
/// file_selector plugin). | ||
JSAny? getHostElement(int viewId) { | ||
return _viewManager.getOptions(viewId)?.hostElement as JSAny?; | ||
return _viewManager.getHostElement(viewId) as JSAny?; | ||
} | ||
|
||
/// Returns the `initialData` configuration value passed from JS when `viewId` was added. | ||
|
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.
This method could use a bit of
/// Documentation
.