extensions/emmet/src/selectItemHTML.ts/getPrevAttribute
function getPrevAttribute(document: vscode.TextDocument, selectionStart: number, selectionEnd: number, node: HtmlNode): vscode.Selection | undefined {
	if (!node.attributes || node.attributes.length === 0 || node.type === 'comment') {
		return;
	}

	for (let i = node.attributes.length - 1; i >= 0; i--) {
		const attr = node.attributes[i];
		if (selectionStart <= attr.start) {
			continue;
		}

		if (!attr.value || attr.value.start === attr.value.end || selectionStart < attr.value.start) {
			// select full attr
			return offsetRangeToSelection(document, attr.start, attr.end);
		}

		if (selectionStart === attr.value.start) {
			if (selectionEnd >= attr.value.end) {
				// select full attr
				return offsetRangeToSelection(document, attr.start, attr.end);
			}
			// select attr value
			return offsetRangeToSelection(document, attr.value.start, attr.value.end);
		}

		// Fetch the prev word in the attr value
		const selectionStartCharacter = document.positionAt(selectionStart).character;
		const attrValueStartCharacter = document.positionAt(attr.value.start).character;
		const pos = selectionStart > attr.value.end ? attr.value.toString().length :
			selectionStartCharacter - attrValueStartCharacter;
		const [newSelectionStartOffset, newSelectionEndOffset] = findPrevWord(attr.value.toString(), pos);
		if (newSelectionStartOffset === undefined || newSelectionEndOffset === undefined) {
			return;
		}
		if (newSelectionStartOffset >= 0 && newSelectionEndOffset >= 0) {
			const newSelectionStart = attr.value.start + newSelectionStartOffset;
			const newSelectionEnd = attr.value.start + newSelectionEndOffset;
			return offsetRangeToSelection(document, newSelectionStart, newSelectionEnd);
		}
	}

	return;
}