Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ssr): use htmlEscape consistently #5116

Merged
merged 1 commit into from
Jan 9, 2025
Merged

Conversation

nolanlawson
Copy link
Collaborator

Details

For some reason, we had a custom attribute value serializer here rather than using htmlEscape like we do elsewhere. The two functions do the same thing.

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.

@nolanlawson nolanlawson requested a review from a team as a code owner January 8, 2025 23:56
import { mutationTracker } from './mutation-tracker';
import { SYMBOL__GENERATE_MARKUP } from './lightning-element';
import type { LightningElement, LightningElementConstructor } from './lightning-element';
import type { Attributes, Properties } from './types';

const escapeAttrVal = (attrValue: string) =>
attrValue.replaceAll('&', '&').replaceAll('"', '"');

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For comparison:

export function htmlEscape(str: string, attrMode: boolean = false): string {
const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
}

@nolanlawson nolanlawson merged commit f080072 into master Jan 9, 2025
11 checks passed
@nolanlawson nolanlawson deleted the nolan/chore-html-esacpe branch January 9, 2025 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants