“There’s something new in western swing music,” declared a 1975 article in the Denton (Texas) Record-Chronicle. “And it’s no gimmick … in fact it’s just a brand new sound by a lady named Ruby Falls. Miss Falls is black — and to my knowledge, this the first attempt at black female western swing music on record — or at least the first I’ve heard.”
Falls wasn’t the first Black woman to attempt a career in country music — just six years prior, Linda Martell’s “Color Him Father” rose to No. 22 on the Billboard Hot Country Songs chart, a record that still stands — but the mid-’70s was a renaissance of sorts. Lenora Ross signed to RCA Nashville (Charley Pride’s label) in ’75, while Virginia Kirby, Barbara Cooper, and Falls launched independent careers. The press was supportive, as were many fans, but a lack of real traction stalled any forward movement. “If something doesn’t happen real soon I may have to change my name,” Falls said in 1979. “How do you think ‘Ruby Fails’ would sound?” Seven years later, Falls died of a brain hemorrhage at the age of 40. An obituary written by the Associated Press noted that she’d left the music business and was working at a computer firm.
In the early ’90s, Cleve Francis, a Virginia-based cardiologist, took a swing at country music’s mainstream and was able to scratch out some early success, namely by self-financing a video for the song “Love Light.” The track was featured on Francis’s 1990 album Last Call for Love, released by the independent label Playback, and though the music itself didn’t garner much buzz, getting the “Love Light” video played on Country Music Television was enough to pique the interest of a Nashville label. But here’s where the story repeats itself: Francis’s last project was released in ’94; a few years later, he was back to practicing medicine full time. Before he left town, though, he kick-started what would become the Black Country Music Association, a group designed to provide community for Black country artists and, ideally, help them achieve tangible, sustainable success. “They let you into the restaurant, they let you be the first to do this or that,” Francis recently told Rolling Stone about the ways of the country-music industry. “Well, I figured, we can stop this. We can give other blacks an avenue to come in, through this organization.”
Aspiring artist and songwriter Frankie Staton took over the BCMA and, after reading a 1996 New York Times article that dismissed systemic racism and instead attributed the lack of Black artists in the genre to a lack of Black interest and talent (“Nashville’s new broadened constituency, which is both younger and better educated than in the past, makes such blanket dismissals hard to support,” wrote Bruce Feiler), decided to expand on the BCMA’s mission. For years she hosted Black country-music showcases, filling a stage with Black artists so undeniably good — so undeniably country — that they began to receive requests to take the show on the road. Nisha Jackson, the 1987 winner of TNN’s You Can Be a Star was a featured performer in February 1998. Despite winning the competition and landing a deal with Capitol Records in 1998, Jackson never actually became a star. She was dropped by the record label in 1990 and joined Staton’s showcases, hoping they would lead to a second-chance breakthrough.
Again, though, the measure of country music’s improvements never extended beyond the shallow, fleeting support of a handful of artists; the lines of (white) folks that spilled onto the sidewalk in front of the Bluebird Café for Staton’s showcasesand the reporters who came to witness these would-be Black country stars and their rabid fans did nothing to force the hand of the industry. “We don’t know how to market you,” label execs said. “Country radio will never play you,” radio promoters said. “Country fans don’t want to listen to you,” program directors said. At the same time, Staton’s demonstrated proficiency in identifying and developing Black talent failed to materialize into a gig as an industry receptionist, let alone as an A&R rep. By the mid-aughts, she was juggling piano gigs at local restaurants and bars, piecing together enough cash to give her Black son the advantage of a private-school education in a still-segregated town. Black country singers Miko Marks and Rissi Palmer came to town soon after, their current outside-the-industry success (via a nonprofit, Bay-area record label and an Apple-hosted podcast, respectively) a clear rebuke of their all-too-familiar experiences in Nashville.
Today, there are lots of people who, when asked about the current state of country music, will say that the industry is making “progress.” They forget that the story has already been written, that the script has a predetermined victor in its white male hero, that the illusion of anything contrary is only meant to keep things interesting — and only temporarily. For these people, the current crop of up-and-coming Black country artists and the subsequent support from the press looks like the hopeful rise of an egalitarian sun, the dawn of a new day in which country music will finally break free from its shameful past. They don’t consider that the country-music industry hasn’t made a single notable Black hire in the last year, that one of the earliest catalysts for country music’s “reckoning” — the changing of Lady Antebellum’s name to an abbreviated version … of the same name … that already belonged to the blues singer Lady A— is drenched in the insensitivity and nod to white supremacy it claimed to address. What’s worse, they don’t know the stories of Falls or Francis orStaton, how,despite their enthusiasm and expectation, they were pushed up against the same glaringly white walls that current artists face and wereleft broken from the impact. They can’t imagine the ways those artists were eventually brushed aside and, with cyclical predictability, expunged from collective memory. If they did, they would know better. Andif they understood how perfectly history repeats itself, how the unexamined past is the best predictor of the future,they would see the suddenly Blacker awards-show stages and the swirling excitement for what it is — but, more crucially, what it isn’t.
The last year has shades of 1975, of 1998, of 2007, when Palmer made her Opry debut and released the declarative “Country Girl,” which peaked at No. 54 on Billboard’s Hot Country Songs chart. From summer2020 through fall and early winter this year, country music went out of its way to lift new Black voices, to show a more progressive side of itself. Even the N-word video from Morgan Wallen, the industry’s platinum playboy, seemed to present only a minor hiccup. Leaked on February 2, the clip drew an immediate line in the sand settled beneath country music’s foundation and forced everyone to choose a side. They did, of course, and as quickly as there were artists and fans who denounced the word and behavior, declaring that it had no place in an industry working toward a more inclusive future and demanding Wallen’s accountability, there were others who took a different approach. There was the pointing of fingers to the N-word’s use in hip-hop, to Wallen’s excessive drinking, to the fact that the man whom Wallen referred to as a p***y-a** n****r was actually Wallen’s Black friend, his existence therefore absolving Wallen of any actual racism. The most significant of these voices, however, was the industry itself, a sign that, perhaps, country music was finally willing torid itself of rot and hollow rhetoric. The ACMs declared Wallen ineligible for the in-process awards cycle; his music disappeared from terrestrial and satellite radio; his label, Big Loud, suspended him.
Meanwhile, the backlash from Wallen’s supporters was swift and furious. Already at the top of Billboard’s200chart pre-N-word, Wallen’s Dangerous: The Double Album remained there for seven weeks after, buoyed by fans who streamed and purchased in record numbers. They called radio stations, asking that Wallen be reinstated while bemoaning “cancel culture.” Andthey hurled vicious cyber threats toward those within the industry who dared to call Wallen out, including Mickey Guyton and Maren Morris. In a video posted to social media on February 10, Wallen urged “those who still see something in me and have defended me” to stop, adding, “I fully accept any penalties I’m facing.” The defense didn’t stop, though, and a February 5 report that country-music execs believed Wallen’s banishment should last “for six months to a year or longer” started to seem like a wild overestimation for the artist with the biggest album in all of music — more significantly, for the artist who reached the pinnacle by way of a segregated industry that has always privatelyaccepted the behavior that had now been caught on film.
It can’t be overstated how much Wallen is but a symptom of country music’s chronic racism, and while he should beheld fully accountable for his actions, the more critical care should be directed toward the industry that got him and itself in this mess. But that would require an admission of sickness, and at this point, there’s been none. In all of the months leading up to the Wallen incident and after, there has been no corporate penance. There was no commitment to the high-level hiring of Black folks who could have an immediate impact on the industry’s diversity issues; there wasn’t even anindustry acknowledgement of its refusal to welcome the descendants of those who helped to create this genre, even as that exclusion became a harbor provided to card-carrying racists. The people who slip into Mickey Guyton’s mentions when she posts a video of her singing or a photo of her son, who call her the N-word and accuse her of trying to turn country music “ghetto”? They feel welcome here; they believe country music is their home. And for the last hundred years, the industry has agreed. It has stopped the architects and builders at the door, making them feel like unwanted guests and accepting only a handful for temporary stays, all while allowing the long-term occupants to turn something once shared and sacred into a shrine of their own sins.
It wasn’t a surprise, then, when the announcement came in, quietly, on a Friday afternoon, that the Country Music Association decided, just three and a half weeks post-N-word and sans press release, that Morgan Wallen’s eligibility would be “amended” for the 2021 awards cycle. Reports that Wallen had, perhaps, not quite “done the work” were already circulating: Wallen’s first public appearance was at Kid Rock’s Big Ass Honky Tonk Rock N Roll Steakhouse of all places, and his faithful followers were continuing to spew their venom. To the CMA, however, it was important to maintain Wallen’s eligibility in the categories of Single, Song, Album, Musical Event, and Music Video of the Year, “so as not to limit opportunity for other credited collaborators.” Never mind that the list of collaborators on Dangerous is starkly white, as is the board that voted on this decision, save for Jimmie Allen. The CMA is the most prominent and prestigious organization in all of country music, with its self-appointed dedication “to bringing the poetry and emotion of Country Music to the world.” It plays a role in shaping the industry it’s all too happy to lead, as well as its surrounding community. So it’s also not surprising that, as of this writing, Wallen’s radiosuspensionhas been largely revoked, his music once again spinning regularly, across nearly all of country radio.
The pat explanation for country music’s enduring racism is that, in the 1920s, the industry was designed that way, that Black people weren’t forced out as much as they were told we never belonged in the first place. The more truthful, more nuanced, answer is that the initial color line drawn by the industry has been repeatedly darkened over time, traced over and over by each new wave of industry executives. History may be written around the big events — the births and deaths, wars waged and won, the cases tried and laws passed — but it is made in the interim: the private conversations, the secret negotiations, the votes cast beyond the reach of photographers’ lenses and reporters’ pens.
When people say they want a family, they don’t suddenly manifest a 50-year wedding anniversary and three grown, well-adjusted children. They find partners with whom they must learn to coexist and get along; they are given kids who must be nurtured and taught and fed at inconvenient hours. Somehow, though, the decision-makers in country music who claim to want betterbelieve this transformed industry will just magically appear, notwithstanding their constant support of the opposite. And this isn’t just happening on the corporate level. Of all of Wallen’s collaborators — whose creative output, the CMA has decided, is more important than a no-excuses stand against racism — only Jason Isbell, who wrote “Cover Me Up,” made an effort to publicly address his involvement with Dangerous, as well as his support of this long-overdue reckoning. “Wallen’s behavior is disgusting and horrifying,” he tweeted on February 3. “I think this is an opportunity for the country music industry to give that spot to somebody who deserves it, and there are lots of black artists who deserve it.” (On February 10, Isbell also announced that all of his revenue earned from Dangerous, up to that point, would be donated to the Nashville chapter of the NAACP.)
But if the mid-’70s and subsequent eras have shown us nothing else, opening up select spots for Black artists isn’t enough. Making room matters, but championing diversity without creating an environment in which it can actually flourish is an exercise in performative futility, a Juneteenth celebration without an honest assessment of the enduring effects of slavery — or earnest efforts to rectify them. Without structural change, those given “opportunity” are bound to fail, the “progress” destined to be short lived. And whileno one in the modern industry can openly state that country music is still the exclusive domain of white folks, they can certainly create a safe space for racism and intolerance. In the case of the genre’s biggest artist — a man who became more successful after a drunken, hateful rage — they can also put on a good face and expresstheir disgust. Then, just a few months later, they can act as if it never happened.
By submitting your email, you agree to our
Terms and Privacy Notice
and to receive email correspondence from us. This site is protected by reCAPTCHA and the Google
Privacy Policy and
Terms of Service apply.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
Already a subscriber?
Already a subscriber?
`;
// integrate Sub(x) scripts and elements
if (hostname !== 'subs.nymag.com') { // do not integrate on this subdomain
document.head.appendChild(trackingScript);
document.body.insertAdjacentHTML('beforeend', subXAnimationElements);
}
There was an error processing the request. Please try again later."}).catch(e=>console.error("Error verifying email: ",e)))(r.querySelector(".content"),o.bannerCTAVerification)})):(l.remove(),s.remove()),o.dismissable||n.remove(),o.useAlertIcon||a.remove(),r.classList.add("show"),n.addEventListener("click",()=>{u(),r.classList.remove("show")})}else r.remove()}});
}, {"1":1,"6":6,"12":12,"35":35,"40":40}];
window.modules["global-nav.client"] = [function(require,module,exports){"use strict";const dom=require(3),auth=require(12),signInButton=dom.find(".user-signin"),signOutButton=dom.find(".user-signout"),globalNav=dom.find('[class^="global-nav"]'),body=dom.find("body"),dropdownItems=dom.findAll(".dropdown-wrap"),gtm=require(1),appendLandingPageParams=require(136),pageUri=require(124).getPageUri(),subscriptionPromoLinks=dom.findAll(".persist-params"),searchString=window.location.search||"";function closeDropdowns(e){let n=globalNav.querySelectorAll(".dropdown.open");dropdownItems.forEach(function(t){let o=t.querySelector(".dropdown");!n||t.contains(e.target)&&27!==e.keyCode||o.classList.remove("open")})}function gtmSendReport(e,n,t){let o={eventCategory:"ecommerce",eventAction:"componentClick",brand:e,dimension23:"global-nav",list:pageUri,pageZone:"header",variant:"nav-link"};"global-nav-link"===t&&(o.eventLabel=n.href),gtm.reportNow(o)}function updateElementTargetUrlsIfQueryStrings(e){if(searchString){const n=new URLSearchParams(searchString);let t=e.href;if(t.includes("?")){const o=t.split("?"),i=new URLSearchParams(o[1]);for(let e of n.entries())i.set(e[0],e[1]);t=`${o[0]}?${i.toString()}`,e.href=t}else e.href=`${t}?${n.toString()}`}}function init(e){const n=e.querySelectorAll(".to-landing-page");window.addEventListener("auth:init",()=>{signInButton.addEventListener("click",function(e){e.preventDefault(),auth.showEmbeddedLoginFlow("top navigation")}),signOutButton.addEventListener("click",function(e){e.preventDefault(),gtmSendReport("Sign Out",e.target,"user-info-link"),auth.logout()}),auth.isAuthenticated()&&e.classList.add("signed-in"),auth.isSubscriber()&&e.classList.add("subscribed"),e.querySelectorAll(".user-link").forEach(e=>{e.classList.add("active")}),subscriptionPromoLinks.forEach(e=>{updateElementTargetUrlsIfQueryStrings(e)}),appendLandingPageParams(n)})}dropdownItems.forEach(function(e){e.addEventListener("click",function(){e.querySelector(".dropdown").classList.toggle("open")})}),body.addEventListener("click",closeDropdowns),document.addEventListener("keydown",closeDropdowns),globalNav.addEventListener("click",function(e){let n=e.target;n.classList.contains("global-nav-track")&>mSendReport(n.text,n,"global-nav-link")}),module.exports=init;
}, {"1":1,"3":3,"12":12,"124":124,"136":136}];
window.modules["aaa-module-mounting.legacy"] = [function(require,module,exports){"use strict";const _pickBy=require(221),_each=require(408),Fingerprint2=require(407),DS=require(406),Eventify=require(246);function registerGlobals(){window.DS=DS,window.Eventify=Eventify,window.Fingerprint2=Fingerprint2,DS.value("Eventify",Eventify),DS.value("Fingerprint2",Fingerprint2),DS.value("$document",window.document),DS.value("$window",window)}function mountDollarSliceComponents(){DS.service("components",["$document","$module",function(e,n){var o=_pickBy(n.definitions,e=>e.providerStrategy===n.providers.controller),r=Object.keys(o);function t(e){return o=>{try{n.get(e,o)}catch(e){logMountError(o,e)}}}_each(r,n=>{var o=e.querySelectorAll('[data-uri*="/_components/'+n+'/"]'),r=e.querySelectorAll('[data-uri$="/_components/'+n+'"]');_each(o,t(n)),_each(r,t(n))}),this.components=r}]),DS.get("components")}function logMountError(e,n){const o=e.outerHTML.slice(0,e.outerHTML.indexOf(e.innerHTML));console.error("Error attaching controller to "+o,n)}registerGlobals(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{mountDollarSliceComponents()}):mountDollarSliceComponents();
}, {"221":221,"246":246,"406":406,"407":407,"408":408}];
window.modules["ads.legacy"] = [function(require,module,exports){"use strict";const _map=require(118),_forEach=require(107),_isString=require(268),_intersectionWith=require(409),_isEqual=require(274),_each=require(408),_debounce=require(182),_sortBy=require(205),page=require(124),visit=require(114);DS.service("adService",["Eventify","$cid","$document","$window",function(e,t,a,i){var o,n,s,r,d,c,u,l,g={},p=this,h=[],f=visit.getQueryParamsObject(["utm_campaign"]),m=document.querySelector('script[data-type="ad-a9"]'),b=[],w=!1,v=[],y=document.querySelector('script[data-name="ad-doubleverify"]');document.querySelector('script[data-name="concert-ads"]')||(i.NYM={},i.NYM.analytics={},i.NYM.analytics.adStartTime=i.performance.now(),i.googletag=i.googletag||{},i.googletag.cmd=i.googletag.cmd||[],u=i.googletag,(m||y)&&(i.googletag.cmd=i.googletag.cmd||[],i.googletag.cmd.push(function(){i.googletag.pubads().disableInitialLoad()})),m&&(l=i.setInterval(function(){void 0!==window.apstag&&void 0!==window.apstag.timeout&&(i.clearInterval(l),window.apstag.cleared=!0,l=null)},10),setTimeout(function(){l&&(i.clearInterval(l),i.googletag.pubads().refresh(),window.apstag||console.log("MESSAGE: Timeout for A9 load exceeded, aborting"))},500)),y&&(b.push(new Promise(function(e){w?e():v.push(e)})),c=i.setTimeout(T,2500)),o=function(e){var t,a,o=e.data,n=[];return o.loaded?e:(o.loaded=!0,t=null,(t=o.sizes?u.defineSlot(o.name,o.sizes,o.id).addService(u.pubads()):u.defineOutOfPageSlot(o.name,o.id).addService(u.pubads())).setTargeting("adid",o.id),f.hasOwnProperty("utm_campaign")&&t.setTargeting("utmcamp",f.utm_campaign),a=p.getAdCount(o.label),t.setTargeting("label",o.label+"_"+o.site+"-"+a),u.display(o.id),u.pubads().addEventListener("slotOnload",function(){i.NYM.analytics.firstAdLoadTime||(i.NYM.analytics.firstAdLoadTime=i.performance.now(),i.NYM.analytics.firstAdLoadLabel=e.data.label)}),n=_(o),Promise.all(b).then(function(){n?window.apstag&&window.apstag.cleared?window.apstag.fetchBids({slots:[n],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([t],{changeCorrelator:!1})})}):y&&u.pubads().refresh([t],{changeCorrelator:!1}):u.pubads().refresh([t],{changeCorrelator:!1})}),e.slot=t,e)},n=function(e){var a,i,o,n=t(),s=e.getAttribute("data-name"),r=e.getAttribute("data-sizes"),d=e.getAttribute("data-label"),c=e.getAttribute("data-site");n=e.id,r&&r.length?(r=r.split(","),a=[],_map(r,function(e){e=e.split("x"),i=parseInt(e[0]),o=parseInt(e[1]),a.push([i,o])})):(e.classList.add("oop"),a=!1),this.data={id:n,name:s,sizes:a,loaded:!1,label:d,site:c},g[n]=this},r=function(e){u.cmd.push(function(){var t=o(e);g[e.data.id]=t})},s=function(e){var t=[];e.slot?(t=_(e))&&window.apstag&&window.apstag.cleared&&window.apstag.fetchBids({slots:[t],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([e.slot],{changeCorrelator:!1})})}):e&&r(e)},u.cmd.push(function(){var e,t,o,n=page.getMeta("article:tag"),s=page.getMeta("author"),r=i.location.href,d=(e=a.head.querySelector(".head-gtm"),t=a.body.querySelector(".gtm"),e&&"top"===e.getAttribute("data-gtm")?"gtmtop":t&&"bottom"===t.getAttribute("data-gtm")?"gtmbottom":"");o=[],_forEach([n,s,d],function(e){_forEach(e.split(","),function(e){(e=e.trim().toLowerCase().replace(/\s/g,"-").replace(/\'|\’/g,"")).length&&o.push(e)})}),u.pubads().setTargeting("kw",o),u.pubads().setTargeting("entry_group",o),r=r.slice(r.lastIndexOf("/")+1),u.pubads().setTargeting("pn",r),u.companionAds().setRefreshUnfilledSlots(!0),u.pubads().enableAsyncRendering(),u.enableServices()}),this.load=r,this.create=function(e){return new n(e)},this.refresh=function(e){var t;_isString(e)?(t=this.getById(e),s(t)):s(e)},this.remove=function(e){var t=e.data.id;a.getElementById(t).innerHTML=""},this.getAdCount=function(e){var t,a=0,i=Object.keys(g);return _each(i,function(i){(t=g[i]).data.loaded&&t.data.label===e&&a++}),a},this.getById=function(e){return g[e]},d=_debounce(function(){var e={TopLeaderboard:1,RightColTopMPU:2,outOfPage:99,"homepageTakeover/TopLeaderboard":1},t=_sortBy(h,function(t){return e[t.data.label]||10});_forEach(t,function(e){return e.data.sizes?r(e):i.setTimeout(function(){r(e)},2e3)}),y&&window.PQ.cmd.push(()=>{try{window.PQ.loadSignals(["ids","bsc","vlp"],T)}catch(e){T(),console.error(`There has been an error loading Double Verify signals: ${e}`)}}),h=[]},10),this.addToPageLoadQueue=function(e){h.push(e),d()});function _(e){var t,a=e.sizes;return a=_intersectionWith(a,[[970,250],[970,90],[728,90],[300,600],[300,250],[320,100],[320,50]],_isEqual),e.sizes&&e.sizes.length&&(t={slotID:e.id,sizes:a,slotName:e.label}),t}function T(){i.clearTimeout(c),w=!0,_forEach(v,function(e){e()})}}]);
}, {"107":107,"114":114,"118":118,"124":124,"182":182,"205":205,"268":268,"274":274,"408":408,"409":409}];
window.modules["cid.legacy"] = [function(require,module,exports){"use strict";DS.service("$cid",function(){var r=Math.floor(100*Math.random());return function(){return"cid-"+ ++r}});
}, {}];
window.modules["client.legacy"] = [function(require,module,exports){"use strict";require("cid.legacy"),require("ads.legacy"),require("facebook.legacy"),require("aaa-module-mounting.legacy");
}, {"cid.legacy":"cid.legacy","aaa-module-mounting.legacy":"aaa-module-mounting.legacy","ads.legacy":"ads.legacy","facebook.legacy":"facebook.legacy"}];
window.modules["facebook.legacy"] = [function(require,module,exports){"use strict";DS.service("facebook",[function(){this.fb=function(i){window.FB&&window.FB[i].apply(this,Array.prototype.slice.call(arguments,1))}}]);
}, {}];
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o typeof key === 'string' && key.match(/\.legacy$/)).forEach(key => window.require(key));
}
function tryToMount(fn, el, name) {
try {
fn(el); // init the controller
} catch (e) {
const elementTag = el.outerHTML.slice(0, el.outerHTML.indexOf(el.innerHTML));
console.error(`Error initializing controller for "${name}" on "${elementTag}"`, e);
}
}
/**
* mount client.js component controllers
*/
function mountComponentModules() {
Object.keys(window.modules).filter(key => typeof key === 'string' && key.match(/\.client$/)).forEach(key => {
let controllerFn = window.require(key);
if (typeof controllerFn === 'function') {
const name = key.replace('.client', ''),
instancesSelector = `[data-uri*="_components/${name}/"]`,
defaultSelector = `[data-uri$="_components${name}"]`,
instances = document.querySelectorAll(instancesSelector),
defaults = document.querySelectorAll(defaultSelector);
for (let el of instances) {
tryToMount(controllerFn, el, name);
}
for (let el of defaults) {
tryToMount(controllerFn, el, name);
}
}
});
}
// Make sure that a `window.process.env.NODE_ENV` is available in the client for any dependencies,
// services, or components that could require it
// note: the `` value is swapped for the actual environment variable in /lib/cmd/compile/scripts.js
window.process = window.process || {};
window.process.env = window.process.env || {};
if (!window.process.env.NODE_ENV) {
window.process.env.NODE_ENV = '';
}
// note: legacy controllers that require legacy services (e.g. dollar-slice) must
// wait for DOMContentLoaded to initialize themselves, as the files themselves must be mounted first
mountLegacyServices();
mountComponentModules();
// ]]