-
Notifications
You must be signed in to change notification settings - Fork 78
Make attribute localization "pull" rather than "push" #205
Copy link
Copy link
Open
Labels
Description
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:
fluent.js/fluent-dom/src/localization.js
Lines 213 to 221 in 5786bf9
| 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}); | |
| } | |
| } | |
| } |
Reactions are currently unavailable