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

Is there any plan on moving to Polymer 1.0? #127

Open
devAtPolydeals opened this issue Jun 4, 2015 · 20 comments
Open

Is there any plan on moving to Polymer 1.0? #127

devAtPolydeals opened this issue Jun 4, 2015 · 20 comments

Comments

@devAtPolydeals
Copy link

I am currently on Polymer 0.5 & am planning on moving to Polymer 1.0. I use app-router in my current web app. Do you plan on moving to 1.0 anytime soon?

@antdking
Copy link

antdking commented Jun 6, 2015

works fine, but no animations yet

@timboven
Copy link

timboven commented Jun 8, 2015

Not sure if I'm doing something wrong - but for me it's not working fine.
The simple cases work - but the more advanced ones are not working.

I have a very 'simple' route, very similar to one of the examples in the readme - but with Polymer 1.0 loaded (and working fine):

<app-route path="/badge/:reference">
    <template>
      <span>{{reference}}</span>
    </template>
</app-route>

but 'reference' is not updated with the value I pass in the URL.
Any clue if I'm doing something incorrect or is it definitely due to Polymer 1.0?

@ninthspace
Copy link

Note: if you're using hash-only URLs, Polymer 1.0.0-1.0.3 currently intercepts the hash, breaking routers. See: https://github.com/Polymer/polymer/pull/1780/files for the fix.

@plequang
Copy link
Contributor

Hi,

In order to see how complicated it will be to migrate to Polymer 1.0, I've tried to migrate app-router's functional tests to Polymer 1.0, without changing anything to app-router. This means I've not migrated tests that are using core-animated-pages, or any other core-* elements.

The result is available in the following branch https://github.com/plequang/app-router/tree/polymer-1.0-tests-migration

Migration steps

  • migrate to new <dom-module> element registration
  • Migrate to new properties declarations
  • added <span> around all text content binding
  • removed curly brackets around declarative event handlers
  • this.querySelector('::shadow app-router') is not working anymore. Couldn't get the new Polymer.dom(this).querySelector('app-router') to work either, so used this.$.router instead.

Problems

Polymer <template>

https://erikringsmuth.github.io/app-router/#/databinding/#polymer-template

Because template.createInstance(model) has disappeared, this is not working anymore.

app-router creates instance of templates using document.importNode(template.content, true);, but without binding a model to them.
As appRouter.createModel is not called anymore, data binding events are also not fired.

@timboven : this explains why your example is not working anymore.

Accessing the parent scope

https://erikringsmuth.github.io/app-router/#/databinding/#accessing-the-parent-scope
Is also not working, as templateInstance in elements does not exists anymore.

app-router.init in attachedCallback

Currently app-router.init() method is called in the attachedCallback function (which is a callback from the custom elements specification).
This was causing problems in the test-session.html test.
The first state-change event is fired too early, before the session from <user-session> is bound to to the demo-app element.
In the case of test-session.html, it works when initializing manually the app-router in the demo-app ready() callback.

test-session-global

My understanding of this this is that the <user-session> element in <demo-app> should "publish" it's session property to the inner <user-session> elements in <login-page> and <home-page>.

Databinding has changed a lot in Polymer 1.0, and I was not able to have it work. I'm a bit confused with the one-way/two-way/downward/upward bindings in Polymer 1.0.

domReady

As domReady does not exist anymore, I've used the attached callback, but I'm not sure this is strictly equivalent.

@erikringsmuth
Copy link
Owner

This looks like a great start! In the end we may need to remove features that Polymer 1.0 doesn't support.

To summaries your post:

The test-session-global stuff was to test the two-way bindings in Polymer 0.5. This completely changed for 1.0. I'm not sure what we'll do here yet.

@devAtPolydeals
Copy link
Author

In firefox i get:
TypeError: document.querySelector(...).go is not a function
I only have 1 line of code in my js. This is to take the user to landing page for now
document.querySelector('app-router').go('/landing', {replace: true});
It works fine in chrome though. I don't know if its related to Polymer 1.0..go had always worked for me before in firefox

