#103 textContent get issue

master
Agriya Dev5 2021-05-22 18:37:38 +05:30
parent 203af05cd5
commit 7a3c2a0b58
3 changed files with 6 additions and 4 deletions

View File

@ -325,7 +325,8 @@ class LayersPanel {
* @returns {void} * @returns {void}
*/ */
layerRename() { layerRename() {
const oldName = document.querySelector("#layerlist tr.layersel td.layername").textContent; const ele = document.querySelector("#layerlist tr.layersel td.layername");
const oldName = (ele) ? ele.textContent : '';
const newName = prompt(this.editor.i18next.t('notification.enterNewLayerName'), ""); const newName = prompt(this.editor.i18next.t('notification.enterNewLayerName'), "");
if (!newName) { if (!newName) {
return; return;
@ -425,7 +426,8 @@ class LayersPanel {
const elements = $id('layerlist').querySelectorAll("td.layervis"); const elements = $id('layerlist').querySelectorAll("td.layervis");
Array.from(elements).forEach(function(element) { Array.from(elements).forEach(function(element) {
element.addEventListener('click', function(evt) { element.addEventListener('click', function(evt) {
const name = evt.currentTarget.parentNode.querySelector("td.layername").textContent; const ele = evt.currentTarget.parentNode.querySelector("td.layername");
const name = (ele)? ele.textContent : '';
const vis = evt.currentTarget.classList.contains("layerinvis"); const vis = evt.currentTarget.classList.contains("layerinvis");
self.editor.svgCanvas.setLayerVisibility(name, vis); self.editor.svgCanvas.setLayerVisibility(name, vis);
evt.currentTarget.classList.toggle("layerinvis"); evt.currentTarget.classList.toggle("layerinvis");

View File

@ -722,7 +722,7 @@ export const getTextMethod = function () {
const selectedElements = elemContext_.getSelectedElements(); const selectedElements = elemContext_.getSelectedElements();
const selected = selectedElements[0]; const selected = selectedElements[0];
if (isNullish(selected)) { return ''; } if (isNullish(selected)) { return ''; }
return selected.textContent; return (selected) ? selected.textContent : '';
}; };
/** /**

View File

@ -294,7 +294,7 @@ export class ChangeElementCommand extends Command {
this.oldValues = attrs; this.oldValues = attrs;
for (const attr in attrs) { for (const attr in attrs) {
if (attr === '#text') { if (attr === '#text') {
this.newValues[attr] = elem.textContent; this.newValues[attr] = (elem) ? elem.textContent : '';
} else if (attr === '#href') { } else if (attr === '#href') {
this.newValues[attr] = getHref(elem); this.newValues[attr] = getHref(elem);
} else { } else {