Coder Social home page Coder Social logo

Comments (5)

joshuaballoch avatar joshuaballoch commented on June 22, 2024

@geekdave I created some tests to show what I mean (I've never used jasmine before, so apologies if they're not well written). I created them on a fork at https://github.com/joshuaballoch/backbone.subroute/blob/polluted-routes/spec/js/route-pollution-specs.js

I ran the tests; if you comment out the second test at https://github.com/joshuaballoch/backbone.subroute/blob/polluted-routes/spec/js/route-pollution-specs.js#L14 and just run https://github.com/joshuaballoch/backbone.subroute/blob/polluted-routes/spec/js/route-pollution-specs.js#L9, then you see the routes being initialized as expected.

Subsequently, if you run https://github.com/joshuaballoch/backbone.subroute/blob/polluted-routes/spec/js/route-pollution-specs.js#L14, you will perhaps see in more detail what I mean.

from backbone.subroute.

geekdave avatar geekdave commented on June 22, 2024

Looks like this may be a regression caused by #22 caused by #16. I am looking into it.

In the meantime, to unblock yourself, you can use v0.3.2 which does not have this issue:
https://github.com/ModelN/backbone.subroute/blob/0.3.2/backbone.subroute.js

Note that in your test spec:

    var subRouter = Backbone.SubRoute.extend( {
        routes: {
            "":"handDefaultRoute"
        }
    } );

    it ( 'should have normal subroutes if just one subroute is initialized', function () {
        SubRouterOne = new subRouter("subrouterone");
        expect(SubRouterOne.routes).toEqual( { '' : 'handDefaultRoute', subrouterone : 'handDefaultRoute' } );
    } );

The it block should not expect { '' : 'handDefaultRoute', subrouterone : 'handDefaultRoute' } but rather { "subrouterone" : 'handDefaultRoute' }

This is because the default empty string route should get the prefix prepended to it.

from backbone.subroute.

geekdave avatar geekdave commented on June 22, 2024

Specifically, this seems to be caused by some change in PR #23 PR #16.

EDIT: Mistakenly attributed the regression to the wrong change. Appears to be due to the switch to using dynamic runtime processing of prefixed routes, instead of constructing the routes only at initialization time.

from backbone.subroute.

geekdave avatar geekdave commented on June 22, 2024

Fixed. Big thanks to @mikesnare for suggesting the fix, and for @joshuaballoch for providing the specs to identify the issue (merged in PR #28)

from backbone.subroute.

geekdave avatar geekdave commented on June 22, 2024

Released version 0.4.1 with this fix (https://github.com/ModelN/backbone.subroute/releases/tag/0.4.1)

from backbone.subroute.

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.