canjs / can-stache-element

Create custom elements with can-stache and can-define-class
https://canjs.com/doc/can-stache-element.html
MIT License
3 stars 1 forks source link

Warn when a component property shadows a DOM Element property #95

Closed m-mujica closed 5 years ago

m-mujica commented 5 years ago

I ran into an issue with a component defining a tagName property like this:

class MyComponent extends StacheElement {
  static get view() {
    return "";
  }

  static get props() {
    return {
      tagName: String
    };
  }
}

can-stache-bindings throws the following error:

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
    at Object.viewModel 
    at makeDataBinding

There is a warning already in place when components define an error property. We should extend that functionality.

nlundquist commented 5 years ago

I can't reproduce the error in this issue, but I agree that this should cause a warning.

m-mujica commented 5 years ago

I saw this while working on https://github.com/canjs/can-devtools-components/blob/064f639b2c93f169702651b7d56b35ace47953d9/viewmodel-editor/viewmodel-editor.js, maybe if you change this line to tagName: String and try loading the demo page you'll be able to replicate.