MCPcopy Create free account
hub / github.com/angular/components / sanityCheckListItemContent

Function sanityCheckListItemContent

src/material/list/list-base.ts:329–350  ·  view source on GitHub ↗

* Sanity checks the configuration of the list item with respect to the amount * of lines, whether there is a title, or if there is unscoped text content. * * The checks are extracted into a top-level function that can be dead-code * eliminated by Terser or other optimizers in production mode.

(item: MatListItemBase)

Source from the content-addressed store, hash-verified

327 * eliminated by Terser or other optimizers in production mode.
328 */
329function sanityCheckListItemContent(item: MatListItemBase) {
330 const numTitles = item._titles!.length;
331 const numLines = item._lines!.length;
332
333 if (numTitles > 1) {
334 console.warn('A list item cannot have multiple titles.');
335 }
336 if (numTitles === 0 && numLines > 0) {
337 console.warn('A list item line can only be used if there is a list item title.');
338 }
339 if (
340 numTitles === 0 &&
341 item._hasUnscopedTextContent &&
342 item._explicitLines !== null &&
343 item._explicitLines > 1
344 ) {
345 console.warn('A list item cannot have wrapping content without a title.');
346 }
347 if (numLines > 2 || (numLines === 2 && item._hasUnscopedTextContent)) {
348 console.warn('A list item can have at maximum three lines.');
349 }
350}

Callers 1

_updateItemLinesFunction · 0.85

Calls 1

warnMethod · 0.80

Tested by

no test coverage detected