Skip to content

Add elementReady-like helper for DOM detections #85

Open
@fregante

Description

Sometimes we want to test whether a page matches before it's done downloading, this can be done by passing a selector to element-ready.

I have 2 ideas:

Static definitions

Instead of being just a function, we can define the detections as a list of constraints like:

- const canUserEditOrg = (url) => isOrganizationProfile() && exists('.pagehead-tabs-item[href$="/settings/profile"]')
+ const canUserEditOrgDefinition = [isOrganizationProfile, '.pagehead-tabs-item[href$="/settings/profile"]']
+ export canUserEditOrg = solveConstraints(canUserEditOrgDefinition);
+ export canUserEditOrgAsync = solveConstraintsAsync(canUserEditOrgDefinition);

But this gets wordy FAST

Duplicate functions

  const canUserEditOrg = (url) => isOrganizationProfile() && exists('.pagehead-tabs-item[href$="/settings/profile"]')
+ const canUserEditOrgAsync = async (url) => isOrganizationProfile() && await existsReady('.pagehead-tabs-item[href$="/settings/profile"]')

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions