Skip to content

[Story] Only run amp-story.rewriteStyles_() when needed #36660

@gmajoulet

Description

@gmajoulet

Description

amp-story.rewriteStyles_() does not need to run in non one-panel-desktop contexts.

/**
* @param {!Element} styleEl
* @private
*/
rewriteStyles_(styleEl) {
// TODO(#15955): Update this to use CssContext from
// ../../../extensions/amp-animation/0.1/web-animations.js
this.mutateElement(() => {
styleEl.textContent = styleEl.textContent
.replace(/(-?[\d.]+)vh/gim, 'calc($1 * var(--story-page-vh))')
.replace(/(-?[\d.]+)vw/gim, 'calc($1 * var(--story-page-vw))')
.replace(/(-?[\d.]+)vmin/gim, 'calc($1 * var(--story-page-vmin))')
.replace(/(-?[\d.]+)vmax/gim, 'calc($1 * var(--story-page-vmax))');
});
}

cc @ampproject/wg-stories @Gregable

Alternatives Considered

Additional Context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions