Skip to content
Snippets Groups Projects
Commit e93b9aa2 authored by Olivier Dony's avatar Olivier Dony
Browse files

[FIX] website: restore CDN for lazy assets


The CDN implementation for resources works by matching well-know attributes
(`href`, `src`, `action`) that hold URLs matching the CDN filters and injects
the CDN prefix. However 13.0 introduced lazy loading for assets in #32181,
so the attributes are now prefixed with `data-` and replaced at runtime.

This PR updates the tag matching in order to cover both variants of
attribute names.

closes odoo/odoo#54156

X-original-commit: 6d4b5fcd
Signed-off-by: default avatarToufik Benjaa (tbe) <tbe@odoo.com>
parent c387ec19
Branches
Tags
No related merge requests found
......@@ -68,9 +68,13 @@ class QWeb(models.AbstractModel):
if not website.cdn_activated:
return atts
if name and name in atts:
data_name = f'data-{name}'
if name and (name in atts or data_name in atts):
atts = OrderedDict(atts)
atts[name] = website.get_cdn_url(atts[name])
if name in atts:
atts[name] = website.get_cdn_url(atts[name])
if data_name in atts:
atts[data_name] = website.get_cdn_url(atts[data_name])
if isinstance(atts.get('style'), str) and 'background-image' in atts['style']:
atts = OrderedDict(atts)
atts['style'] = re_background_image.sub(lambda m: '%s%s' % (m.group(1), website.get_cdn_url(m.group(2))), atts['style'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment