node_manipulation.ts (angular-11.0.1) | : | node_manipulation.ts (angular-11.0.2) | ||
---|---|---|---|---|
/** | /** | |||
* @license | * @license | |||
* Copyright Google LLC All Rights Reserved. | * Copyright Google LLC All Rights Reserved. | |||
* | * | |||
* Use of this source code is governed by an MIT-style license that can be | * 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 | * found in the LICENSE file at https://angular.io/license | |||
*/ | */ | |||
import {ViewEncapsulation} from '../metadata/view'; | import {ViewEncapsulation} from '../metadata/view'; | |||
import {Renderer2} from '../render/api'; | import {Renderer2} from '../render/api'; | |||
import {RendererStyleFlags2} from '../render/api_flags'; | ||||
import {addToArray, removeFromArray} from '../util/array_utils'; | import {addToArray, removeFromArray} from '../util/array_utils'; | |||
import {assertDefined, assertDomNode, assertEqual, assertIndexInRange, assertStr | import {assertDefined, assertDomNode, assertEqual, assertString} from '../util/a | |||
ing} from '../util/assert'; | ssert'; | |||
import {assertLContainer, assertLView, assertTNodeForLView} from './assert'; | import {assertLContainer, assertLView, assertTNodeForLView} from './assert'; | |||
import {attachPatchData} from './context_discovery'; | import {attachPatchData} from './context_discovery'; | |||
import {icuContainerIterate} from './i18n/i18n_tree_shaking'; | import {icuContainerIterate} from './i18n/i18n_tree_shaking'; | |||
import {CONTAINER_HEADER_OFFSET, HAS_TRANSPLANTED_VIEWS, LContainer, MOVED_VIEWS , NATIVE, unusedValueExportToPlacateAjd as unused1} from './interfaces/container '; | import {CONTAINER_HEADER_OFFSET, HAS_TRANSPLANTED_VIEWS, LContainer, MOVED_VIEWS , NATIVE, unusedValueExportToPlacateAjd as unused1} from './interfaces/container '; | |||
import {ComponentDef} from './interfaces/definition'; | import {ComponentDef} from './interfaces/definition'; | |||
import {NodeInjectorFactory} from './interfaces/injector'; | import {NodeInjectorFactory} from './interfaces/injector'; | |||
import {TElementNode, TIcuContainerNode, TNode, TNodeFlags, TNodeType, TProjecti onNode, unusedValueExportToPlacateAjd as unused2} from './interfaces/node'; | import {TElementNode, TIcuContainerNode, TNode, TNodeFlags, TNodeType, TProjecti onNode, unusedValueExportToPlacateAjd as unused2} from './interfaces/node'; | |||
import {unusedValueExportToPlacateAjd as unused3} from './interfaces/projection' ; | import {unusedValueExportToPlacateAjd as unused3} from './interfaces/projection' ; | |||
import {isProceduralRenderer, ProceduralRenderer3, RComment, RElement, Renderer3 | import {isProceduralRenderer, ProceduralRenderer3, Renderer3, unusedValueExportT | |||
, RNode, RText, unusedValueExportToPlacateAjd as unused4} from './interfaces/ren | oPlacateAjd as unused4} from './interfaces/renderer'; | |||
derer'; | import {RComment, RElement, RNode, RText} from './interfaces/renderer_dom'; | |||
import {isLContainer, isLView} from './interfaces/type_checks'; | import {isLContainer, isLView} from './interfaces/type_checks'; | |||
import {CHILD_HEAD, CLEANUP, DECLARATION_COMPONENT_VIEW, DECLARATION_LCONTAINER, DestroyHookData, FLAGS, HookData, HookFn, HOST, LView, LViewFlags, NEXT, PARENT , QUERIES, RENDERER, T_HOST, TVIEW, TView, TViewType, unusedValueExportToPlacate Ajd as unused5} from './interfaces/view'; | import {CHILD_HEAD, CLEANUP, DECLARATION_COMPONENT_VIEW, DECLARATION_LCONTAINER, DestroyHookData, FLAGS, HookData, HookFn, HOST, LView, LViewFlags, NEXT, PARENT , QUERIES, RENDERER, T_HOST, TVIEW, TView, TViewType, unusedValueExportToPlacate Ajd as unused5} from './interfaces/view'; | |||
import {assertTNodeType} from './node_assert'; | import {assertTNodeType} from './node_assert'; | |||
import {getLViewParent} from './util/view_traversal_utils'; | import {getLViewParent} from './util/view_traversal_utils'; | |||
import {getNativeByTNode, unwrapRNode, updateTransplantedViewCount} from './util /view_utils'; | import {getNativeByTNode, unwrapRNode, updateTransplantedViewCount} from './util /view_utils'; | |||
const unusedValueToPlacateAjd = unused1 + unused2 + unused3 + unused4 + unused5; | const unusedValueToPlacateAjd = unused1 + unused2 + unused3 + unused4 + unused5; | |||
const enum WalkTNodeTreeAction { | const enum WalkTNodeTreeAction { | |||
/** node create in the native environment. Run on initial creation. */ | /** node create in the native environment. Run on initial creation. */ | |||
skipping to change at line 978 | skipping to change at line 979 | |||
// | // | |||
// If they are we need to process the second anchor as well. | // If they are we need to process the second anchor as well. | |||
applyToElementOrContainer(action, renderer, parentRElement, anchor, beforeNo de); | applyToElementOrContainer(action, renderer, parentRElement, anchor, beforeNo de); | |||
} | } | |||
for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) { | for (let i = CONTAINER_HEADER_OFFSET; i < lContainer.length; i++) { | |||
const lView = lContainer[i] as LView; | const lView = lContainer[i] as LView; | |||
applyView(lView[TVIEW], lView, renderer, action, parentRElement, anchor); | applyView(lView[TVIEW], lView, renderer, action, parentRElement, anchor); | |||
} | } | |||
} | } | |||
// TODO(misko): Can't import RendererStyleFlags2.DashCase as it causes imports t | ||||
o be resolved | ||||
// in different order which causes failures. Duplicating for now. | ||||
const enum TempRendererStyleFlags2 { | ||||
Important = 1 << 0, | ||||
DashCase = 1 << 1 | ||||
} | ||||
/** | /** | |||
* Writes class/style to element. | * Writes class/style to element. | |||
* | * | |||
* @param renderer Renderer to use. | * @param renderer Renderer to use. | |||
* @param isClassBased `true` if it should be written to `class` (`false` to wri te to `style`) | * @param isClassBased `true` if it should be written to `class` (`false` to wri te to `style`) | |||
* @param rNode The Node to write to. | * @param rNode The Node to write to. | |||
* @param prop Property to write to. This would be the class/style name. | * @param prop Property to write to. This would be the class/style name. | |||
* @param value Value to write. If `null`/`undefined`/`false` this is considered a remove (set/add | * @param value Value to write. If `null`/`undefined`/`false` this is considered a remove (set/add | |||
* otherwise). | * otherwise). | |||
*/ | */ | |||
skipping to change at line 1017 | skipping to change at line 1011 | |||
} else { | } else { | |||
ngDevMode && ngDevMode.rendererAddClass++; | ngDevMode && ngDevMode.rendererAddClass++; | |||
if (isProcedural) { | if (isProcedural) { | |||
(renderer as Renderer2).addClass(rNode, prop); | (renderer as Renderer2).addClass(rNode, prop); | |||
} else { | } else { | |||
ngDevMode && assertDefined((rNode as HTMLElement).classList, 'HTMLElemen t expected'); | ngDevMode && assertDefined((rNode as HTMLElement).classList, 'HTMLElemen t expected'); | |||
(rNode as HTMLElement).classList.add(prop); | (rNode as HTMLElement).classList.add(prop); | |||
} | } | |||
} | } | |||
} else { | } else { | |||
let flags = prop.indexOf('-') === -1 ? undefined : TempRendererStyleFlags2.D ashCase as number; | let flags = prop.indexOf('-') === -1 ? undefined : RendererStyleFlags2.DashC ase as number; | |||
if (value == null /** || value === undefined */) { | if (value == null /** || value === undefined */) { | |||
ngDevMode && ngDevMode.rendererRemoveStyle++; | ngDevMode && ngDevMode.rendererRemoveStyle++; | |||
if (isProcedural) { | if (isProcedural) { | |||
(renderer as Renderer2).removeStyle(rNode, prop, flags); | (renderer as Renderer2).removeStyle(rNode, prop, flags); | |||
} else { | } else { | |||
(rNode as HTMLElement).style.removeProperty(prop); | (rNode as HTMLElement).style.removeProperty(prop); | |||
} | } | |||
} else { | } else { | |||
// A value is important if it ends with `!important`. The style | // A value is important if it ends with `!important`. The style | |||
// parser strips any semicolons at the end of the value. | // parser strips any semicolons at the end of the value. | |||
const isImportant = typeof value === 'string' ? value.endsWith('!important ') : false; | const isImportant = typeof value === 'string' ? value.endsWith('!important ') : false; | |||
if (isImportant) { | if (isImportant) { | |||
// !important has to be stripped from the value for it to be valid. | // !important has to be stripped from the value for it to be valid. | |||
value = value.slice(0, -10); | value = value.slice(0, -10); | |||
flags! |= TempRendererStyleFlags2.Important; | flags! |= RendererStyleFlags2.Important; | |||
} | } | |||
ngDevMode && ngDevMode.rendererSetStyle++; | ngDevMode && ngDevMode.rendererSetStyle++; | |||
if (isProcedural) { | if (isProcedural) { | |||
(renderer as Renderer2).setStyle(rNode, prop, value, flags); | (renderer as Renderer2).setStyle(rNode, prop, value, flags); | |||
} else { | } else { | |||
ngDevMode && assertDefined((rNode as HTMLElement).style, 'HTMLElement ex pected'); | ngDevMode && assertDefined((rNode as HTMLElement).style, 'HTMLElement ex pected'); | |||
(rNode as HTMLElement).style.setProperty(prop, value, isImportant ? 'imp ortant' : ''); | (rNode as HTMLElement).style.setProperty(prop, value, isImportant ? 'imp ortant' : ''); | |||
} | } | |||
} | } | |||
End of changes. 6 change blocks. | ||||
16 lines changed or deleted | 8 lines changed or added |