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

Allowing global selectors #32

Closed
3 tasks done
pixelastic opened this issue Jan 5, 2016 · 1 comment
Closed
3 tasks done

Allowing global selectors #32

pixelastic opened this issue Jan 5, 2016 · 1 comment

Comments

@pixelastic
Copy link
Contributor

The selectors we can currently specify are only scoped selectord. It means that, for any given lvlX element, in order to get its lvl{X-1} and lvl{X-2} parents, we have to check the DOM tree.

It works well for correctly crafted HTML, but fails as soon as the hierarchy is not in the HTML DOM order. This happens often when the hierarchy is in a sidebar, while the content is in the main part of the page. With our current scoped selectors, we cannot build such a hierarchy.

We need to allow global selectors, that instead of looking up the DOM tree will simply try to select an element in the page, wherever it is placed.

A possible API would be to allow passing objects to each selectors instead of strings.

{
  "selectors": {
    "lvl0": {
        "selector": "#accordion a.category-title:not(.collapsed)",
        "global": true
    },
    "lvl1": ".content h2",
    "lvl2": ".content h3",
    "lvl3": ".content h4",
    "lvl4": ".content h5",
    "text": ".content p"
  }

We keep retrocompatibility by converting simple strings to objects with a global: false and a selector key.

Checklist

  • Should still allow string based syntax
  • ...as well as an object with global: false as the default
  • if global: true, will use the result of the first match of the selector
@pixelastic pixelastic added this to the v1.1 milestone Jan 5, 2016
@pixelastic pixelastic changed the title Allow selectors to be global Allowing global selectors Jan 5, 2016
This was referenced Jan 5, 2016
@pixelastic pixelastic modified the milestone: v2.0 Jan 5, 2016
@maxiloc maxiloc closed this as completed Jan 11, 2016
@maxiloc
Copy link
Contributor

maxiloc commented Jan 15, 2016

Fixed with #39

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

2 participants