diff --git a/dist/index.js b/dist/index.js index bd5aa63..2f8d665 100644 --- a/dist/index.js +++ b/dist/index.js @@ -44,9 +44,14 @@ var reflect = function reflect(el) { var retarget = function retarget(el) { return (0, _keys2.default)(el).concat(['on', 'once', 'emit', 'classList', 'getAttribute', 'setAttribute']).map(function (d) { - return _is2.default.fn(el[d]) ? el.shadowRoot[d] = el[d].bind(el) : Object.defineProperty(el.shadowRoot, d, { get: function get(z) { + return _is2.default.fn(el[d]) ? el.shadowRoot[d] = el[d].bind(el) : Object.defineProperty(el.shadowRoot, d, { + get: function get(z) { return el[d]; - } }); + }, + set: function set(z) { + return el[d] = z; + } + }); }); }; diff --git a/src/index.js b/src/index.js index 25bf38c..268d188 100644 --- a/src/index.js +++ b/src/index.js @@ -27,7 +27,11 @@ const retarget = el => keys(el) .concat(['on', 'once', 'emit', 'classList', 'getAttribute', 'setAttribute']) .map(d => is.fn(el[d]) ? (el.shadowRoot[d] = el[d].bind(el)) - : Object.defineProperty(el.shadowRoot, d, { get: z => el[d] })) + : Object.defineProperty(el.shadowRoot, d, { + get: z => el[d] + , set: z => el[d] = z + }) + ) const log = require('utilise/log')('[ri/shadow]') , err = require('utilise/err')('[ri/shadow]') diff --git a/test.js b/test.js index 2a9709b..6932fcd 100644 --- a/test.js +++ b/test.js @@ -110,7 +110,7 @@ describe('Shadow DOM', function(){ time(100, done) }) - it('should retarget .classed and .attr', function(){ + it('should retarget .classed and .attr', function(){ var ripple = shadow(components(fn(data(core())))) ripple('component-2', noop) @@ -138,4 +138,18 @@ describe('Shadow DOM', function(){ expect(root.getAttribute('foo')).to.be.eql('bar') }) + it('should make shadow properties setter transparent', function(){ + var ripple = shadow(components(fn(data(core())))) + + el2.foo = true + ripple('component-2', noop) + ripple.render(el2) + + el2.foo = 10 + expect(el2.shadowRoot.foo).to.eql(10) + + el2.shadowRoot.foo = 20 + expect(el2.foo).to.eql(20) + }) + }) \ No newline at end of file