-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(cdk/drag-drop): move preview-related logic into a separate c…
…lass Moves the logic for creating and managing the preview into a separate class to make it a bit easier to manage. This new class is internal only.
- Loading branch information
Showing
4 changed files
with
226 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {EmbeddedViewRef} from '@angular/core'; | ||
|
||
/** | ||
* Gets the root HTML element of an embedded view. | ||
* If the root is not an HTML element it gets wrapped in one. | ||
*/ | ||
export function getRootNode(viewRef: EmbeddedViewRef<any>, _document: Document): HTMLElement { | ||
const rootNodes: Node[] = viewRef.rootNodes; | ||
|
||
if (rootNodes.length === 1 && rootNodes[0].nodeType === _document.ELEMENT_NODE) { | ||
return rootNodes[0] as HTMLElement; | ||
} | ||
|
||
const wrapper = _document.createElement('div'); | ||
rootNodes.forEach(node => wrapper.appendChild(node)); | ||
return wrapper; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.