Explorar o código

fix(InstrumentReader): fix null error in readTempoInstruction

also small refactor (above)
sschmid %!s(int64=4) %!d(string=hai) anos
pai
achega
f4867be182
Modificáronse 1 ficheiros con 2 adicións e 3 borrados
  1. 2 3
      src/MusicalScore/ScoreIO/InstrumentReader.ts

+ 2 - 3
src/MusicalScore/ScoreIO/InstrumentReader.ts

@@ -154,8 +154,7 @@ export class InstrumentReader {
           }
         } else if (xmlNode.name === "note") {
           let printObject: boolean = true;
-          if (xmlNode.hasAttributes && xmlNode.attribute("print-object") &&
-              xmlNode.attribute("print-object").value === "no") {
+          if (xmlNode.attribute("print-object")?.value === "no") {
               printObject = false; // note will not be rendered, but still parsed for Playback etc.
               // if (xmlNode.attribute("print-spacing")) {
               //   if (xmlNode.attribute("print-spacing").value === "yes" {
@@ -556,7 +555,7 @@ export class InstrumentReader {
         } else if (xmlNode.name === "sound") {
           // (*) MetronomeReader.readTempoInstruction(xmlNode, this.musicSheet, this.currentXmlMeasureIndex);
           try {
-            if (xmlNode.hasAttributes && xmlNode.attribute("tempo") !== undefined) {
+            if (xmlNode.attribute("tempo")) { // can be null, not just undefined!
 
                 const tempo: number = parseFloat(xmlNode.attribute("tempo").value);