Code Monkey home page Code Monkey logo

Comments (14)

justinbmeyer avatar justinbmeyer commented on May 30, 2024

Keys passed into replaceStateOnce will bee stored in replaceStateOnceKeys.

bee

from can-route-pushstate.

justinbmeyer avatar justinbmeyer commented on May 30, 2024

Used in can-route for building regular expressions to match routes.

It is?

from can-route-pushstate.

justinbmeyer avatar justinbmeyer commented on May 30, 2024

DISPATCHHANDLERS

Updates this._value to the current url. PushstateObservable inherits from SimpleObservable which is using the can-event-queue/value/value mixin.

Why is inheritance relevant here? Maybe you are trying to talk about can.dispatch. That's not clear from the language.

Updating the value is really only part of this function. The other important bit is that it dispatches event handlers on the object.

This should also talk about why this function would be called ... (as a result of calling history.pushstate)

Btw, I think this was supposed to cache can.dispatch symbol.

from can-route-pushstate.

justinbmeyer avatar justinbmeyer commented on May 30, 2024

var linksHost = node.host || window.location.host;

I would generally put this code closer to where it matters ...

if (window.location.host === linksHost) {

from can-route-pushstate.

justinbmeyer avatar justinbmeyer commented on May 30, 2024

Test if you can preventDefault

Why might .preventDefault() not be there?

If you don't know ... write nothing ...

from can-route-pushstate.

justinbmeyer avatar justinbmeyer commented on May 30, 2024
domEvents.addDelegateListener(document.documentElement, "click", "a", this.anchorClickHandler);

maybe this should be using can-globals/document/document to get the current document ...

Especially since unonbound is doing this:

		var document = getDocument(),
			window = getGlobal();

from can-route-pushstate.

justinbmeyer avatar justinbmeyer commented on May 30, 2024

Initalizes this._value Sets up event listeners to capture click events on elements. Overwrites the history api methods .pushState and .replaceState.

Missing a period?

from can-route-pushstate.

justinbmeyer avatar justinbmeyer commented on May 30, 2024

Adds PushstateObservable to the top of the stack and returns the current url.

What stack?

What this is really doing is making reading PushstateObservables observable by can-observations

from can-route-pushstate.

justinbmeyer avatar justinbmeyer commented on May 30, 2024

calls either pushState or replaceState on the difference in properties between oldProps and newProps.

Make sure all sentences start with Capital and end with a period.

from can-route-pushstate.

justinbmeyer avatar justinbmeyer commented on May 30, 2024

patch.key refers to the mutated property name on newProps.

This doesn't really describe what's going on here. What's basically happening is the old state and the new state are diffed to figure out which keys are changing. Depending if the keys are used in replaceStateKeys or replaceStateOnceKeys, replaceState will be used.

from can-route-pushstate.

justinbmeyer avatar justinbmeyer commented on May 30, 2024

var pushstateObservableProto = {

is this needed?

from can-route-pushstate.

indifferentghost avatar indifferentghost commented on May 30, 2024

There's no other use of "can.dispatch" in the library, I'm not sure why there would be a need to cache it.

I'm not sure I understand:

What this is really doing is making reading PushstateObservables observable by can-observations

The only reason I know of for testing e.preventDefault is browser compatibility, as it wasn't implemented in some older browsers.

The only use I could find for paramsMatcher is in can-route where it's either used to build regex or find substrings. added:

or return url substrings of routes.

from can-route-pushstate.

justinbmeyer avatar justinbmeyer commented on May 30, 2024

@HTMLGhozt It creates a slight performance benefit that probably isn't needed here, but helps in more heavily used code.

The following has to do 4 things:

obj[Symbol.for("thing")]
  1. Lookup Symbol
  2. Lookup .for
  3. Call .for
  4. Lookup the symbol on obj

This has to do 2:

obj[thingSymbol]
  1. Lookup thingSymbol
  2. Lookup the symbol on obj

from can-route-pushstate.

indifferentghost avatar indifferentghost commented on May 30, 2024

#136 updates the documentation and refactors to fix the aforementioned issues.

from can-route-pushstate.

Related Issues (20)

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.