refactor(core): remove cookie and comment testing utilities from DomAdapters (#32278)
PR Close #32278
This commit is contained in:
@ -157,8 +157,8 @@ export function stringifyElement(el: any /** TODO #9100 */): string {
|
||||
if (_selfClosingTags.indexOf(tagName) == -1) {
|
||||
result += `</${tagName}>`;
|
||||
}
|
||||
} else if (getDOM().isCommentNode(el)) {
|
||||
result += `<!--${getDOM().nodeValue(el)}-->`;
|
||||
} else if (isCommentNode(el)) {
|
||||
result += `<!--${el.nodeValue}-->`;
|
||||
} else {
|
||||
result += getDOM().getText(el);
|
||||
}
|
||||
@ -169,3 +169,13 @@ export function stringifyElement(el: any /** TODO #9100 */): string {
|
||||
export function createNgZone(): NgZone {
|
||||
return new NgZone({enableLongStackTrace: true});
|
||||
}
|
||||
|
||||
export function isCommentNode(node: Node): boolean {
|
||||
return node.nodeType === Node.COMMENT_NODE;
|
||||
}
|
||||
|
||||
export function setCookie(name: string, value: string) {
|
||||
// document.cookie is magical, assigning into it assigns/overrides one cookie value, but does
|
||||
// not clear other cookies.
|
||||
document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
import {Type, ɵglobal as global} from '@angular/core';
|
||||
import {ComponentFixture} from '@angular/core/testing';
|
||||
import {By, ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||
import {isCommentNode} from '@angular/platform-browser/testing/src/browser_util';
|
||||
|
||||
|
||||
|
||||
@ -285,7 +286,7 @@ function elementText(n: any): string {
|
||||
return n.map(elementText).join('');
|
||||
}
|
||||
|
||||
if (getDOM().isCommentNode(n)) {
|
||||
if (isCommentNode(n)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user