processing / p5.js

p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. http://twitter.com/p5xjs —
http://p5js.org/
GNU Lesser General Public License v2.1
21.1k stars 3.22k forks source link

Is the index missing in `setName` from `p5.XML`? #7019

Closed IronBlood closed 1 month ago

IronBlood commented 1 month ago

Most appropriate sub-area of p5.js?

p5.js version

No response

Web browser and version

No response

Operating system

No response

Steps to reproduce this

The source code is shown below:

  setName(name) {
    const content = this.DOM.innerHTML;
    const attributes = this.DOM.attributes;
    const xmlDoc = document.implementation.createDocument(null, 'default');
    const newDOM = xmlDoc.createElement(name);
    newDOM.innerHTML = content;
    for (let i = 0; i < attributes.length; i++) {
      newDOM.setAttribute(attributes[i].nodeName, attributes.nodeValue);
    }
    this.DOM = newDOM;
  }

Should it be newDOM.setAttribute(attributes[i].nodeName, attributes[i].nodeValue); instead? This line was introduce from the commit db90f55eb92b2b3f7aada01eb723bd485ca59597.

limzykenneth commented 1 month ago

It looks like the index is indeed missing from the reference to attributes, you can file a PR to fix this if you like.