don't inject html code in preset names

This commit is contained in:
Martin Raifer
2022-06-24 19:11:00 +02:00
parent 8bb1d39431
commit 209cc23d92
4 changed files with 10 additions and 10 deletions

View File

@@ -36,7 +36,7 @@ export function presetCategory(categoryID, category, allPresets) {
_this.matchScore = () => -1;
_this.name = () => t(`_tagging.presets.categories.${categoryID}.name`, { 'default': categoryID });
_this.nameLabel = () => t.html(`_tagging.presets.categories.${categoryID}.name`, { 'default': categoryID });
_this.nameLabel = () => t.append(`_tagging.presets.categories.${categoryID}.name`, { 'default': categoryID });
_this.terms = () => [];

View File

@@ -94,9 +94,9 @@ export function presetPreset(presetID, preset, addable, allFields, allPresets) {
return t(textID, options);
};
_this.t.html = (scope, options) => {
_this.t.append = (scope, options) => {
const textID = `_tagging.presets.presets.${presetID}.${scope}`;
return t.html(textID, options);
return t.append(textID, options);
};
@@ -104,9 +104,7 @@ export function presetPreset(presetID, preset, addable, allFields, allPresets) {
return _this.t('name', { 'default': _this.originalName });
};
_this.nameLabel = () => {
return _this.t.html('name', { 'default': _this.originalName });
};
_this.nameLabel = () => _this.t.append('name', { 'default': _this.originalName });
_this.subtitle = () => {
if (_this.suggestion) {
@@ -121,7 +119,7 @@ export function presetPreset(presetID, preset, addable, allFields, allPresets) {
if (_this.suggestion) {
let path = presetID.split('/');
path.pop(); // remove brand name
return t.html('_tagging.presets.presets.' + path.join('/') + '.name');
return t.append('_tagging.presets.presets.' + path.join('/') + '.name');
}
return null;
};

View File

@@ -329,7 +329,8 @@ export function uiPresetList(context) {
.attr('class', 'namepart')
.call(svgIcon((localizer.textDirection() === 'rtl' ? '#iD-icon-backward' : '#iD-icon-forward'), 'inline'))
.append('span')
.html(function() { return preset.nameLabel() + '…'; });
.call(preset.nameLabel())
.append('span').text('…');
box = selection.append('div')
.attr('class', 'subgrid')
@@ -402,7 +403,7 @@ export function uiPresetList(context) {
.enter()
.append('div')
.attr('class', 'namepart')
.html(function(d) { return d; });
.each(function(d) { d(d3_select(this)); });
wrap.call(item.reference.button);
selection.call(item.reference.body);

View File

@@ -1,4 +1,5 @@
import { dispatch as d3_dispatch } from 'd3-dispatch';
import { select as d3_select } from 'd3-selection';
import { presetManager } from '../../presets';
import { utilArrayIdentical } from '../../util/array';
@@ -108,7 +109,7 @@ export function uiSectionFeatureType(context) {
.enter()
.append('div')
.attr('class', 'namepart')
.html(function(d) { return d; });
.each(function(d) { return d(d3_select(this)); });
}
section.entityIDs = function(val) {