lib/actions/select-item.js
function getRangesFromCSSNode(node) {
	let ranges;

	if (node.type === 'rule') {
		ranges = [ getRange(node.selectorToken) ].concat(node.parsedSelector.map(getRange));
	} else if (node.type === 'at-rule') {
		const nameEndToken = node.expressionToken || node.nameToken;
		ranges = [
			new Range(node.nameToken.start, nameEndToken.end),
			getRange(node.nameToken),
			getRange(node.expressionToken)
		];
		node.parsedExpression.forEach(token => {
			ranges.push(getRange(token));
			iterateCSSToken(token, t => {
				if (t.type === 'argument') {
					ranges.push(getRange(t));
				}
			});
		});
	} else if (node.type === 'property') {
		ranges = [
			getRange(node),
			getRange(node.nameToken),
			getRange(node.valueToken)
		];
		node.parsedValue.forEach(value => {
			// parsed value contains a comma-separated list of sub-values,
			// each of them, it turn, may contain space-separated parts
			ranges.push(getRange(value));

			for (let i = 0, il = value.size, token; i < il; i++) {
				token = value.item(i);
				if (token.type === 'url') {
					ranges.push(getRange(token), getRange(token.item(0)));
				} else if (token.type !== 'whitespace' && token !== 'comment') {
					ranges.push(getRange(token));

					iterateCSSToken(token, t => {
						if (t.type === 'argument') {
							ranges.push(getRange(t));
						}
					});
				}
			}
		});
	}

	return ranges ? uniqueRanges(ranges.filter(Boolean)) : [];
}
function getRangesFromCSSNode(node) {
	let ranges;

	if (node.type === 'rule') {
		ranges = [ getRange(node.selectorToken) ].concat(node.parsedSelector.map(getRange));
	} else if (node.type === 'at-rule') {
		const nameEndToken = node.expressionToken || node.nameToken;
		ranges = [
			new Range(node.nameToken.start, nameEndToken.end),
			getRange(node.nameToken),
			getRange(node.expressionToken)
		];
		node.parsedExpression.forEach(token => {
			ranges.push(getRange(token));
			iterateCSSToken(token, t => {
				if (t.type === 'argument') {
					ranges.push(getRange(t));
				}
			});
		});
	} else if (node.type === 'property') {
		ranges = [
			getRange(node),
			getRange(node.nameToken),
			getRange(node.valueToken)
		];
		node.parsedValue.forEach(value => {
			// parsed value contains a comma-separated list of sub-values,
			// each of them, it turn, may contain space-separated parts
			ranges.push(getRange(value));

			for (let i = 0, il = value.size, token; i < il; i++) {
				token = value.item(i);
				if (token.type === 'url') {
					ranges.push(getRange(token), getRange(token.item(0)));
				} else if (token.type !== 'whitespace' && token !== 'comment') {
					ranges.push(getRange(token));

					iterateCSSToken(token, t => {
						if (t.type === 'argument') {
							ranges.push(getRange(t));
						}
					});
				}
			}
		});
	}

	return ranges ? uniqueRanges(ranges.filter(Boolean)) : [];
}
function getRangesFromCSSNode ( node ) { let ranges ; if ( node . type === 'rule' ) { ranges = [ getRange ( node . selectorToken ) ] . concat ( node . parsedSelector . map ( getRange ) ) ; } else if ( node . type === 'at-rule' ) { const nameEndToken = node . expressionToken || node . nameToken ; ranges = [ new Range ( node . nameToken . start , nameEndToken . end ) , getRange ( node . nameToken ) , getRange ( node . expressionToken ) ] ; node . parsedExpression . forEach ( token => { ranges . push ( getRange ( token ) ) ; iterateCSSToken ( token , t => { if ( t . type === 'argument' ) { ranges . push ( getRange ( t ) ) ; } } ) ; } ) ; } else if ( node . type === 'property' ) { ranges = [ getRange ( node ) , getRange ( node . nameToken ) , getRange ( node . valueToken ) ] ; node . parsedValue . forEach ( value => { // parsed value contains a comma-separated list of sub-values, // each of them, it turn, may contain space-separated parts ranges . push ( getRange ( value ) ) ; for ( let i = 0 , il = value . size , token ; i < il ; i ++ ) { token = value . item ( i ) ; if ( token . type === 'url' ) { ranges . push ( getRange ( token ) , getRange ( token . item ( 0 ) ) ) ; } else if ( token . type !== 'whitespace' && token !== 'comment' ) { ranges . push ( getRange ( token ) ) ; iterateCSSToken ( token , t => { if ( t . type === 'argument' ) { ranges . push ( getRange ( t ) ) ; } } ) ; } } } ) ; } return ranges ? uniqueRanges ( ranges . filter ( Boolean ) ) : [ ] ; }
Returns possible selection ranges from given CSS model node
@param  {Node} node
@return {Range[]}
Returns possible selection ranges from given CSS model node