Skip to content

Commit 7e7d1e7

Browse files
committed
surplus
1 parent 8ee776b commit 7e7d1e7

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

libraries/surplus/src/basic-tests.js

+13
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
ComponentWithChildrenRerender,
2525
ComponentWithDifferentViews,
2626
ComponentWithProperties,
27+
ComponentWithoutProperties,
2728
ComponentWithUnregistered,
2829
ComponentWithImperativeEvent,
2930
ComponentWithDeclarativeEvent
@@ -122,6 +123,18 @@ describe("basic support", function() {
122123
});
123124
});
124125

126+
it("will not overwrite unwriteable properties", function () {
127+
this.weight = 3;
128+
S.root(() => {
129+
let root = <ComponentWithoutProperties />;
130+
let wc = root.wc;
131+
expect(wc.getAttribute('amethod')).to.eql('method');
132+
expect(wc.getAttribute('agetter')).to.eql('getter');
133+
expect(wc.getAttribute('areadonly')).to.eql('readonly');
134+
expect(wc.innerHTML).to.eql('Success');
135+
})
136+
});
137+
125138
// TODO: Is it the framework's responsibility to check if the underlying
126139
// property is defined? Or should it just always assume it is and do its
127140
// usual default behavior? Preact will actually check if it's defined and

libraries/surplus/src/components.js

+18
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import on from 'surplus-mixin-on';
2121
import 'ce-without-children';
2222
import 'ce-with-children';
2323
import 'ce-with-properties';
24+
import 'ce-without-properties';
2425
import 'ce-with-event';
2526

2627
export const ComponentWithoutChildren = () =>
@@ -80,6 +81,23 @@ export const ComponentWithProperties = () => {
8081
);
8182
}
8283

84+
export const ComponentWithoutProperties = () => {
85+
const data = {
86+
getter: 'getter',
87+
method: 'method',
88+
readonly: 'readonly',
89+
};
90+
return (
91+
<div>
92+
<ce-without-properties ref={__.wc}
93+
amethod={data.method}
94+
agetter={data.getter}
95+
areadonly={data.readonly}
96+
></ce-without-properties>
97+
</div>
98+
)
99+
}
100+
83101
export const ComponentWithUnregistered = () => {
84102
const data = {
85103
bool: true,

0 commit comments

Comments
 (0)