Method String.splitSelector
- Calling Convention:
-
String.splitSelector()
- Parameters:
- none
- Returns:
-
An object of 'tag', 'id', and 'classes' based on if the string were a CSS style selector. Note that sibling and child selectors are not valid for this command.
- 'tag' will be the tag found in the selector or an empty string if none present
- 'id' will be the id in the selector or an empty string if none present
- 'classes' will be a spaced list of classes declared or an empty string if none present
The output format is meant for use with
_.make
, but is exposed to developers as it may prove useful for other tasks.
Example #1
JavaScript
var s = 'p#test.some.what';
console.log(s.splitSelector());
Output
Object: { content : '', special : '', classes : 'some what', id : 'test', tag : 'p' }
Example #2
JavaScript
var s = '#test~This is a test';
console.log(s.splitSelector());
Output
Object: { content : 'This is a test', special : '', classes : '', id : 'test', tag : '' }