From d49c7a3adb19b6f9a834135741572331702f23a8 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 11 May 2018 14:05:52 +0100 Subject: [PATCH] Avoid unnecessary use of .html() where .text() will do --- editor/js/ui/diff.js | 30 ++++++------- editor/js/ui/editor.js | 12 +++--- editor/js/ui/notifications.js | 4 +- editor/js/ui/palette-editor.js | 54 ++++++++++++------------ editor/js/ui/projects/projectSettings.js | 4 +- editor/js/ui/search.js | 10 ++--- editor/js/ui/subflow.js | 4 +- editor/js/ui/tab-info.js | 18 ++++---- editor/js/ui/tray.js | 2 +- editor/js/ui/typeSearch.js | 2 +- editor/js/ui/utils.js | 18 ++++---- editor/js/ui/workspaces.js | 10 ++--- 12 files changed, 85 insertions(+), 83 deletions(-) diff --git a/editor/js/ui/diff.js b/editor/js/ui/diff.js index 5a1ceea7f..4a305eb6c 100644 --- a/editor/js/ui/diff.js +++ b/editor/js/ui/diff.js @@ -51,11 +51,11 @@ RED.diff = (function() { var tabForLabel = (object.newTab || object.tab).n; var titleSpan = $('',{class:"node-diff-tab-title-meta"}).appendTo(originalCell); if (tabForLabel.type === 'tab') { - titleSpan.html(tabForLabel.label||tabForLabel.id); + titleSpan.text(tabForLabel.label||tabForLabel.id); } else if (tab.type === 'subflow') { - titleSpan.html((tabForLabel.name||tabForLabel.id)); + titleSpan.text((tabForLabel.name||tabForLabel.id)); } else { - titleSpan.html(RED._("diff.globalNodes")); + titleSpan.text(RED._("diff.globalNodes")); } var flowStats = { local: { @@ -131,7 +131,7 @@ RED.diff = (function() { } } $('').appendTo(originalNodeDiv); - $('').html(RED._("diff.flowProperties")).appendTo(originalNodeDiv); + $('').text(RED._("diff.flowProperties")).appendTo(originalNodeDiv); row.click(function(evt) { evt.preventDefault(); @@ -206,7 +206,7 @@ RED.diff = (function() { } } var localStats = $('',{class:"node-diff-tab-stats"}).appendTo(localCell); - $('').html(RED._('diff.nodeCount',{count:localNodeCount})).appendTo(localStats); + $('').text(RED._('diff.nodeCount',{count:localNodeCount})).appendTo(localStats); if (flowStats.conflicts + flowStats.local.addedCount + flowStats.local.changedCount + flowStats.local.deletedCount > 0) { $(' [ ').appendTo(localStats); @@ -245,7 +245,7 @@ RED.diff = (function() { } } var remoteStats = $('',{class:"node-diff-tab-stats"}).appendTo(remoteCell); - $('').html(RED._('diff.nodeCount',{count:remoteNodeCount})).appendTo(remoteStats); + $('').text(RED._('diff.nodeCount',{count:remoteNodeCount})).appendTo(remoteStats); if (flowStats.conflicts + flowStats.remote.addedCount + flowStats.remote.changedCount + flowStats.remote.deletedCount > 0) { $(' [ ').appendTo(remoteStats); if (flowStats.conflicts > 0) { @@ -464,7 +464,7 @@ RED.diff = (function() { wires.forEach(function(p,i) { var port = $("
  • ").appendTo(list); if (p && p.length > 0) { - $("").html(i+1).appendTo(port); + $("").text(i+1).appendTo(port); var links = $("
      ").appendTo(port); p.forEach(function(d) { c++; @@ -474,15 +474,15 @@ RED.diff = (function() { var def = RED.nodes.getType(node.type)||{}; createNode(node,def).appendTo(entry); } else { - entry.html(d); + entry.text(d); } }) } else { - port.html('none'); + port.text('none'); } }) if (c === 0) { - result.html("none"); + result.text("none"); } else { list.appendTo(result); } @@ -507,7 +507,7 @@ RED.diff = (function() { createNodeIcon(node,def).appendTo(nodeTitleDiv); var contentDiv = $('
      ',{class:"node-diff-node-description"}).appendTo(nodeTitleDiv); var nodeLabel = node.label || node.name || node.id; - $('',{class:"node-diff-node-label"}).html(nodeLabel).appendTo(contentDiv); + $('',{class:"node-diff-node-label"}).text(nodeLabel).appendTo(contentDiv); return nodeTitleDiv; } function createNodeDiffRow(node,stats,CurrentDiff) { @@ -739,7 +739,7 @@ RED.diff = (function() { var status; row = $("").appendTo(nodePropertiesTableBody); - $("",{class:"node-diff-property-cell-label"}).html("id").appendTo(row); + $("",{class:"node-diff-property-cell-label"}).text("id").appendTo(row); localCell = $("",{class:"node-diff-property-cell node-diff-node-local"}).appendTo(row); if (localNode) { localCell.addClass("node-diff-node-unchanged"); @@ -782,7 +782,7 @@ RED.diff = (function() { conflict = true; } row = $("").appendTo(nodePropertiesTableBody); - $("",{class:"node-diff-property-cell-label"}).html("position").appendTo(row); + $("",{class:"node-diff-property-cell-label"}).text("position").appendTo(row); localCell = $("",{class:"node-diff-property-cell node-diff-node-local"}).appendTo(row); if (localNode) { localCell.addClass("node-diff-node-"+(localChanged?"changed":"unchanged")); @@ -850,7 +850,7 @@ RED.diff = (function() { conflict = true; } row = $("").appendTo(nodePropertiesTableBody); - $("",{class:"node-diff-property-cell-label"}).html("wires").appendTo(row); + $("",{class:"node-diff-property-cell-label"}).text("wires").appendTo(row); localCell = $("",{class:"node-diff-property-cell node-diff-node-local"}).appendTo(row); if (localNode) { if (!conflict) { @@ -917,7 +917,7 @@ RED.diff = (function() { } row = $("").appendTo(nodePropertiesTableBody); - var propertyNameCell = $("",{class:"node-diff-property-cell-label"}).html(d).appendTo(row); + var propertyNameCell = $("",{class:"node-diff-property-cell-label"}).text(d).appendTo(row); localCell = $("",{class:"node-diff-property-cell node-diff-node-local"}).appendTo(row); if (localNode) { if (!conflict) { diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index e767283bc..df50db725 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -660,7 +660,7 @@ RED.editor = (function() { return A.i-B.i; }) rows.forEach(function(r,i) { - r.r.find("label").html((i+1)+"."); + r.r.find("label").text((i+1)+"."); r.r.appendTo(outputsDiv); }) if (rows.length === 0) { @@ -696,12 +696,12 @@ RED.editor = (function() { function buildLabelRow(type, index, value, placeHolder) { var result = $('
      ',{class:"node-label-form-row"}); if (type === undefined) { - $('').html(RED._("editor.noDefaultLabel")).appendTo(result); + $('').text(RED._("editor.noDefaultLabel")).appendTo(result); result.addClass("node-label-form-none"); } else { result.addClass(""); var id = "node-label-form-"+type+"-"+index; - $('