File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import on from 'surplus-mixin-on';
2121import 'ce-without-children' ;
2222import 'ce-with-children' ;
2323import 'ce-with-properties' ;
24+ import 'ce-without-properties' ;
2425import 'ce-with-event' ;
2526
2627export 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+
83101export const ComponentWithUnregistered = ( ) => {
84102 const data = {
85103 bool : true ,
You can’t perform that action at this time.
0 commit comments