Elementals.js

Latest Version: 3.6.4 PRODUCTION 13 April 2018

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 an empty string if none present
  2. 'id' will be the id in the selector or an empty string if none present
  3. '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 : ''
}

Elementals String Methods

Elementals Extensions

Polyfills

These link to the Mozilla Developer Network (MDN)

Property Key

  • Object
  • Method or Variable
  • "Constant" Variable

Downloads

Advertisement