File tree 6 files changed +11
-9
lines changed
dev-warning-missing-data-binding
dev-warning-readonly-computed
dev-warning-readonly-window-binding
6 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,10 @@ export default function dom(
147
147
. join ( ',\n' ) }
148
148
}` ;
149
149
150
+ const debugName = `<${ generator . customElement ? generator . tag : name } >` ;
151
+
150
152
const constructorBody = deindent `
153
+ ${ options . dev && `this._debugName = '${ debugName } ';` }
151
154
${ options . dev && ! generator . customElement &&
152
155
`if (!options || (!options.target && !options._root)) throw new Error("'target' is a required option");` }
153
156
this.options = options;
@@ -160,7 +163,7 @@ export default function dom(
160
163
${ options . dev &&
161
164
Array . from ( generator . expectedProperties ) . map (
162
165
prop =>
163
- `if (!('${ prop } ' in this._state)) console.warn("Component was created without expected data property '${ prop } '");`
166
+ `if (!('${ prop } ' in this._state)) console.warn("${ debugName } was created without expected data property '${ prop } '");`
164
167
) }
165
168
${ generator . bindingGroups . length &&
166
169
`this._bindingGroups = [${ Array ( generator . bindingGroups . length ) . fill ( '[]' ) . join ( ', ' ) } ];` }
@@ -288,13 +291,12 @@ export default function dom(
288
291
` ) ;
289
292
}
290
293
291
- // TODO deprecate component.teardown()
292
294
builder . addBlock ( deindent `
293
295
${ options . dev && deindent `
294
296
${ name } .prototype._checkReadOnly = function _checkReadOnly(newState) {
295
297
${ Array . from ( generator . readonly ) . map (
296
298
prop =>
297
- `if ('${ prop } ' in newState && !this._updatingReadonlyProperty) throw new Error("Cannot set read-only property '${ prop } '");`
299
+ `if ('${ prop } ' in newState && !this._updatingReadonlyProperty) throw new Error("${ debugName } : Cannot set read-only property '${ prop } '");`
298
300
) }
299
301
};
300
302
` }
Original file line number Diff line number Diff line change @@ -151,7 +151,7 @@ export function _set(newState) {
151
151
export function _setDev ( newState ) {
152
152
if ( typeof newState !== 'object' ) {
153
153
throw new Error (
154
- 'Component .set was called without an object of data key-values to update.'
154
+ this . _debugName + ' .set was called without an object of data key-values to update.'
155
155
) ;
156
156
}
157
157
Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ export default {
2
2
dev : true ,
3
3
4
4
warnings : [
5
- `Component was created without expected data property 'value'`
5
+ `<Main$> was created without expected data property 'value'`
6
6
]
7
7
} ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ export default {
2
2
dev : true ,
3
3
4
4
warnings : [
5
- `Component was created without expected data property 'foo'` ,
6
- `Component was created without expected data property 'bar'`
5
+ `<Main$> was created without expected data property 'foo'` ,
6
+ `<Main$> was created without expected data property 'bar'`
7
7
]
8
8
} ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export default {
6
6
component . set ( { foo : 1 } ) ;
7
7
throw new Error ( 'Expected an error' ) ;
8
8
} catch ( err ) {
9
- assert . equal ( err . message , `Cannot set read-only property 'foo'` ) ;
9
+ assert . equal ( err . message , `<Main$>: Cannot set read-only property 'foo'` ) ;
10
10
}
11
11
}
12
12
} ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export default {
6
6
component . set ( { width : 99 } ) ;
7
7
throw new Error ( 'Expected an error' ) ;
8
8
} catch ( err ) {
9
- assert . equal ( err . message , `Cannot set read-only property 'width'` ) ;
9
+ assert . equal ( err . message , `<Main$>: Cannot set read-only property 'width'` ) ;
10
10
}
11
11
}
12
12
} ;
You can’t perform that action at this time.
0 commit comments