- Refactoring: Avoid redundant creation of text node for strings when passing to `append`

master
Brett Zamir 2020-01-04 16:43:03 +08:00
parent 332a562876
commit 92f8a5be57
3 changed files with 6 additions and 6 deletions

View File

@ -69,19 +69,19 @@ describe('draw.Drawing', function () {
const setupSVGWith3Layers = function (svgElem) {
const layer1 = document.createElementNS(NS.SVG, 'g');
const layer1Title = document.createElementNS(NS.SVG, 'title');
layer1Title.append(document.createTextNode(LAYER1));
layer1Title.append(LAYER1);
layer1.append(layer1Title);
svgElem.append(layer1);
const layer2 = document.createElementNS(NS.SVG, 'g');
const layer2Title = document.createElementNS(NS.SVG, 'title');
layer2Title.append(document.createTextNode(LAYER2));
layer2Title.append(LAYER2);
layer2.append(layer2Title);
svgElem.append(layer2);
const layer3 = document.createElementNS(NS.SVG, 'g');
const layer3Title = document.createElementNS(NS.SVG, 'title');
layer3Title.append(document.createTextNode(LAYER3));
layer3Title.append(LAYER3);
layer3.append(layer3Title);
svgElem.append(layer3);

View File

@ -89,7 +89,7 @@ describe('recalculate', function () {
tspan.setAttribute('x', '200');
tspan.setAttribute('y', '150');
const theText = document.createTextNode('Foo bar');
const theText = 'Foo bar';
tspan.append(theText);
elem.append(tspan);
svg.append(elem);

View File

@ -232,7 +232,7 @@ export default {
$(this).html(
$('<span>').append(
$('<img>').attr('src', curMeta.preview_url),
document.createTextNode(title)
title
)
);
} else {
@ -254,7 +254,7 @@ export default {
if (curMeta && curMeta.preview_url) {
entry = $('<span>').append(
$('<img>').attr('src', curMeta.preview_url),
document.createTextNode(title)
title
);
} else {
entry = $('<img>').attr('src', response);