MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / scope

Function scope

code/styling/public/app.js:23010–23060  ·  view source on GitHub ↗

* Scope * * @param {string} parent * @param {string} current * @param {number} invert * @param {number} level * @return {string}

(parent, current, invert, level)

Source from the content-addressed store, hash-verified

23008 * @return {string}
23009 */
23010 function scope (parent, current, invert, level) {
23011 var selector = current
23012 var code = selector.charCodeAt(0)
23013
23014 // trim leading whitespace
23015 if (code < 33) {
23016 code = (selector = selector.trim()).charCodeAt(0)
23017 }
23018
23019 switch (code) {
23020 // &
23021 case AND: {
23022 switch (cascade + level) {
23023 case 0:
23024 case 1: {
23025 if (parent.trim().length === 0) {
23026 break
23027 }
23028 }
23029 default: {
23030 return selector.replace(andptn, '$1'+parent.trim())
23031 }
23032 }
23033 break
23034 }
23035 // :
23036 case COLON: {
23037 switch (selector.charCodeAt(1)) {
23038 // g in :global
23039 case 103: {
23040 if (escape > 0 && cascade > 0) {
23041 return selector.replace(escapeptn, '$1').replace(andptn, '$1'+nscope)
23042 }
23043 break
23044 }
23045 default: {
23046 // :hover
23047 return parent.trim() + selector.replace(andptn, '$1'+parent.trim())
23048 }
23049 }
23050 }
23051 default: {
23052 // html &
23053 if (invert*cascade > 0 && selector.indexOf('\f') > 0) {
23054 return selector.replace(andptn, (parent.charCodeAt(0) === COLON ? '' : '$1')+parent.trim())
23055 }
23056 }
23057 }
23058
23059 return parent + selector
23060 }
23061
23062 /**
23063 * Property

Callers 1

selectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected