Skip to content

Commit f080072

Browse files
authored
chore(ssr): use htmlEscape consistently (#5116)
1 parent fb5ef00 commit f080072

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/@lwc/ssr-runtime/src/render.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
* SPDX-License-Identifier: MIT
55
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
66
*/
7-
import { getOwnPropertyNames, isNull, isString, isUndefined, DEFAULT_SSR_MODE } from '@lwc/shared';
7+
import {
8+
getOwnPropertyNames,
9+
isNull,
10+
isString,
11+
isUndefined,
12+
DEFAULT_SSR_MODE,
13+
htmlEscape,
14+
} from '@lwc/shared';
815
import { mutationTracker } from './mutation-tracker';
916
import { SYMBOL__GENERATE_MARKUP } from './lightning-element';
1017
import type { LightningElement, LightningElementConstructor } from './lightning-element';
1118
import type { Attributes, Properties } from './types';
1219

13-
const escapeAttrVal = (attrValue: string) =>
14-
attrValue.replaceAll('&', '&').replaceAll('"', '"');
15-
1620
function renderAttrsPrivate(
1721
instance: LightningElement,
1822
attrs: Attributes,
@@ -58,7 +62,8 @@ function renderAttrsPrivate(
5862
}
5963
}
6064

61-
result += attrValue === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrValue)}"`;
65+
result +=
66+
attrValue === '' ? ` ${attrName}` : ` ${attrName}="${htmlEscape(attrValue, true)}"`;
6267
}
6368

6469
// If we didn't render any `class` attribute, render one for the scope token(s)

0 commit comments

Comments
 (0)