fix(ivy): only remove missing placeholders with runtime i18n (#29252)
Dynamic nodes are created at the end of the view stack, but we were removing all the placeholders between `i18nStart` and the last created node index, instead of removing everything between `i18nStart` and `i18nEnd`. This caused errors when dynamic nodes where created in multiple i18n blocks because we would remove all of the dynamic nodes created in the previous i18n blocks. PR Close #29252
This commit is contained in:

committed by
Kara Erickson

parent
e6117a3a49
commit
7315a68ac6
@ -649,16 +649,14 @@ function i18nEndFirstPass(tView: TView) {
|
||||
const tI18n = tView.data[rootIndex + HEADER_OFFSET] as TI18n;
|
||||
ngDevMode && assertDefined(tI18n, `You should call i18nStart before i18nEnd`);
|
||||
|
||||
// The last placeholder that was added before `i18nEnd`
|
||||
const previousOrParentTNode = getPreviousOrParentTNode();
|
||||
const visitedNodes = readCreateOpCodes(rootIndex, tI18n.create, tI18n.icus, viewData);
|
||||
|
||||
// Find the last node that was added before `i18nEnd`
|
||||
let lastCreatedNode = previousOrParentTNode;
|
||||
let lastCreatedNode = getPreviousOrParentTNode();
|
||||
if (lastCreatedNode.child) {
|
||||
lastCreatedNode = findLastNode(lastCreatedNode.child);
|
||||
}
|
||||
|
||||
const visitedNodes = readCreateOpCodes(rootIndex, tI18n.create, tI18n.icus, viewData);
|
||||
|
||||
// Remove deleted nodes
|
||||
for (let i = rootIndex + 1; i <= lastCreatedNode.index - HEADER_OFFSET; i++) {
|
||||
if (visitedNodes.indexOf(i) === -1) {
|
||||
@ -719,7 +717,6 @@ function readCreateOpCodes(
|
||||
currentTNode !,
|
||||
`You need to create or select a node before you can insert it into the DOM`);
|
||||
previousTNode = appendI18nNode(currentTNode !, destinationTNode, previousTNode);
|
||||
destinationTNode.next = null;
|
||||
break;
|
||||
case I18nMutateOpCode.Select:
|
||||
const nodeIndex = opCode >>> I18nMutateOpCode.SHIFT_REF;
|
||||
|
Reference in New Issue
Block a user