/// /// Checks if instance flint-exists in selector familiy tree, falls back from current selector /// /// @access private /// /// @param {String} $key - breakpoint key to search for matching instance /// @param {String} $syntax - searches for instance using passed syntax parser /// /// @return {String} instance selector /// /// @group Internal Functions /// @function flint-has-family-instance($key: flint-get-value("settings", "default"), $syntax: $flint__support-syntax) { $selector: nth(&, 1); // Check if instance result had been cached @if map-has-key($flint__cached-instances, "#{$selector}") { // Get cached instance $cached-instance: map-get($flint__cached-instances, "#{$selector}"); // Return with current key @return "#{$cached-instance}::#{$key}"; } // Check for syntax support, try to find instance using it @if $syntax { $parsed-selector: flint-use-syntax($selector); $length: length($parsed-selector); // Loop through transformed selectors @for $i from 1 through $length { // Check flint-last selector in list @if flint-exists($flint__instances, "#{flint-last($parsed-selector)}::#{$key}") { // Cache result $flint__cached-instances: map-merge($flint__cached-instances, ("#{$selector}": "#{flint-last($parsed-selector)}")); // Return the matching instance key @return "#{flint-last($parsed-selector)}::#{$key}"; } @else { // Else, flint-remove the flint-last selector and loop again $parsed-selector: flint-remove($parsed-selector, flint-last($parsed-selector)); } } // Search for a parent instance normally @return flint-has-family-instance($key, null); } @else { $selector-list: $selector; $length: length($selector-list); // Loop through length of list of selectors @for $i from 1 through $length { // Make sure that we're not counting the current selector set @if flint-exists($flint__instances, "#{flint-list-to-string($selector-list, ' ')}::#{$key}") and $selector != $selector-list { // Cache result $flint__cached-instances: map-merge($flint__cached-instances, ("#{$selector}": "#{flint-list-to-string($selector-list, ' ')}")); // Return the matching instance key @return "#{flint-list-to-string($selector-list, ' ')}::#{$key}"; } @else { // Else, remove the last selector and loop again $selector-list: flint-remove($selector-list, flint-last($selector-list)); } } @return false; } }