Elementals.js

Latest Version: 3.4 PRODUCTION 18 November 2017

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.

  1. 'tag' will be the tag found in the selector or div if none is present
  2. 'id' will be the id in the selector or boolean false if none is present
  3. 'classes' will be a spaced list of classes declared, or boolean false if none are present.

The output format is meant for use with _.make.

Example #1

JavaScript
var s = 'p#test.some.what';
console.log(s.splitSelector());
Output
Object: {
	tag : 'p',
	id : 'test',
	classes : 'some what'
}

Example #2

JavaScript
var s = '#test';
console.log(s.splitSelector());
Output
Object: {
	tag : 'div',
	id : 'test',
	classes : false
}

Advertisement