Skip to content

Make attribute localization "pull" rather than "push" #205

Open
@stasm

Description

@stasm

When localizing DOM elements, we currently try to set all attributes we find defined in the localization. There's a sanitization step which filters attributes missing from the default allowed list or attributes which haven't been explicitly allowed with data-l10n-args.

I think we should double down on this sanitization design and make attribute localization pull rather than push. For any given DOM element, the bindings would only format the known allowed attributes.

This would allow the low-level code in Localization to never have to inspect the inner representation of a message, as it does right now:

if (msg.attrs) {
formatted.attributes = [];
for (const [name, attr] of Object.entries(msg.attrs)) {
const value = ctx.format(attr, args, errors);
if (value !== null) {
formatted.attributes.push({name, value});
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions