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

Support HTML in querying functions #4

Open
treshugart opened this issue Nov 25, 2016 · 0 comments
Open

Support HTML in querying functions #4

treshugart opened this issue Nov 25, 2016 · 0 comments

Comments

@treshugart
Copy link
Member

treshugart commented Nov 25, 2016

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.

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

No branches or pull requests

1 participant