-
-
Save Comandeer/de6c832993a8b9c21b01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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