-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63958 from Microsoft/octref/web-component
html.experimental.custom.tags/attributes for #62976
- Loading branch information
Showing
7 changed files
with
139 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
extensions/html-language-features/server/src/utils/tagDefinitions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { ITagSet, IAttributeSet, HTMLTagSpecification } from 'vscode-html-languageservice'; | ||
|
||
interface Tag { | ||
label: string; | ||
description: string; | ||
attributes: Attribute[]; | ||
} | ||
interface Attribute { | ||
label: string; | ||
description: string; | ||
} | ||
interface RawTagSet { | ||
tags: Tag[]; | ||
} | ||
interface RawAttributeSet { | ||
attributes: Attribute[]; | ||
} | ||
|
||
export function parseTagSet(source: string): ITagSet { | ||
const tagSet: ITagSet = {}; | ||
|
||
let rawTagSet: RawTagSet; | ||
try { | ||
rawTagSet = JSON.parse(source); | ||
} catch (err) { | ||
return {}; | ||
} | ||
|
||
rawTagSet.tags.forEach(c => { | ||
tagSet[c.label] = new HTMLTagSpecification(c.description, c.attributes.map(a => a.label)); | ||
}); | ||
|
||
return tagSet; | ||
} | ||
|
||
export function parseAttributes(source: string): IAttributeSet { | ||
const attributeSet: IAttributeSet = {}; | ||
|
||
let rawAttributeSet: RawAttributeSet; | ||
try { | ||
rawAttributeSet = JSON.parse(source); | ||
} catch (err) { | ||
return {}; | ||
} | ||
|
||
rawAttributeSet.attributes.forEach(ag => { | ||
attributeSet[ag.label] = { | ||
...ag | ||
}; | ||
}); | ||
|
||
return attributeSet; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters