<link rel="import" href="../polymer/polymer.html">
<script src="route.js"></script>

<dom-module id="radiant-router">
  <script>
    (function () {
      Polymer({
        is: 'radiant-router',

        properties: {
          url: { type: String, notify: true },
          routeState: { type: Object, notify: true },
          rootRoute: { type: Object, value: null }
        },

        observers: [
          '_onURLChange(url, rootRoute)',
          '_onRouteStateChange(routeState, rootRoute, routeState.*)'
        ],

        _onURLChange: function (url) {
          this.rootRoute.url = url
          this._extractPropertiesFromRouter()
        },

        _onRouteStateChange: function (routeState) {
          this.rootRoute.state = routeState
          this._extractPropertiesFromRouter()
        },

        _extractPropertiesFromRouter: function () {
          // URL
          this.url = this.rootRoute.url

          // routeState
          var newRouteState = this.rootRoute.state
          if (!deepEqual(this.routeState, newRouteState)) {
            this.routeState = newRouteState
          }
        }
      })

      function deepEqual(obj1, obj2) {
        return JSON.stringify(obj1) === JSON.stringify(obj2)
      }
    })()
  </script>
</dom-module>

<link rel="import" href="../polymer/polymer.html">
<script src="route.js"></script>

<dom-module id="radiant-router">
  <script>
    (function () {
      Polymer({
        is: 'radiant-router',

        properties: {
          url: { type: String, notify: true },
          routeState: { type: Object, notify: true },
          rootRoute: { type: Object, value: null }
        },

        observers: [
          '_onURLChange(url, rootRoute)',
          '_onRouteStateChange(routeState, rootRoute, routeState.*)'
        ],

        _onURLChange: function (url) {
          if (url === undefined) { return }
          this.rootRoute.url = url
          this._extractPropertiesFromRouter()
        },

        _onRouteStateChange: function (routeState) {
          if (routeState === undefined) { return }
          this.rootRoute.state = routeState
          this._extractPropertiesFromRouter()
        },

        _extractPropertiesFromRouter: function () {
          // URL
          this.url = this.rootRoute.url

          // routeState
          var newRouteState = this.rootRoute.state
          if (!deepEqual(this.routeState, newRouteState)) {
            this.routeState = newRouteState
          }
        }
      })

      function deepEqual(obj1, obj2) {
        return JSON.stringify(obj1) === JSON.stringify(obj2)
      }
    })()
  </script>
</dom-module>

Fix problem with Polymer 2.0 binding system
Fix problem with Polymer 2.0 binding system