本文整理匯總了TypeScript中polymer-analyzer.ParsedHtmlDocument.sourceRangeForAttribute方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ParsedHtmlDocument.sourceRangeForAttribute方法的具體用法?TypeScript ParsedHtmlDocument.sourceRangeForAttribute怎麽用?TypeScript ParsedHtmlDocument.sourceRangeForAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類polymer-analyzer.ParsedHtmlDocument
的用法示例。
在下文中一共展示了ParsedHtmlDocument.sourceRangeForAttribute方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getAttributeAstLocation
/**
* If the position is inside of the node's attributes section, return the
* correct LocationResult.
*/
function getAttributeAstLocation(
node: parse5.ASTNode,
position: SourcePosition,
document: ParsedHtmlDocument,
location: Parse5Location): AttributesSection|AttributeValue|undefined {
/**
* TODO(rictic): upstream to @types the fact that regular locations (not just
* element locations) can have attrs sometimes.
*/
const attrs: parse5.AttributesLocationInfo =
(isElementLocationInfo(location) && location.startTag.attrs) ||
location['attrs'] || {};
for (const attrName in attrs) {
const range = document.sourceRangeForAttribute(node, attrName);
if (isPositionInsideRange(position, range)) {
if (isPositionInsideRange(
position,
document.sourceRangeForAttributeValue(node, attrName))) {
return {kind: 'attributeValue', attribute: attrName, element: node};
}
return {kind: 'attribute', attribute: attrName, element: node};
}
}
}