From ace6dcd064f737eff51a5b9058aaaa0c14921f8a Mon Sep 17 00:00:00 2001 From: Justin Meyer Date: Fri, 16 Dec 2016 09:55:14 -0600 Subject: [PATCH] fixes #28 --- can-construct.js | 4 ++-- can-construct_test.js | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/can-construct.js b/can-construct.js index e9aea04..0d4a4fe 100644 --- a/can-construct.js +++ b/can-construct.js @@ -309,7 +309,7 @@ assign(Construct, { // this should be used for patching other objects // the super plugin overwrites this _overwrite: function (what, oldProps, propName, val) { - what[propName] = val; + Object.defineProperty(what, propName, {value: val, configurable: true, enumerable: true, writable: true}); }, // Set `defaults` as the merger of the parent `defaults` and this // object's `defaults`. If you overwrite this method, make sure to @@ -685,7 +685,7 @@ assign(Construct, { * return [$(element)] * } * }); - * + * * MyWidget = WidgetFactory.extend({ * init: function($el){ * $el.html("My Widget!!") diff --git a/can-construct_test.js b/can-construct_test.js index 247db0d..7c5b945 100644 --- a/can-construct_test.js +++ b/can-construct_test.js @@ -206,3 +206,22 @@ test("basic injection attacks thwarted", function() { } }); + +QUnit.test("setters not invoked on extension (#28)", function(){ + + var extending = true; + var Base = Construct.extend("Base",{ + set something(value){ + QUnit.ok(!extending, "called when not extending"); + }, + get something(){ + + } + }); + + Base.extend("Extended",{ + something: "value" + }); + extending = false; + new Base().something = "foo"; +});