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

lit-element page.js and parameters not working? #573

Open
tamis-laan opened this issue Sep 6, 2020 · 0 comments
Open

lit-element page.js and parameters not working? #573

tamis-laan opened this issue Sep 6, 2020 · 0 comments

Comments

@tamis-laan
Copy link

tamis-laan commented Sep 6, 2020

I'm using lit-element in combination with page.js and I'm running into an error. The code below is a simplification of the code I'm working on:

import {LitElement, html, css, property, customElement} from 'lit-element'

@customElement('my-app')
export class myApp extends LitElement {
  // Element properties
  static get properties(){ return {page:{type:String}} }
  // Constructor
  constructor() {
    super()
    page('/',            ()=>this.page='index')
    page('/test/:id', ()=>{console.log('TRACE');this.page='test'})
    page()
  }

  render() {
    if(this.page === "index") {
      return html`index`
    }
    if(this.page === "test") {
      return html`test`
    }
  }

}

The route '/' works fine and shows me index, however the route /test/abc gives me the following error:

client.js:1 Uncaught SyntaxError: Unexpected token '<'
Uncaught (in promise) DOMException: Failed to register a ServiceWorker for scope ('http://localhost:3000/test/') with script ('http://localhost:3000/test/sw.js'): The script has an unsupported MIME type ('text/html').

Also the TRACE is not logged in console.

Not sure if the error is relatable as my setup is far more complex then the example above. But maybe someone has experience using page.js and lit-element together and has run up to similar problems before?

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

1 participant