Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for host before .substring #126

Open
davehorner opened this issue Feb 23, 2025 · 0 comments
Open

check for host before .substring #126

davehorner opened this issue Feb 23, 2025 · 0 comments

Comments

@davehorner
Copy link

davehorner commented Feb 23, 2025

I think that substring should be checked. if host is not passed, it shouldn't deref a null. if host isn't passed, it should work right?
using import * as scrawl from "https://unpkg.com/[email protected]";

Exported function (to modules and scrawl object). Use addCanvas to add a Scrawl-canvas canvas element to a web page. The items argument should include

host - the host element, either as the DOM element itself, or some sort of CSS search string, or a Scrawl-canvas Stack entity. If no host is supplied, Scrawl-canvas will add the new canvas element to the DOM document body; in all cases, the new canvas element is appended at the end of the host element (or DOM document)
name - String identifier for the element; will generate a random name for the canvas if no name is supplied.
any other regular Scrawl-canvas Canvas artefact attribute
By default, Scrawl-canvas will setup the new Canvas as the ‘current canvas’, and will add mouse/pointer tracking functionality to it. If no dimensions are supplied then the Canvas will default to 300px wide and 150px high.

export const addCanvas = function (items = Ωempty) {
...
    if (host.substring) {  <-- **YOU USE HOST WITHOUT CHECKING HOST IS NOT NULL**

        temphost = artefact[host];

        if (!temphost && host) {

            host = document.querySelector(host);

            if (host) mygroup = host.id;
        }
        else host = temphost;
    }

    if (host) {  <--- **YOU CHECK FOR HOST HERE.**

        if (host.type === T_STACK) {

            mygroup = host.name;
            position = ABSOLUTE;
            host = host.domElement;
        }
        else if (!isa_dom(host)) host = document.body;
    }
    else host = document.body;
...
};

#127
if (host && host.substring)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant