Giter VIP home page Giter VIP logo

iron-lazy-pages's People

Contributors

abdonrd avatar bedeoverend avatar jpradelle avatar lozandier avatar rictic avatar s-kulikov avatar sandro-k avatar timvdlippe avatar web-padawan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iron-lazy-pages's Issues

Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

I have this error when switching between iron-lazy-page instances:

Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
  • only appears on second load of iron-lazy-page children element
  • related to Polymer upgrade to 1.6.0

An example as here, the file containing iron-lazy-pages is this one.
(try clicking between tabs multiple times).

The row which causes the issue is follow:

document.head.removeChild(e.target || e.srcElement);

Implement dom-if functionality

iron-lazy-pages 2.0 shipped without template support, as it was not a blocker for publishing (Polymer 2 was out for a while already). However, a frequent request is template support for large pages. Thus it would be nice to, instead of shipping a custom implementation, relay to <dom-if>. E.g. if a page is <dom-if> instead, set its value to true and rely on its stamping mechanism to do all the other magic.

async.html:34 Uncaught TypeError: Cannot read property 'disconnect' of null. in version 2.1.1 . I'm use hide-immediatly property

iron-lazy-pages-behavior.html:150 crash

async.html:34 Uncaught TypeError: Cannot read property 'disconnect' of null
at DomApi.unobserveNodes (polymer.dom.html:73)
at HTMLElement.detached (iron-overlay-behavior.html:210)
at HTMLElement.detached (class.html:275)
at HTMLElement.detached (class.html:272)
at HTMLElement.detached (class.html:272)
at HTMLElement.detached (class.html:272)
at HTMLElement.detached (class.html:272)
at HTMLElement.disconnectedCallback (legacy-element-mixin.html:125)
at Zc.disconnectedCallback (CustomElementInternals.js:313)
at R (CustomElementInternals.js:104)

  unobserveNodes @ polymer.dom.html:73
  detached @ iron-overlay-behavior.html:210
  detached @ class.html:275
  detached @ class.html:272
  detached @ class.html:272
  detached @ class.html:272
  detached @ class.html:272
  disconnectedCallback @ legacy-element-mixin.html:125
  Zc.disconnectedCallback @ CustomElementInternals.js:313
  R @ CustomElementInternals.js:104
  (anonymous) @ Node.js:77
  __detachInstance @ dom-repeat.html:629
  disconnectedCallback @ dom-repeat.html:313
  Zc.disconnectedCallback @ CustomElementInternals.js:313
  R @ CustomElementInternals.js:104
  (anonymous) @ Node.js:116
  __teardownInstance @ dom-if.html:275
  __render @ dom-if.html:159
  __renderDebouncer.Polymer.Debouncer.debounce @ dom-if.html:108
  _timer._asyncModule.run @ debounce.html:43
  microtaskFlush @ async.html:31
  setTimeout (async)    
  microtaskFlush @ async.html:33
  characterData (async)    
  set @ patch-accessors.js:327
  set @ Node.js:175
  run @ async.html:199
  setConfig @ debounce.html:40
  debounce @ debounce.html:123
  __debounceRender @ dom-if.html:108
  runObserverEffect @ property-effects.html:225
  runEffectsForProperty @ property-effects.html:168
  runEffects @ property-effects.html:130
  _propertiesChanged @ property-effects.html:1899
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  _setProperty @ property-effects.html:1683
  Object.defineProperty.set @ properties-changed.html:157
  _show @ iron-lazy-pages-behavior.html:150
  onFinished @ iron-lazy-pages-behavior.html:113
  _itemSelected @ iron-lazy-pages-behavior.html:120
  handler @ template-stamp.html:92
  l @ patch-events.js:425
  dispatchEvent @ patch-builtins.js:87
  fire @ legacy-element-mixin.html:427
  _applySelection @ iron-selectable.html:350
  setItemSelected @ iron-selection.html:81
  select @ iron-selection.html:100
  _selectSelected @ iron-selectable.html:287
  _updateSelected @ iron-selectable.html:277
  runMethodEffect @ property-effects.html:904
  runEffectsForProperty @ property-effects.html:168
  runEffects @ property-effects.html:130
  _propertiesChanged @ property-effects.html:1899
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  __enableOrFlushClients @ property-effects.html:1783
  _flushClients @ property-effects.html:1755
  _propertiesChanged @ property-effects.html:1894
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  _setProperty @ property-effects.html:1683
  Object.defineProperty.set @ properties-changed.html:157
  _modulePageChanged @ app-container.html:380
  runMethodEffect @ property-effects.html:904
  runEffectsForProperty @ property-effects.html:168
  runEffects @ property-effects.html:130
  _propertiesChanged @ property-effects.html:1899
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  _setProperty @ property-effects.html:1683
  Object.defineProperty.set @ properties-changed.html:157
  _routeChanged @ app-container.html:345
  runMethodEffect @ property-effects.html:904
  runEffectsForProperty @ property-effects.html:168
  runEffects @ property-effects.html:130
  _propertiesChanged @ property-effects.html:1899
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  runNotifyEffects @ property-effects.html:272
  _propertiesChanged @ property-effects.html:1902
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  setProperties @ property-effects.html:1829
  __tryToMatch @ app-route.html:332
  runMethodEffect @ property-effects.html:904
  runEffectsForProperty @ property-effects.html:168
  runEffects @ property-effects.html:130
  _propertiesChanged @ property-effects.html:1899
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  __enableOrFlushClients @ property-effects.html:1783
  _flushClients @ property-effects.html:1755
  _propertiesChanged @ property-effects.html:1894
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  runNotifyEffects @ property-effects.html:272
  _propertiesChanged @ property-effects.html:1902
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  setProperties @ property-effects.html:1829
  __tryToMatch @ app-route.html:332
  runMethodEffect @ property-effects.html:904
  runEffectsForProperty @ property-effects.html:168
  runEffects @ property-effects.html:130
  _propertiesChanged @ property-effects.html:1899
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  __enableOrFlushClients @ property-effects.html:1783
  _flushClients @ property-effects.html:1755
  _propertiesChanged @ property-effects.html:1894
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  runNotifyEffects @ property-effects.html:272
  _propertiesChanged @ property-effects.html:1902
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  _setProperty @ property-effects.html:1683
  Object.defineProperty.set @ properties-changed.html:157
  _locationChanged @ app-route-converter-behavior.html:73
  runMethodEffect @ property-effects.html:904
  runEffectsForProperty @ property-effects.html:168
  runEffects @ property-effects.html:130
  _propertiesChanged @ property-effects.html:1899
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  _setProperty @ property-effects.html:1683
  Object.defineProperty.set @ properties-changed.html:157
  __computeRoutePath @ app-location.html:186
  runMethodEffect @ property-effects.html:904
  runEffectsForProperty @ property-effects.html:168
  runEffects @ property-effects.html:130
  _propertiesChanged @ property-effects.html:1899
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  runNotifyEffects @ property-effects.html:272
  _propertiesChanged @ property-effects.html:1902
  _flushProperties @ properties-changed.html:373
  _flushProperties @ property-effects.html:1731
  _invalidateProperties @ property-effects.html:1699
  _setProperty @ property-effects.html:1683
  Object.defineProperty.set @ properties-changed.html:157
  _urlChanged @ iron-location.html:230
  handler @ template-stamp.html:92
  l @ patch-events.js:425
  fire @ legacy-element-mixin.html:427
  _globalOnClick @ iron-location.html:313
  handler @ template-stamp.html:92
  l @ patch-events.js:425

Data binding not working on individual pages

It seems like data binding with an element within a iron-lazy-page is not working.

<template is="iron-lazy-page" data-route=""> <landing-view is-loading={{isLoading}}></landing-view> </template>

This is quite a big issue if you want to fetch data from one component to another. I'm not sure if this is a polymer behavior or something that can be fixed with this component?

Add notifyResize for paper-tabs

When using paper-tabs, call of notifyResize is required to display selection bar correctly.
This is how it is implemented by iron-pages:

      _selectedPageChanged: function(selected, old) {
        this.async(this.notifyResize);
      }

For now, I have to do this manually when using iron-lazy-pages. Would you mind implementing it?

CSS Mixins don't get applied when selected is two-way bound to another element

Description

When you two-way bind the selected attribute to another element it causes CSS mixins to not apply.
One primary use-case where this seems to be an issue is with app-location and app-route.

Expected outcome

paper-card has a box-shadow underneath

Actual outcome

paper-card doesn't have a box-shadow

Live Demo

Live Demo

If you remove the paper-input then the shadow appears.

Keep track of active pages and unstamp after threshold

When there are a lot of page navigations, keeping pages active might result in a slow application. When a certain number of pages has been stamped, the oldest page could be unstamped. This requires an array of active pages, sorted by last active and pages notifying the iron-lazy-pages parent whether they just stamped or not.

Import href doesn't work in Firefox

The demo doesn't work in Firefox. Lazy page content isn't loaded, although routing works as desired.

Only the index file is being loaded, while partials specified in the "path" attribute are not fetched (there are no requests in the Network tab of Firefox devtools).

There are no console errors, the only warning is that "Use of getPreventDefault() is deprecated", but it seems not to be related with the issue.

upd: I tried to debug it and something is wrong with the importHref - in Firefox it is never reached, neither onError callback. Firefox version is the newest one

Here is the workaround which works in Firefox kinda like as it is desired.

upd 2: the reason is vulcanizing with shards (using gulp-web-component-shards). Without vulcanizing component seems to be OK.

Fix Firefox Travis build

The Travis build keeps on failing on Firefox, but it is working just fine locally. Somehow this needs to be fixed by correctly configuring Travis.

Multiple stamped / active pages

So it seems that when selecting a page, then moving away from it before the required HTML is loaded, it will still stamp and select the previously selected page, but also stamp and show the newly selected item as well.

e.g. these sequence of events:

  1. Select 'foo', which requires foo.html
  2. Starts loading foo.html
  3. Select bar, which requires bar.html
  4. Starts loading bar.html
  5. bar.html loads
  6. Bar is stamped and shown
  7. foo.html loads
  8. Foo is stamped and shown

Given this line here I don't know how this is happening, but it appears it is.

Make sure iron-lazy-pages does not generate linter errors

Apparently the correct 2.0 version of iron-lazy-pages generates linter errors of polymer lint. This should not be happening. Not sure when I have time to investigate and address the issues.

  • Lazy imports are generating warnings, as the analyzer is not traversing the lazy imports of iron-lazy-pages.
    • A PR is open to support this in the polymer-analyzer (Polymer/polymer-analyzer#600), but I do not think that one will be merged.
    • There is a behavior (https://github.com/Polymer/lazy-imports) that would resolve the linter errors, but forces more source code changes for the 2.0 version + import another behavior.
    • Maybe the behavior is not required and the user only needs to specify the rel="lazy-import", without actually any source code changes to iron-lazy-pages.

Kill the component once no longer selected

Is it possible to kill a component once it is no longer needed/selected? E. g., we have one page with podcasts, there I can play a podcast. Now if I switch route, the podcast will still play since the component/podcast player is still in the DOM.

iron-lazy-pages for polymer 3

Hi, I've created a new version of your iron-lazy-pages for polymer 3.0 that works with <dom-if> to mainly have css stylesheets lazy-loaded. Should work inside Shadow DOM?

  static get template() {
    return `
      <link rel="stylesheet" href="./my-view1/my-view1.css">
   ...

I still need to run some test but you can have a look at it here: https://github.com/robertosobachi/iron-lazy-pages/tree/3.0-preview

I can create a pull request if you're happy with it later on when I'm sure all tests are covered.

I've also created a new version of the polymer-starter-kit that runs polymer 3-preview with gulp and your iron-lazy-pages here https://github.com/robertosobachi/polymer-starter-kit

Demo is broken in Firefox due to 404

The demo page uses iron-lazy-pages with some path attributes with not existing components:

    <template is="iron-lazy-page" data-route="bar" path="bla.html">
      Bar page
    </template>

When trying to load it, we receive 404:

GET http://timvdlippe.github.io/iron-lazy-pages/components/iron-lazy-pages/demo/bla.html?0 404 (Not Found)

After that, in Chrome and Safari loading is set to false (and spinner disappears), and the Bar page content is displayed.
However, in Firefox loading occasionally remains on the first click to this tab.

In the console, the error is shown at this time:

TypeError: Argument 1 of Node.removeChild is not an object.

Only after switching tabs several times, Bar page is displayed.

Do not require a template definition when lazy loading content

Currently all pages are required to be an iron-lazy-page. This means that they all must be wrapped inside a template. It would be nicer if this requirement is not that strict and instead elements can be loaded without a template, by requiring the attribute data-path to be set on the element.

E.g. something like this:

<iron-lazy-pages attr-for-selected="data-route" selected="{{route}}">
  <template is="iron-lazy-page" data-route="foo" path="foo/foo.html">
    Foo page
  </template>
  <bar-page data-route="bar" data-path="bar/bar.html"></bar-page>
</iron-lazy-pages>

MIME Exception

Hi,

We've converted our polymer 1.x app to 3.x manually. We've executed the 1.x project through java app, following the same procedure in the 3.x project we are getting MIME exception i.e, we are unable to import polymer elements from this statement.
import {PolymerElement, html} from '@polymer/polymer/polymer-element.js';

The pages execute fine independently using Polymer serve.

How to resolve the issue.

The polymer components are not loading.
Do we need to change the path while loading. How to do it ?
Do we need to change ES6 to AMD modules

Ranganath.

iron-select event gets fired if I use iron-pages in my element

index.html

<iron-lazy-pages attr-for-selected="data-route" selected="dashboard">
  <template is="iron-lazy-page" data-route="dashboard" path="elements/chart-elements.html">
    <chart-view active="[[dashboardActive]]"></chart-view>
  </template>
</iron-lazy-pages>

chart-view.html

<iron-pages selected="0">
  <section>vimal</section>
  <section>TimvdLippe</section>
</iron-pages>

Error:
_Uncaught TypeError: event.detail.item.loadAndShow is not a function

Add async property

There is an optAsync parameter which can be passed into importHref. This seems to be useful to prevent screen repainting, as mentioned here:

By default HTML imports block rendering of the page. 
The router waits for the link's load event to fire before using the imported document 
so this will speed up rendering when navigating between routes.

BTW, this parameter is used by app-drawer-template.

I will create a PR for implementing this. Not yet sure how should it be covered with tests.

data-path is relative to location of embedding element

We use iron-lazy-pages within a app-drawer-layout:

<app-drawer-layout>
  <app-drawer slot="drawer">...</app-drawer>

  <iron-lazy-pages attr-for-selected="name" selected="[[_selected]]" load-async>
    <my-home name="home" data-path="home.html"></my-home>
 ...

Loading the application in Chrome (Fedora) leads to an error because file http://localhost:8081/bower_components/app-layout/app-drawer-layout/home.html can't be found.

It works when changing the relative path to

  <my-home name="home" data-path="../../../elements/home.html"></my-home>

I would expect that the path in data-path is relative to the base path of the application (same as <link rel="import" href="home.html">.

Variable bindings not ready when switching to view with data-binding

I am facing a bit of a weird issue and I am not sure if iron-lazy-pages is the problem.

I am switching from a simple custom-element (no data binding), to a custom element with data binding (from getting-started to master-detail):

image

I am getting an error in dom-if.html that the binding is still null.

image

The stateChanged observer on the host has fired, so the data is actually there. e.g. the function that determines the selected attribute for iron-lazy-pages has already fired successfully, triggering the page switch.

This happens with or without hide-immediately.

What do you think is the problem here?

iron-lazy-page.html should import polymer.html

The following error is thrown when using new polymer-analyzer:

error:   In vendor/iron-lazy-pages/iron-lazy-page.html: [unknown-polymer-behavior] - Unable to resolve behavior `Polymer.Templatizer`. Did you import it? Is it annotated with @polymerBehavior?

My suggestion is that polymer.html should be imported explicitly by iron-lazy-page.html

Third demo does not work for dom-if branch

The third demo does not render the paper-tabs, and appears to be missing the element. Once the dom-if element is added, the dom-if templates do not render, as the 'if' attribute is not set. The demo could be modified to show how the dom-if template works if distributed to the light DOM.

selected-attribute on the stamped page

Hi, I need to use the selected-attribute property, which iron-lazy-pages has from Polymer.IronSelectableBehavior, but I've noticed that it's setted on the instead of the stamped page element. It's important for me to know if the page is visible to the user.

How can I do that? Thank you!

Release element

Could you please create a release (to have a fixed version that could be referred from a build using the element)?

restamp="false" will fail

If you set restamp="false", the element will be removed and injected from DOM after loading the correct page.
As the default value is false, you can get rid of the attribute, but if you include it, the output doesn't work as expected.

Light DOM children stamped to parent's shadow DOM

I'm trying to use iron-lazy-pages in a wrapper component to handle pages distributed in its light DOM, like so:

<iron-lazy-pages ...>
  <content select="[is=iron-lazy-page]"></content>
</iron-lazy-pages

It works, but active pages are stamped as siblings of <content> in the parent's shadow DOM, which defeats the purpose of distributing templates to the light DOM to begin with.

Noticed support for distributing to light DOM was added in #26, also checked out the new demo from that PR and it stamps to Shadow DOM too. Is that the intended behaviour, or a bug?

Usage without lazy loading

Is there any way to use this element without actually fetching the elements?

For example I'd simply like to remove from the DOM not currently viewed "pages" and add them back when they are in-view.

The current <iron-pages> implementation simply hides them.

Pages are restamped over and over

I've two pages:

<iron-lazy-pages attr-for-selected="name" selected="[[_selected]]">
  <template is="iron-lazy-page" name="list" path="list.html">List</template>
  <template is="iron-lazy-page" name="detail" path="detail.html">Detail</template>
</iron-lazy-pages>

When the user toggles between the two pages, my pages are restamped each time. This is especially tricky if a page holds state (e.g. load data from the backend or stay on a specific tab within the page).

Is there a way to activate the dom-if behavior (https://www.polymer-project.org/1.0/docs/devguide/templates.html#dom-if)?

  • Only hide the deactivated pages once they are stamped.
  • (Potentially) explicitly request restamping via the restamp property.

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.