@erikringsmuth
Copy link
Owner

@devAtPolydeals that may be related to timing around upgrading the custom element. If you try to call document.querySelector('app-router').go(...) before the element is upgraded it will give you a dereference error. If that's the case you might have to manually initialize the router before calling go() https://erikringsmuth.github.io/app-router/#/events#addeventlistener.

@devAtPolydeals
Copy link
Author

You you are right, i moved it under:
''' window.addEventListener('WebComponentsReady', function() { });``` and it was okay!

wonder why chrome didn't catch it?

@plequang
Copy link
Contributor

For info, I've just updated the tests to make them work withFirefox.
Also, I've used webcomponents-lite.js for all the tests, meaning Polymer is using "Shady DOM" instead of "Shadow DOM".

Regarding the automatic initialization of app-router in the attachedCallback function, there is a difference between Chrome and "polyfilled" browser (Firefox/Internet Explorer).

Considering the test-session.html test :

<dom-module id="demo-app">
      <template>
        <!-- bind the session object to demo-app -->
        <user-session session="{{session}}"></user-session>
        <app-router id="router" on-state-change="stateChange">
            [...]

The lifecycle of the elements in Chrome is :

  • demo-app created
  • user-session created
  • user-session ready
  • user-session attached
  • app-router attachedCallback
  • demo-app ready
  • demo-app attached

Whereas in polyfilled browsers :

  • demo-app created
  • user-session created
  • user-session ready
  • demo-app ready
  • demo-app attached
  • user-session attached
  • app-router attachedCallback

This means in Chrome, the app-router.init call in attachedCallback is too early (this callback is called by the browser as soon as the element is added to the DOM), so demo-app is not ready and the session object has not been bound to demo-app.
Whereas it is OK in Firefox.

It is maybe a good practice to always use manual init when using app-router with Polymer 1.0.

@christianbauer
Copy link

I've been staring at this for an hour now and I can't get it to work with 2.6.1 and Polymer 1.0:

<link rel="import" href="bower_components/polymer/polymer.html">

<dom-module id="my-element">
    <template>
        <h1>Router Test</h1>
        <app-router>
            <app-route path="*">
                <template>
                    <h2>OK</h2>
                </template>
            </app-route>
        </app-router>
    </template>
    <script>
        Polymer({
            is: 'my-element'
        });
    </script>
</dom-module>

The inline template isn't rendered. I've tried manual init with the same result.

@Barbayar
Copy link

I'm using Polymer 1.0

      <app-route path="/order/:orderId">
        <template>
          <p>Your order number is {{orderId}}</p>
        </template>
      </app-route>

and, went to the http://localhost:3000/#/order/2, the result is

Your order number is {{orderId}}

@binoculars
Copy link

👍

@sandro-k
Copy link

@Barbayar in Polymer 1.0 <p>Your order number is {{orderId}}</p> is not supported use <p>Your order number is <span>{{orderId}}</span></p>

@pensierinmusica
Copy link

Same as @christianbauer here, inline templating is not rendering at all for me with Chrome and Polymer v 1.0.5

@s-devaney
Copy link

Perhaps the claim "works with Polymer" should be removed as, you know, it doesn't actually work with Polymer properly any more?

@JesterXL
Copy link

JesterXL commented Sep 8, 2015

Same results as @pensierinmusica and @s-devaney. Imports work, but inline templates do not work in Polymer 1.1.

@SPAHI4
Copy link

SPAHI4 commented Oct 16, 2015

So will it be updated to 1.0?

@Compufreak345
Copy link

Any progress here? I currently have to use more-routing and it's really annoying as it does not seem to get any bugfixes...

@sandro-k
Copy link

Have a look at the comment from addyosmani at Polymer/polymer-starter-kit#426 about more-routing..

@Compufreak345
Copy link

Thank you @sandro-k , that's very interesting.

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