Skip to content
This repository was archived by the owner on Feb 4, 2018. It is now read-only.
This repository was archived by the owner on Feb 4, 2018. It is now read-only.

Support HTML in querying functions #4

@treshugart

Description

@treshugart

Currently we support HTML in mount() but it'd be nice if this was also supported in all() et al to match that. For example:

mount('<div><span></span></div>').one('<span></span>');

If we do this, the heuristic for seeing if it's a selector or HTML needs to be considered. Upon initial inspection, it seems that you can do something like:

// This would match HTML
query.trim().indexOf('<') === 0

The only downsides, which we can't do anything about other than trimming around the string is whitespace inside of the node, which has to match exactly. This can catch you up if you use template literals:

// Matches because trim()
mount('<div><span></span></div>').one(`
  <span></span>
`);

// Does not match because inner whitespace.
// JSX works because it ignores whitespace.
mount('<div><span></span></div>').one(`
  <span>
  </span>
`);

This would probably just need to be emphasised in the docs when documenting this form of the arguments.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions