The experiment shows that when the route no longer matches, <app.route>
modifies the subroute
, but does not clear the subrouteData
(perhaps this is an error in this element). However, <app-route>
always sets data
when active=true
(i.e. the route matches), so you will need to check the active
flag before reading data
.
For example, you can only show an element if active
is true
(and remove it from the DOM if false
):
<template is="dom-if" if="[[subrouteActive]]" restamp> <my-el uuid="[[subrouteData.uuid]]"></my-el> </template>
Or the element may internally skip processing if active
is false
:
<my-el uuid="[[subrouteData.uuid]]" active="[[subrouteActive]]"></my-el> // my-el script _processUuid: function() { if (!this.active) return; // do something with this.uuid... }
Or the element could observe active
and reset things if false
:
// my-el script _onActiveChanged: function(active) { if (!active) { // reset... } }
source share