In comedian Cole Escola’s debut play, Oh, Mary!, Mary Todd Lincoln gets to be an unstoppable diva, and so do they.
ByJason P. Frank,
a Vulture writer covering comedy, theater, and music
Photo: Matthew Leifheit for New York Magazine
Photo: Matthew Leifheit for New York Magazine
This article was featured in One Great Story, New York’s reading recommendation newsletter. Sign up here to get it nightly.
This piece was originally published on February 8, 2024. We are republishing it to mark the news of Oh, Mary!heading to Broadway this summer. Read more about the news here.
It’s 28 degrees outside in mid-January, and Cole Escola is leading me around Brooklyn’s Green-Wood Cemetery in search of the gravestone of an actress-producer who died in 1873. “My lips are gone,” Escola tells me as they clutch their phone with gloveless hands. We’re spinning around, attempting and failing to follow directions from a combination of Google Maps, Apple Maps, and findagrave.com. They assume the voice of a prototypical audiobook narrator: “Two faggots walk into a cemetery …”
We’re looking for the grave of Laura Keene, who was performing in Our American Cousin at Ford’s Theatre in Washington, D.C., when Abraham Lincoln was shot in 1865. Escola chose to bring me to Keene’s grave in honor of their debut play, Oh, Mary!, which they wrote and star in as Mary Todd Lincoln in the days leading up to the assassination of her husband. Keene told people she had rushed into Lincoln’s box with a glass of water and cradled the dying president’s head in her arms. Some scholars have since theorized that she lied about this melodramatic moment, which would make her a spiritual predecessor of Oh, Mary! One of the show’s central tenets is that the truth matters less than a worthwhile fabrication.
The germ of Oh, Mary! began with an email Escola sent themselves in 2009 asking what it would be like “if Abe’s assassination wasn’t such a bad thing for Mary.” From there, they did little to no research. In Oh, Mary!’s telling of history, Mary is a former cabaret star longing to get back to her previous work rather than remain in the gilded cage of the White House. (She drinks paint thinner to cope with this, is forced by her husband to vomit it up, then drinks the vomit.) Escola’s Mary is conniving, mean, and loud. She schemes and plots her way back to the cabaret stage by throwing people down stairs, verbally destroying an acting coach, and screaming at her husband. Escola calls Mary a “Miss Piggy type” — she’s akin to an actress who wants to play Juliet but is meant to play the nurse. Even as her behavior grows deranged, Escola manages to get audiences so engrossed in Mary’s headspace that they come to cheer on Abe’s death right along with her.
Photo: Matthew Leifheit for New York Magazine
Escola, 37, is primarily known as a comedian and TV actor. They gained attention in 2008 for YouTube videos in which they played characters both based on real people and of their own imagination: a loopy diva like Bernadette Peters, the depressed busybody Joyce Conner, a mom in an orange-juice commercial so dedicated to her children that it drives her to violence. They’ve been a regular on Search Party and Difficult People,and in both they brought the idea of the “demon twink” to its fully villainous conclusion. In all venues, their work feels somehow of a piece with classic gay artistry — they get referred to as “camp” a lot, a descriptor they see as “not lazy, but not thorough” — and specific to them. More recently, they’ve released longer narrative productions like Our Home Out West and Pee Pee Manor on YouTube, in which their characters often speak in a luxurious legato with an occasional chop of a phrase that cuts through everything around it. In Pee Pee Manor, after the main character is warned by townsfolk through ominous monologues to not move into her new house owing to its previous owners’ unnatural deaths, she quips, “Accidents happen. Look at Pearl Harbor.” Their works are exquisitely rendered artifacts of stupidity with a handmade quality that makes them feel less like the increasingly polished queer media we’ve been inundated with of late, from Matthew López’s The Inheritance to Andrew Haigh’s All of Us Strangers, and more like part of an exciting new generation of slapdash queerness indebted to John Waters alongside Josh Sharp and Aaron Jackson’s Dicks: The Musical.
Escola was born in Clatskanie, Oregon, a town of 1,700 people. When they were 5 years old, their family moved out of a trailer, away from Escola’s father, and in with their grandmother, who was their primary parent for a while. She was a grandma’s grandma — “Gray perm, rice pudding, doilies; she made clothes, and she could knit and crochet and bake” — and accepted Escola’s latent fagginess without fuss, buying them their first Barbie without any curiosity about why they would want it. Other family members would encourage their femininity in a way that felt too pointed: “It was always, ‘You can play with this if you want.’ And that felt like, ‘Well, now I feel like I shouldn’t be playing with it because you’re making it seem odd.’”
They realized they were nonbinary (without the label) upon seeing the book cover for A Child Called “It” when they were 10. The memoir, by Dave Pelzer, is about a boy who is dehumanized and abused by his parents, but Escola didn’t read it, so the title seemed positive. “I remember thinking, like, Oh my God, that’s me. I’m not a boy. I’m not a girl. I’m it,” they recall. “I had two friends, and we would use the it pronoun to describe each other. Not in public or anything but just in private. Between us. We called ourselves ‘the Its.’” When they came out as nonbinary in 2020, they almost used it as their pronoun of choice but opted against it because “I was like, Don’t be extra annoying.”
If they knew they were an it at 10, they knew they were poor much earlier. “I hated my family so much for being white trash,” they say, though Escola didn’t call them that at the time. The first divas they worshipped were homemakers, like their grandma, but skewed upper-middle class — beginning with Kanga from Winnie-the-Pooh; progressing to Mrs. Potts, who lasted through age 8; then landing on Martha Stewart. Over one summer when they were a tween, they would regularly stay up until 5 a.m. to watch episodes of Martha Stewart Living. They spent their birthday money on Christmas decorations and idolized wealthy, sophisticated characters like Christine Baranski’s Maryann Thorpe on Cybill, realizing, as many gays have before them, that if they couldn’t be cosmopolitan through money, they would have to do it through culture.
Photo: Matthew Leifheit for New York Magazine
Photo: Matthew Leifheit for New York Magazine
When they were 16, they moved in with their cousin to go to a high school in Longview, Washington, that had a drama program. (Subconsciously, the move was also due to the fact that they felt like they’d be able to come out in a new place.) Escola had learned to be funny in late middle school and early high school because it meant they got bullied less. “As long as there’s going to be attention on me, I might as well command it myself,” they say. They hated school but ended up enrolling at Marymount Manhattan College in New York in order to follow their boyfriend at the time: “I was like, I need to be near him or kill myself.” The two broke up before school started, but Escola still made the move in 2005. After their freshman year, they dropped out because they couldn’t take out any more loans without a guarantor.
The following year and a half in New York was not good. Escola was, in no particular order, “suicidal, bulimic, lonely, and depressed.” They got a job at the Scholastic Bookstore, where they alternately worked as a cashier, hosted birthday parties, and, sometimes for events, dressed up as Clifford the Big Red Dog. One day, their friend sent Escola a pantsuit that made them wonder if they could pass as an older woman. “I dressed up in it, and I had this fake-fur coat, and I did horrible frosted makeup and spiked my hair,” they recall. Escola gave her a name — Joyce Conner — and took a walk in character around the Upper East Side. “Because I was suicidal at that time, I thought, Wouldn’t it be funny if I was having my thoughts, but as her? ‘I’ve got to kill myself Saturday.’What if this busybody woman was thinking about her suicide as if it was a lunch she was having on Sunday?” Suddenly, even though they were still thinking about suicide, they felt happy.
Soon after, a friend of Escola’s made a student film about Joyce, which Escola showed to Dan Fishback, a playwright and performer they were seeing at the time. Fishback encouraged Escola to perform in Bushwick as the character, inviting them to open for anti-folk bands, a genre that began in the 1980s as a way to rebel against the glossiness and rigidity of mainstream folk music. “Joyce was a big part of the Brooklyn anti-folk scene for about six months in 2008,” Escola says. That year, they posted their first video as Joyce to YouTube (“Joyce Conner Survives the Heat,” in which Joyce says she attempted to kill herself a few months prior before realizing the pills she swallowed were vitamin-D supplements). Over the next few years, they built their audience more consistently; they performed live, doing character sets and cabaret, both on their own and as part of Bridget Everett’s 2013 show Rock Bottom, in which they played a fetus. By 2015, they were cast on Difficult People, and, in 2017, they became a recurring guest on At Home With Amy Sedaris. Oh, Mary! is Escola’s first full-scale live production, involving multiple sets, four other actors (including Conrad Ricamora, fresh off leading the Broadway production of Here Lies Love, as Abraham Lincoln), and a director, Sam Pinkleton, who just worked as the choreographer for Stephen Sondheim’s final musical, Here We Are.
As we trek through the cemetery fields, veering off the paths, the conversation turns back to divas. Escola loves pre-Code movies, and they have a particular fascination with Barbara Stanwyck — “You can’t catch her acting” — whose mother, Kathryn Ann Stevens, is also buried in Green-Wood. When they lived nearby, Escola would come to the cemetery just to visit Stevens’s grave. The first time they traveled to Europe, they went to Marlene Dietrich’s burial site in Berlin and the apartment in Paris where she died. “I love Dietrich,” they say. “I didn’t like when she wore suits.” We share an obsession with Elaine Stritch. “Her talent aside, she represents this golden age of Broadway and New York — the sort of New York that I dreamed of but I never could be a part of when I was a kid.”
Photo: Matthew Leifheit for New York Magazine
Escola’s relationship with audiences is complicated: “I’m scared of them. I hate them. I resent them. I look down on them. I need them.” In 2016, Julio Torres invited them to perform their first live comedy set on a lineup at Williamsburg venue. They hated it. “You have three people before you who are doing stand-up that’s very conversational. Then I come onstage, and all of a sudden there’s a fourth wall and I’m pulling the wig out,” they explain. “I can feel the audience go, Ugh.” Growing up, their personality (sincere, feminine, loud) was considered obnoxious by family members and peers alike. “My biggest fear and biggest belief about myself,” they say, “is that I’m really annoying.”
But, in Oh, Mary!, they’ve designed a role in which annoyance is the goal. Escola is in total control of the stage as Mary Todd Lincoln. The show is a pastiche of the melodramas Escola loves — they call themselves “a maudlin old queen” — with all the screaming that entails. It’s a subtly tricky part: Because Mary is so impulsive, even a flicker of Escola anticipating her next act would ruin the joke; her mania is most thrilling when the audience doesn’t know what’s coming next. But Escola appears entirely in the moment, letting the audience into Mary’s thought process so that it is rapt because of not only their words but their face. After Mary drinks that bucket of vomited-up paint thinner, Escola lays their whole body back in their seat with the self-satisfied smile of someone who just eked out a battle win in the midst of a difficult war. It brings down the house.
Finally, we arrive at Keene’s grave, where one nearly decayed flower is already resting. We remove the plastic from our Trader Joe’s bouquet of yellow roses — chosen because they were the flowers at Escola’s grandmother’s funeral — and place them down. “Please don’t let the ghosts of Abraham and Mary ruin my show,” Escola implores Keene. “Please protect me from bad reviews. And I hope you’re proud. Love you.”
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(4),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(135),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,"4":4,"12":12,"124":124,"135":135}];
window.modules["aaa-module-mounting.legacy"] = [function(require,module,exports){"use strict";const _pickBy=require(221),_each=require(406),Fingerprint2=require(408),DS=require(407),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(406),_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,"406":406,"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","ads.legacy":"ads.legacy","facebook.legacy":"facebook.legacy","aaa-module-mounting.legacy":"aaa-module-mounting.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();
// ]]