Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function getContextualizedSelector( element, selector ) {
var escapedId = CKEDITOR.tools.escapeCss( element.$.id ),
selectorParts = selector.split( /,\s*/ ),
splitRegex = /([\.#\[\s\+>:]|[\^*]*=["']*|["']*[\]]$)/,
notEscapeCharacters = [ '', ' ', '+', '>', '[', ']', '.', '#', '=', '"', "'", '^', '*', ':' ],
currentPart,
escapedPart,
i,
j;
for ( i = 0; i < selectorParts.length; i++ ) {
currentPart = CKEDITOR.tools.trim( selectorParts[ i ] ).split( splitRegex );
escapedPart = '';
for ( j = 0; j < currentPart.length; j++ ) {
escapedPart += CKEDITOR.tools.indexOf( notEscapeCharacters, currentPart[ j ].charAt( 0 ) ) === -1 ?
CKEDITOR.tools.escapeCss( currentPart[ j ] ) : currentPart[ j ];
}
selectorParts[ i ] = escapedPart;
}
return '#' + escapedId + ' ' + selectorParts.join( ', #' + escapedId + ' ' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.