question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update all and nextSibling Error (including solution)

See original GitHub issue

Description of your Issue or Request:

I am getting the nextSibling error on long articles with pictures. Also, I could not select the entire content and change the font size or font family.

steps to reproduce (Add more if necessary):

  1. Write a long article with pictures

  2. Select all content with CTRL + A

  3. Change the font size or font family

What is your Operating System, Browser and Version and Summernote Version you are using:

  1. Operating System: [ ] Microsoft Windows [ ] Apple [x] Linux [ ] All

  2. Browser and Version: [ ] Brave [ ] Chrome [ ] Edge [x] Firefox [ ] Internet Explorer [ ] Opera [ ] Safari [ ] Other (Specify):

  3. Summernote Version, place an x inside the brackets: [ ] BS3 [x] BS4 [ ] Lite [ ] All

screenshot of issue

recording

the solution I have applied

I realized that this feature was not applied to the parts after the picture when all the articles with pictures were selected and tried to change the text properties. I solved the problem by modifying the dom.js file a bit.

function nextPointWithEmptyNode(point, isSkipInnerOffset) {
   let node, offset = 0;

   // if node is empty string node, return current node's sibling.
   if (isEmpty(point.node)) {
     if(point.node === null){
       return null;
     }

     node = point.node.nextSibling;
     offset = 0;

     return {
       node: node,
       offset: offset,
     };
   }

   if (nodeLength(point.node) === point.offset) {
     if (isEditable(point.node)) {
       return null;
     }

     node = point.node.parentNode;
     offset = position(point.node) + 1;

     // if next node is editable ,  return current node's sibling node.
     if (isEditable(node)) {
       node = point.node.nextSibling;
       offset = 0;
     }

   } else if (hasChildren(point.node)) {
     node = point.node.childNodes[point.offset];
     offset = 0;
     if (isEmpty(node)) {
       if (!isEmpty(point.node.nextSibling)) {
         return {
           node: point.node.nextSibling,
           offset: offset,
         };
       }
       return null;
     }
   } else {
     node = point.node;
     offset = isSkipInnerOffset ? nodeLength(point.node) : point.offset + 1;

     if (isEmpty(node)) {
       return null;
     }
   }

   return {
     node: node,
     offset: offset,
   };
 }

nextPointWithEmptyNode function to the above code. After updating it fixed my nextSibling problem.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
DiemenDesigncommented, May 6, 2021

Awesome, thanks for submitting a PR. Once I get time, I’ll get onto testing this out. Not that I doubt that you haven’t done a good job, other devs will also need approve something like this, so I’ll tag them into the PR as well, that way they can check on their systems, pretty sure a couple use Apple, and at this time it seems to be the most problematic, esp. with Safari. I’ll be testing all the browser I can in Linux.

1reaction
fatihgvncommented, May 6, 2021

Yes, I did not encounter any problems during my tests. This works… 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

this.nextSibling not working - Stack Overflow
The nextElementSibling read-only property returns the element immediately following the specified one in its parent's children list, or null if the specified ...
Read more >
Node.nextSibling - Web APIs - MDN Web Docs
The read-only nextSibling property of the Node interface returns the node immediately following the specified one in their parent's childNodes ...
Read more >
HTML | DOM nextSibling Property - GeeksforGeeks
It is a read-only property. Syntax: node.nextSibling. Return value: This property returns a next sibling of the specified node or null if the ......
Read more >
Walking the DOM - The Modern JavaScript Tutorial
The DOM allows us to do anything with elements and their contents, but first we need to reach the corresponding DOM object. All...
Read more >
SAP message FMHIE443 No valid next sibling for new mult
How to fix this error? Change the next sibling definition for the hierarchy node &V3&&V4& (hierarchical part). Procedure for System Administrators. The system ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found