Skip to content

Commit

Permalink
Merge pull request hyperaudio#146 from hyperaudio/144-first-word-sele…
Browse files Browse the repository at this point in the history
…ction-bug

fix for hyperaudio#144
  • Loading branch information
maboa authored Feb 8, 2023
2 parents 21e1d31 + a5eaf2c commit be06de2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions js/hyperaudio-lite.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! (C) The Hyperaudio Project. MIT @license: en.wikipedia.org/wiki/MIT_License. */
/*! Version 2.1 */
/*! Version 2.1.1 */

'use strict';

Expand Down Expand Up @@ -360,9 +360,9 @@ class HyperaudioLite {
let fNodeTime;
let fNodeDuration;

if (fNode != null && fNode.getAttribute('data-m') != null) {
// if the selection ends in a space we want the previous element
if(selection.toString().slice(-1) == " ") {
if (fNode !== null && fNode.getAttribute('data-m') !== null) {
// if the selection ends in a space we want the previous element if it exists
if(selection.toString().slice(-1) == " " && fNode.previousElementSibling !== null) {
fNode = fNode.previousElementSibling;
}

Expand Down

0 comments on commit be06de2

Please sign in to comment.