Skip to content

Commit 820f51b

Browse files
committed
preact
1 parent 4a371e6 commit 820f51b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

libraries/preact/src/basic-tests.js

+12
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
ComponentWithChildrenRerender,
2424
ComponentWithDifferentViews,
2525
ComponentWithProperties,
26+
ComponentWithoutProperties,
2627
ComponentWithUnregistered,
2728
ComponentWithImperativeEvent,
2829
ComponentWithDeclarativeEvent
@@ -113,6 +114,17 @@ describe("basic support", function() {
113114
expect(data).to.eql("Preact");
114115
});
115116

117+
it("will not overwrite unwriteable properties", function () {
118+
this.weight = 3;
119+
let root = mount(<ComponentWithoutProperties />).getDOMNode();
120+
let wc = root.querySelector("#wc");
121+
expect(wc.getAttribute('amethod')).to.eql('method');
122+
expect(wc.getAttribute('agetter')).to.eql('getter');
123+
expect(wc.getAttribute('areadonly')).to.eql('readonly');
124+
expect(wc.innerHTML).to.eql('Success');
125+
});
126+
127+
116128
// it('will set boolean attributes on a Custom Element that has not already been defined and upgraded', function() {
117129
// let root = mount(<ComponentWithUnregistered />).getDOMNode();
118130
// let wc = root.querySelector('#wc');

libraries/preact/src/components.js

+15
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { h, render, Component } from 'preact';
1919
import 'ce-without-children';
2020
import 'ce-with-children';
2121
import 'ce-with-properties';
22+
import 'ce-without-properties';
2223
import 'ce-with-event';
2324

2425
export class ComponentWithoutChildren extends Component {
@@ -109,6 +110,20 @@ export class ComponentWithProperties extends Component {
109110
}
110111
}
111112

113+
export class ComponentWithoutProperties extends Component {
114+
render () {
115+
return (
116+
<div>
117+
<ce-without-properties id="wc"
118+
amethod={"method"}
119+
agetter={"getter"}
120+
areadonly={"readonly"}
121+
></ce-without-properties>
122+
</div>
123+
)
124+
}
125+
}
126+
112127
export class ComponentWithUnregistered extends Component {
113128
render () {
114129
const data = {

0 commit comments

Comments
 (0)