Skip to content

Commit

Permalink
surplus
Browse files Browse the repository at this point in the history
  • Loading branch information
mrginglymus committed Dec 27, 2024
1 parent 8ee776b commit 7e7d1e7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions libraries/surplus/src/basic-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
ComponentWithChildrenRerender,
ComponentWithDifferentViews,
ComponentWithProperties,
ComponentWithoutProperties,
ComponentWithUnregistered,
ComponentWithImperativeEvent,
ComponentWithDeclarativeEvent
Expand Down Expand Up @@ -122,6 +123,18 @@ describe("basic support", function() {
});
});

it("will not overwrite unwriteable properties", function () {
this.weight = 3;
S.root(() => {
let root = <ComponentWithoutProperties />;
let wc = root.wc;
expect(wc.getAttribute('amethod')).to.eql('method');
expect(wc.getAttribute('agetter')).to.eql('getter');
expect(wc.getAttribute('areadonly')).to.eql('readonly');
expect(wc.innerHTML).to.eql('Success');
})
});

// TODO: Is it the framework's responsibility to check if the underlying
// property is defined? Or should it just always assume it is and do its
// usual default behavior? Preact will actually check if it's defined and
Expand Down
18 changes: 18 additions & 0 deletions libraries/surplus/src/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import on from 'surplus-mixin-on';
import 'ce-without-children';
import 'ce-with-children';
import 'ce-with-properties';
import 'ce-without-properties';
import 'ce-with-event';

export const ComponentWithoutChildren = () =>
Expand Down Expand Up @@ -80,6 +81,23 @@ export const ComponentWithProperties = () => {
);
}

export const ComponentWithoutProperties = () => {
const data = {
getter: 'getter',
method: 'method',
readonly: 'readonly',
};
return (
<div>
<ce-without-properties ref={__.wc}
amethod={data.method}
agetter={data.getter}
areadonly={data.readonly}
></ce-without-properties>
</div>
)
}

export const ComponentWithUnregistered = () => {
const data = {
bool: true,
Expand Down

0 comments on commit 7e7d1e7

Please sign in to comment.