|
|
@ -147,7 +147,10 @@ export default function dom(
|
|
|
|
.join(',\n')}
|
|
|
|
.join(',\n')}
|
|
|
|
}`;
|
|
|
|
}`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const debugName = `<${generator.customElement ? generator.tag : name}>`;
|
|
|
|
|
|
|
|
|
|
|
|
const constructorBody = deindent`
|
|
|
|
const constructorBody = deindent`
|
|
|
|
|
|
|
|
${options.dev && `this._debugName = '${debugName}';`}
|
|
|
|
${options.dev && !generator.customElement &&
|
|
|
|
${options.dev && !generator.customElement &&
|
|
|
|
`if ( !options || (!options.target && !options._root) ) throw new Error( "'target' is a required option" );`}
|
|
|
|
`if ( !options || (!options.target && !options._root) ) throw new Error( "'target' is a required option" );`}
|
|
|
|
this.options = options;
|
|
|
|
this.options = options;
|
|
|
@ -160,7 +163,7 @@ export default function dom(
|
|
|
|
${options.dev &&
|
|
|
|
${options.dev &&
|
|
|
|
Array.from(generator.expectedProperties).map(
|
|
|
|
Array.from(generator.expectedProperties).map(
|
|
|
|
prop =>
|
|
|
|
prop =>
|
|
|
|
`if ( !( '${prop}' in this._state ) ) console.warn( "Component was created without expected data property '${prop}'" );`
|
|
|
|
`if ( !( '${prop}' in this._state ) ) console.warn( "${debugName} was created without expected data property '${prop}'" );`
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
${generator.bindingGroups.length &&
|
|
|
|
${generator.bindingGroups.length &&
|
|
|
|
`this._bindingGroups = [ ${Array(generator.bindingGroups.length)
|
|
|
|
`this._bindingGroups = [ ${Array(generator.bindingGroups.length)
|
|
|
@ -290,13 +293,12 @@ export default function dom(
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO deprecate component.teardown()
|
|
|
|
|
|
|
|
builder.addBlock(deindent`
|
|
|
|
builder.addBlock(deindent`
|
|
|
|
${options.dev && deindent`
|
|
|
|
${options.dev && deindent`
|
|
|
|
${name}.prototype._checkReadOnly = function _checkReadOnly ( newState ) {
|
|
|
|
${name}.prototype._checkReadOnly = function _checkReadOnly ( newState ) {
|
|
|
|
${Array.from(generator.readonly).map(
|
|
|
|
${Array.from(generator.readonly).map(
|
|
|
|
prop =>
|
|
|
|
prop =>
|
|
|
|
`if ( '${prop}' in newState && !this._updatingReadonlyProperty ) throw new Error( "Cannot set read-only property '${prop}'" );`
|
|
|
|
`if ( '${prop}' in newState && !this._updatingReadonlyProperty ) throw new Error( "${debugName}: Cannot set read-only property '${prop}'" );`
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
`}
|
|
|
|
`}
|
|
|
|