Skip to content

svg-injector.js:970 Uncaught TypeError: Cannot read property 'replaceChild' of null #28

@sKopheK

Description

@sKopheK

Hi, when multiple instances of SVGInjector are processing various elements with the same URL, an error upon calling replaceChild() on a null object appears, but the element is inserted properly.

Updated examples/simple.html:

<svg class="icon icon--thumb inject-me" data-src="assets/svg/thumb-up.svg" title="I like it!" alt="thumb" onclick="console.log('clicked');"/>
<svg class="icon icon--thumb test-me" data-src="assets/svg/thumb-up.svg" title="I like it!" alt="thumb" onclick="console.log('clicked');"/>
<svg class="icon icon--thumb fetch-me" data-src="assets/svg/thumb-up.svg" title="I like it!" alt="thumb" onclick="console.log('clicked');"/>

<script src="../src/svg-injector.js"></script>
<script>
    new SVGInjector().inject(document.querySelectorAll('.inject-me'));
    new SVGInjector().inject(document.querySelectorAll('.test-me'));
    new SVGInjector().inject(document.querySelectorAll('.fetch-me'));
</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions