Giter Club home page Giter Club logo

simpla-paths's Issues

Investigate perf issues

Very unscientiffic test, but ran Fetch as Google on simplajs.org, and the only thing that rendered was the one bit that isn't using simpla-paths (the footer)

screen shot 2017-12-16 at 4 26 36 pm

Might be worth profiling, and maybe even suggesting to deprecate this in favour of build-time path construction. Or, add a prerender buildstep to simpla-paths, so you can maintain easy clientside path recalculation

Data traversal?

Allow simpla-paths to traverse up/down the tree in attributes, using dot notation inside SIDs/GIDs. Fixes the use-case where markup structure doesn't perfectly match content structure, especially with shared code and complex content models

  • foo.bar to traverse down a tree

  • ..baz to traverse up a tree (additional dot for each level up)

  • Can combine patterns, eg: ..baz.qux

  • Can traverse in both SIDs and GIDs (obvs GIDs can only traverse down, useful for removing unecssary nesting)

  • If the key accessed with traversing doesn’t exist, it is created as per usual

Use Symbols for path prop

Right now we're just setting the path property on any element that has an sid / gid property. This is a risk if the user wants to use these attributes on elements that already have a path property that's used for something else. There's no standard HTML path property, but users could have a custom-element that adds it.

This could be resolved by using a Symbol, rather than a String as the property. This would protect for unknown elements.

From a simpla element's perspective, to keep the regular path property on them, as well as getting the value from simpla-paths, it would have to import the Symbol used by simpla-paths (not much weight given tree-shaking), and pass the value set by paths to it's own path property. e.g.

import { PathSymbol } from 'simpla-paths';

class SimplaText extends HTMLElement {
  set [ PathSymbol ](value) {
    this.path = value;
  }

  get [ PathSymbol ](value) {
    return this.path;
  }
}

A Symbol polyfill would also have to be bundled somewhere, as Symbols aren't supported at all by IE, AFAIK the polyfill is relatively lightweight e.g. are used by SkateJS.

Should fire event on path change

Right now it's impossible to observe path changes on builtins, because simpla-paths doesn't fire any events to let us know when things change.

Should fire a path-changed event originating from the element set that looks something like

{
  detail: {
    path: ...
   }
}

Sanitize basePath

The basePath argument to SimplaPaths.observe() is confusing - intuitively you specify a leading slash, like /base/path, but that results in the following //base/path which is invalid. Likewise I was just guessing whether I should include a trailing slash or not, if I had it would have resulted in /base/path//sid which is also invalid.

I think the fix for this is for observe() just to sanitize whatever it gets in basePath (within limits), particular in regard to leading and trailing slashes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.