@@ -36,7 +36,7 @@ let requestUpdateThenable: (name: string) => {
3636 ) => void ;
3737} ;
3838
39- let issueWarning : ( warning : string ) => void ;
39+ let issueWarning : ( code : string , warning : string ) => void ;
4040
4141if ( DEV_MODE ) {
4242 // Ensure warnings are issued only 1x, even if multiple versions of Lit
@@ -45,17 +45,17 @@ if (DEV_MODE) {
4545 ( globalThis . litIssuedWarnings ??= new Set ( ) ) ;
4646
4747 // Issue a warning, if we haven't already.
48- issueWarning = ( warning : string ) => {
48+ issueWarning = ( code : string , warning : string ) => {
49+ warning += ` See https://lit.dev/msg/${ code } for more information.` ;
4950 if ( ! issuedWarnings . has ( warning ) ) {
5051 console . warn ( warning ) ;
5152 issuedWarnings . add ( warning ) ;
5253 }
5354 } ;
5455
5556 issueWarning (
56- `Lit is in dev mode. Not recommended for production! See ` +
57- `https://lit.dev/docs/tools/development/` +
58- `#development-and-production-builds for more information.`
57+ 'dev-mode' ,
58+ `Lit is in dev mode. Not recommended for production!`
5959 ) ;
6060
6161 // Issue platform support warning.
@@ -64,10 +64,9 @@ if (DEV_MODE) {
6464 globalThis . reactiveElementPlatformSupport === undefined
6565 ) {
6666 issueWarning (
67+ 'polyfill-support-missing' ,
6768 `Shadow DOM is being polyfilled via \`ShadyDOM\` but ` +
68- `the \`polyfill-support\` module has not been loaded. See ` +
69- `https://lit.dev/docs/tools/requirements/#polyfills ` +
70- `for more information.`
69+ `the \`polyfill-support\` module has not been loaded.`
7170 ) ;
7271 }
7372
@@ -77,6 +76,7 @@ if (DEV_MODE) {
7776 _onrejected ?: ( ) => void
7877 ) => {
7978 issueWarning (
79+ 'request-update-promise' ,
8080 `The \`requestUpdate\` method should no longer return a Promise but ` +
8181 `does so on \`${ name } \`. Use \`updateComplete\` instead.`
8282 ) ;
@@ -615,17 +615,19 @@ export abstract class ReactiveElement
615615 this . elementStyles = this . finalizeStyles ( this . styles ) ;
616616 // DEV mode warnings
617617 if ( DEV_MODE ) {
618- [ `initialize` , `requestUpdateInternal` , `_getUpdateComplete` ] . forEach (
619- ( name : string ) => {
620- if ( this . prototype . hasOwnProperty ( name ) ) {
621- issueWarning (
622- `\`${ name } \` is implemented on class ${ this . name } . It ` +
623- `has been removed from this version of \`ReactiveElement\`.` +
624- ` See the changelog at https://github.com/lit/lit/blob/main/packages/reactive-element/CHANGELOG.md`
625- ) ;
626- }
618+ const warnRemovedOrRenamed = ( name : string , renamed = false ) => {
619+ if ( this . prototype . hasOwnProperty ( name ) ) {
620+ issueWarning (
621+ renamed ? 'renamed-api' : 'removed-api' ,
622+ `\`${ name } \` is implemented on class ${ this . name } . It ` +
623+ `has been ${ renamed ? 'renamed' : 'removed' } ` +
624+ `in this version of LitElement.`
625+ ) ;
627626 }
628- ) ;
627+ } ;
628+ warnRemovedOrRenamed ( 'initialize' ) ;
629+ warnRemovedOrRenamed ( 'requestUpdateInternal' ) ;
630+ warnRemovedOrRenamed ( '_getUpdateComplete' , true ) ;
629631 }
630632 return true ;
631633 }
@@ -902,6 +904,7 @@ export abstract class ReactiveElement
902904 attrValue === undefined
903905 ) {
904906 issueWarning (
907+ 'undefined-attribute-value' ,
905908 `The attribute value for the ${ name as string } property is ` +
906909 `undefined on element ${ this . localName } . The attribute will be ` +
907910 `removed, but in the previous version of \`ReactiveElement\`, ` +
@@ -1093,17 +1096,15 @@ export abstract class ReactiveElement
10931096 ) ;
10941097 if ( shadowedProperties . length ) {
10951098 issueWarning (
1099+ 'class-field-shadowing' ,
10961100 `The following properties on element ${ this . localName } will not ` +
10971101 `trigger updates as expected because they are set using class ` +
10981102 `fields: ${ shadowedProperties . join ( ', ' ) } . ` +
10991103 `Native class fields and some compiled output will overwrite ` +
11001104 `accessors used for detecting changes. To fix this issue, ` +
11011105 `either initialize properties in the constructor or adjust ` +
11021106 `your compiler settings; for example, for TypeScript set ` +
1103- `\`useDefineForClassFields: false\` in your \`tsconfig.json\`.` +
1104- `See https://lit.dev/docs/components/properties/#declare and ` +
1105- `https://lit.dev/docs/components/decorators/` +
1106- `#avoiding-issues-with-class-fields for more information.`
1107+ `\`useDefineForClassFields: false\` in your \`tsconfig.json\`.`
11071108 ) ;
11081109 }
11091110 }
@@ -1163,6 +1164,7 @@ export abstract class ReactiveElement
11631164 ) >= 0
11641165 ) {
11651166 issueWarning (
1167+ 'change-in-update' ,
11661168 `Element ${ this . localName } scheduled an update ` +
11671169 `(generally because a property was set) ` +
11681170 `after an update completed, causing a new update to be scheduled. ` +
@@ -1323,8 +1325,8 @@ if (DEV_MODE) {
13231325( globalThis . reactiveElementVersions ??= [ ] ) . push ( '1.0.0-rc.3' ) ;
13241326if ( DEV_MODE && globalThis . reactiveElementVersions . length > 1 ) {
13251327 issueWarning ! (
1328+ 'multiple-versions' ,
13261329 `Multiple versions of Lit loaded. Loading multiple versions ` +
1327- `is not recommended. See https://lit.dev/docs/tools/requirements/ ` +
1328- `for more information.`
1330+ `is not recommended.`
13291331 ) ;
13301332}
0 commit comments