Skip to content

Commit 33ab8d6

Browse files
author
pemrouz
committed
should make shadow properties setter transparent
1 parent 77c2346 commit 33ab8d6

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

dist/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ var reflect = function reflect(el) {
4444

4545
var retarget = function retarget(el) {
4646
return (0, _keys2.default)(el).concat(['on', 'once', 'emit', 'classList', 'getAttribute', 'setAttribute']).map(function (d) {
47-
return _is2.default.fn(el[d]) ? el.shadowRoot[d] = el[d].bind(el) : Object.defineProperty(el.shadowRoot, d, { get: function get(z) {
47+
return _is2.default.fn(el[d]) ? el.shadowRoot[d] = el[d].bind(el) : Object.defineProperty(el.shadowRoot, d, {
48+
get: function get(z) {
4849
return el[d];
49-
} });
50+
},
51+
set: function set(z) {
52+
return el[d] = z;
53+
}
54+
});
5055
});
5156
};
5257

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ const retarget = el => keys(el)
2727
.concat(['on', 'once', 'emit', 'classList', 'getAttribute', 'setAttribute'])
2828
.map(d => is.fn(el[d])
2929
? (el.shadowRoot[d] = el[d].bind(el))
30-
: Object.defineProperty(el.shadowRoot, d, { get: z => el[d] }))
30+
: Object.defineProperty(el.shadowRoot, d, {
31+
get: z => el[d]
32+
, set: z => el[d] = z
33+
})
34+
)
3135

3236
const log = require('utilise/log')('[ri/shadow]')
3337
, err = require('utilise/err')('[ri/shadow]')

test.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('Shadow DOM', function(){
110110
time(100, done)
111111
})
112112

113-
it('should retarget .classed and .attr', function(){
113+
it('should retarget .classed and .attr', function(){
114114
var ripple = shadow(components(fn(data(core()))))
115115

116116
ripple('component-2', noop)
@@ -138,4 +138,18 @@ describe('Shadow DOM', function(){
138138
expect(root.getAttribute('foo')).to.be.eql('bar')
139139
})
140140

141+
it('should make shadow properties setter transparent', function(){
142+
var ripple = shadow(components(fn(data(core()))))
143+
144+
el2.foo = true
145+
ripple('component-2', noop)
146+
ripple.render(el2)
147+
148+
el2.foo = 10
149+
expect(el2.shadowRoot.foo).to.eql(10)
150+
151+
el2.shadowRoot.foo = 20
152+
expect(el2.foo).to.eql(20)
153+
})
154+
141155
})

0 commit comments

Comments
 (0)