Skip to content

Commit 384dc56

Browse files
committed
fluent-dom: Fix the attribute count check
1 parent dee06b8 commit 384dc56

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

fluent-dom/src/localization.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export default class Localization {
175175
* @param {Array<Error>} errors
176176
* @param {Object} message
177177
* @param {Object} args
178-
* @returns {string}
178+
* @returns {string|null}
179179
* @private
180180
*/
181181
function valueFromBundle(bundle, errors, message, args) {
@@ -212,11 +212,12 @@ function messageFromBundle(bundle, errors, message, args) {
212212
formatted.value = bundle.formatPattern(message.value, args, errors);
213213
}
214214

215-
if (message.attributes) {
216-
formatted.attributes = [];
217-
for (const [name, attr] of Object.entries(message.attributes)) {
218-
const value = bundle.formatPattern(attr, args, errors);
219-
formatted.attributes.push({name, value});
215+
let attrNames = Object.keys(message.attributes);
216+
if (attrNames.length > 0) {
217+
formatted.attributes = new Array(attrNames.length);
218+
for (let [i, name] of attrNames.entries()) {
219+
let value = bundle.formatPattern(message.attributes[name], args, errors);
220+
formatted.attributes[i] = {name, value};
220221
}
221222
}
222223

0 commit comments

Comments
 (0)