Microsoft/TypeScript

`HTMLMetaElement` property descriptions

Open

#48 451 ouverte le 27 mars 2022

Voir sur GitHub
 (5 commentaires) (0 réactions) (0 assignés)TypeScript (6 726 forks)batch import
BugDomain: lib.d.tsHelp Wanted

Métriques du dépôt

Stars
 (48 455 stars)
Métriques de merge PR
 (Merge moyen 6j 17h) (9 PRs mergées en 30 j)

Description

lib Update Request

Configuration Check

I'm using VS-Code with Typescript Version 4.7.0-dev.20220323 installed in local repo.

Missing / Incorrect Descriptions

HTMLMetaElement properties:

  • name
  • content
  • httpEquiv
  • media

Sample Code

<!DOCTYPE html>
<html lang="en">

<head>
	<!-- meta tags for social media-->
	<meta	name="title"	content="blabla">
	…
</head>

<body>
	…
</body>

</html>
/**
 * `getElementsByTagName` returns a {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection HTMLCollection},\
 * which is an `Array-like` object similar to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments arguments},\
 * therefore we need to convert it to a real {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array Array},\
 * containing {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMetaElement HTMLMetaElement}'s,\
 * to be able to use Array-Methods on it.
 */
const	metaTitle =	[...document.head.getElementsByTagName('meta')]
			.find(meta => meta.name === 'title')
	,origTitle =	metaTitle?.content

document.title = metaTitle ? `${origTitle}${extraText}` : 'someOtherText'

In VS-Code hover-over the name/content properties in above code.

  • name It should display something similar to: Gets or sets the value of the name property of the element.
  • content It should display something similar to: Gets or sets the value of the content property of the element.
  • The other mentioned properties have similar issues.

Documentation Link

Guide contributeur