Skip to content

Commit

Permalink
Merge pull request #55 from canjs/def-el
Browse files Browse the repository at this point in the history
Prevent DOM event warning from calling getter
  • Loading branch information
matthewp authored Jul 9, 2019
2 parents 727adb5 + cf1dcb7 commit ae8bf7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/can-stache-define-element-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,12 @@ if (browserSupports.customElements) {
dev.devOnlyTest("Warns when a property matches an event name", function(assert) {
class ClickPropEl extends StacheDefineElement {
static get define() {
return { click: String };
return {
click: String,
get other() {
throw new Error('Don\'t get me');
}
};
}
}
customElements.define("click-prop-should-warn", ClickPropEl);
Expand Down
2 changes: 1 addition & 1 deletion src/mixin-define.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function mixinDefine(Base = HTMLElement) {
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
let defines = typeof Type.define === "object" ? Type.define : {};
canReflect.eachKey(defines, function(value, key) {
Object.keys(defines).forEach(function(key) {
if("on" + key in Type.prototype) {
canLogDev.warn(`${canReflect.getName(Type)}: The defined property [${key}] matches the name of a DOM event. This property could update unexpectedly. Consider renaming.`);
}
Expand Down

0 comments on commit ae8bf7b

Please sign in to comment.