Skip to content

Commit 5ef6462

Browse files
committed
hyperapp
1 parent 21bcfe1 commit 5ef6462

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

libraries/hyperapp/src/basic-tests.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import {
2525
ComponentWithDifferentViews,
2626
ComponentWithProperties,
2727
ComponentWithImperativeEvent,
28-
ComponentWithDeclarativeEvent
28+
ComponentWithDeclarativeEvent,
29+
ComponentWithoutProperties
2930
} from "./components";
3031

3132
// Setup the test harness. This will get cleaned out with every test.
@@ -130,6 +131,17 @@ describe("basic support", function () {
130131
let data = wc.str || wc.getAttribute("str");
131132
expect(data).to.eql("Hyperapp");
132133
});
134+
135+
it('will not overwrite unwritable properties', async function() {
136+
this.weight = 3;
137+
ComponentWithoutProperties(root);
138+
await new Promise(requestAnimationFrame);
139+
let wc = testContainer.querySelector('#wc');
140+
expect(wc.getAttribute('amethod')).to.eql('method');
141+
expect(wc.getAttribute('agetter')).to.eql('getter');
142+
expect(wc.getAttribute('areadonly')).to.eql('readonly');
143+
expect(wc.innerHTML).to.eql('Success');
144+
})
133145
});
134146

135147
describe("events", function () {

libraries/hyperapp/src/components.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import "ce-without-children"
1919
import "ce-with-children"
2020
import "ce-with-properties"
2121
import "ce-with-event"
22+
import "ce-without-properties"
2223

2324
import { app, h, text } from "hyperapp"
2425

@@ -81,6 +82,20 @@ export const ComponentWithProperties = node =>
8182
]),
8283
})
8384

85+
export const ComponentWithoutProperties = node =>
86+
app({
87+
node,
88+
init: {},
89+
view: () =>
90+
h('div', {}, [
91+
h('ce-without-properties', {
92+
amethod: 'method',
93+
agetter: 'getter',
94+
areadonly: 'readonly'
95+
}),
96+
]),
97+
})
98+
8499
export const ComponentWithImperativeEvent = node => {
85100
const _withElem = (_, opts) =>
86101
requestAnimationFrame(_ => {

0 commit comments

Comments
 (0)