Problem:
GM_addElement(null, "img", { id: "test1", src: "abc.jpg" });
GM_addElement(void 0, "img", { id: "test1", src: "abc.jpg" });
Both lines of code above insert elements and return element objects. But in fact it shouldn't be like that.
Expected result:
when parentNode is null or undefined, it should return null directly, and dosen't insert the element.
As I have feedback in tampermonkey#2729, because if I want to insert an IMG into an element, but don't get the element correctly (it returns null or undefined), the IMG will be inserted into the current document instead of in the specified element, which is an unintended error.
Environment:
- OS: Windows
- Browser: all
- Violentmonkey Version: all
Problem:
Both lines of code above insert elements and return element objects. But in fact it shouldn't be like that.
Expected result:
when
parentNodeisnullorundefined, it should return null directly, and dosen't insert the element.As I have feedback in tampermonkey#2729, because if I want to insert an IMG into an element, but don't get the element correctly (it returns
nullorundefined), the IMG will be inserted into the current document instead of in the specified element, which is an unintended error.Environment: