From cae27b1904e64c921783da565e3dc5a93254e457 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 15 Apr 2018 16:19:39 -0400 Subject: [PATCH] allow overwritten observe --- src/generators/dom/index.ts | 2 +- src/validate/js/propValidators/methods.ts | 2 +- test/js/samples/event-handlers-custom/expected-bundle.js | 3 ++- test/js/samples/event-handlers-custom/expected.js | 3 ++- test/js/samples/setup-method/expected-bundle.js | 3 ++- test/js/samples/setup-method/expected.js | 3 ++- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/generators/dom/index.ts b/src/generators/dom/index.ts index bac46acab7..eb7533187c 100644 --- a/src/generators/dom/index.ts +++ b/src/generators/dom/index.ts @@ -138,7 +138,6 @@ export default function dom( : options.shared || ''; let prototypeBase = `${name}.prototype`; - templateProperties.methods && (prototypeBase = `@assign(${prototypeBase}, %methods)`); const proto = sharedPath ? `@proto` @@ -343,6 +342,7 @@ export default function dom( } @assign(${prototypeBase}, ${proto}); + ${templateProperties.methods && `@assign(${prototypeBase}, %methods);`} `); } diff --git a/src/validate/js/propValidators/methods.ts b/src/validate/js/propValidators/methods.ts index 3956855150..cef7095a82 100644 --- a/src/validate/js/propValidators/methods.ts +++ b/src/validate/js/propValidators/methods.ts @@ -6,7 +6,7 @@ import getName from '../../../utils/getName'; import { Validator } from '../../index'; import { Node } from '../../../interfaces'; -const builtin = new Set(['set', 'get', 'on', 'fire', 'observe', 'destroy']); +const builtin = new Set(['set', 'get', 'on', 'fire', 'destroy']); export default function methods(validator: Validator, prop: Node) { if (prop.value.type !== 'ObjectExpression') { diff --git a/test/js/samples/event-handlers-custom/expected-bundle.js b/test/js/samples/event-handlers-custom/expected-bundle.js index 196f0e1c94..861a3afc78 100644 --- a/test/js/samples/event-handlers-custom/expected-bundle.js +++ b/test/js/samples/event-handlers-custom/expected-bundle.js @@ -204,6 +204,7 @@ function SvelteComponent(options) { } } -assign(assign(SvelteComponent.prototype, methods), proto); +assign(SvelteComponent.prototype, proto); +assign(SvelteComponent.prototype, methods); export default SvelteComponent; diff --git a/test/js/samples/event-handlers-custom/expected.js b/test/js/samples/event-handlers-custom/expected.js index 7675f5e199..bfec447406 100644 --- a/test/js/samples/event-handlers-custom/expected.js +++ b/test/js/samples/event-handlers-custom/expected.js @@ -56,5 +56,6 @@ function SvelteComponent(options) { } } -assign(assign(SvelteComponent.prototype, methods), proto); +assign(SvelteComponent.prototype, proto); +assign(SvelteComponent.prototype, methods); export default SvelteComponent; \ No newline at end of file diff --git a/test/js/samples/setup-method/expected-bundle.js b/test/js/samples/setup-method/expected-bundle.js index 8e8036f6e7..39f5d28c80 100644 --- a/test/js/samples/setup-method/expected-bundle.js +++ b/test/js/samples/setup-method/expected-bundle.js @@ -181,7 +181,8 @@ function SvelteComponent(options) { } } -assign(assign(SvelteComponent.prototype, methods), proto); +assign(SvelteComponent.prototype, proto); +assign(SvelteComponent.prototype, methods); setup(SvelteComponent); diff --git a/test/js/samples/setup-method/expected.js b/test/js/samples/setup-method/expected.js index feee1679e5..d39c4288e3 100644 --- a/test/js/samples/setup-method/expected.js +++ b/test/js/samples/setup-method/expected.js @@ -44,7 +44,8 @@ function SvelteComponent(options) { } } -assign(assign(SvelteComponent.prototype, methods), proto); +assign(SvelteComponent.prototype, proto); +assign(SvelteComponent.prototype, methods); setup(SvelteComponent); export default SvelteComponent; \ No newline at end of file