Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1435,8 +1435,13 @@ export function applyViewTransitionName(
className: ?string,
): void {
instance = ((instance: any): HTMLElement);
// If the name isn't valid CSS identifier, base64 encode the name instead.
// This doesn't let you select it in custom CSS selectors but it does work in current
// browsers.
const escapedName =
CSS.escape(name) !== name ? 'r-' + btoa(name).replace(/=/g, '') : name;
// $FlowFixMe[prop-missing]
instance.style.viewTransitionName = name;
instance.style.viewTransitionName = escapedName;
if (className != null) {
// $FlowFixMe[prop-missing]
instance.style.viewTransitionClass = className;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ export function revealCompletedBoundariesWithViewTransitions(
const idPrefix = '';
name = '_' + idPrefix + 'T_' + autoNameIdx++ + '_';
}
elementStyle['viewTransitionName'] = name;
// If the name isn't valid CSS identifier, base64 encode the name instead.
// This doesn't let you select it in custom CSS selectors but it does work in current
// browsers.
const escapedName =
CSS.escape(name) !== name ? 'r-' + btoa(name).replace(/=/g, '') : name;
elementStyle['viewTransitionName'] = escapedName;
shouldStartViewTransition = true;
}
try {
Expand Down
4 changes: 4 additions & 0 deletions scripts/flow/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,3 +644,7 @@ declare module 'rbush' {
fromJSON(data: any): RBush<T>;
}
}

declare class CSS {
static escape(str: string): string;
}
Loading