Microsoft/TypeScript

`HTMLMetaElement` property descriptions

Open

#48,451 建立於 2022年3月27日

在 GitHub 查看
 (5 留言) (0 反應) (0 負責人)TypeScript (6,726 fork)batch import
BugDomain: lib.d.tsHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

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

貢獻者指南