A Sad List of Robert Pattinson’s Struggles Filming The Batman
ByJennifer Zhan,
a Vulture news blogger covering music, internet culture, and TV.
Photo: Warner Bros. and DC Comics
When Robert Pattinson learned he’d been cast as Batman in 2019, he sat in a garden and gazed at the sun. “I was like, Why me? Why, why all these blessings?” he recalled in an interview with Extra. But despite this glowing start, the actor’s next three years working on Matt Reeves’s The Batman would not be free from emotional and physical turmoil. During the press tour for the Warner Bros. film, which hit theaters Friday, Pattinson has shared anecdotes about the various mishaps tied to his role as the latest iteration of DC Comics character and original sad boyBruce Wayne. Here’s a list of 14 struggles he claims he faced while working on The Batman, from having to reshoot a single scene 40 times to spending lonely months away from the sun. It’s worth noting that, by his own admission, Pattinson has lied in interviews before. But we’ll give him the benefit of the doubt before calling him a liar, liar, clown car on fire.
His very sweaty screen test
As is tradition for Batman actors, Pattinson did a screen test in costume at the Warner Bros. studio in Burbank, California. He told Jimmy Kimmel he ended up wearing a combination of two Batsuits that didn’t really fit: Van Kilmer’s body and George Clooney’s headpiece (also known as a cowl).
Pattinson was “pouring sweat” for the entire screen test, which lasted for about eight hours, he told ComicBook. Even Reeves noticed, with the director later recalling to Esquire that Pattinson’s cowl “started to sag on his face” from heat. Pattinson told People he was “absolutely boiling” in the suit and his sweat caused “a major makeup issue.” Until he received his own Batsuit, the experience continued to haunt him. “I thought that was what it was going to be like when I was shooting the movie,” he said. “And so for six months I’d been thinking, I don’t know what I’m gonna do. I need to get some Botox for my sweat glands or something.”
A ‘major panic attack’
Per Entertainment Weekly, Pattinson continued to experience “his own bout of anxiety” even after securing the role. The first time he spoke lines from the script was when he was paired with Zoë Kravitz for her screen test for the part of Selina Kyle (a.k.a. Catwoman). “They had this idea that they wanted me to be taller at the beginning, so I basically had high-heeled sneakers on, and I’m tottering around in this strange Batman outfit,” Pattinson said. “The camera’s not even on me, it’s on the back of my head, and I’m literally having this major panic attack, just looking for emotional support from Zoë, who’s trying to get the part.”
A broken wrist
When The Batman reportedly began shooting at the end of 2019, Colin Farrell wasn’t the only Penguin on set. “I broke my wrist at the beginning of it all, doing a stunt, even before COVID. So the whole first section was trying to keep working out — looking like a penguin,” Pattinson told GQ, adding ominously, “I remember when that seemed like the worst thing that could go wrong.”
Reshooting a scene 40 times
According to Insider, Pattinson joked during a Q&A that he was “about to have an embolism” on set when director Reeves kept asking him to redo a scene with more emotion. “That was maybe the worst day of the whole shoot because I really genuinely thought it was [Reeves] that was wrong,” Pattinson said. “I was like, How can we be doing 40 takes of this?” (Crew members gave an even higher estimate to The Sun, reportedly claiming the actor was once asked to shoot a single scene 50 times.) But after Reeves invited him to watch the playback of his own performance, he realized his cowl was stifling his expressions. “I’m like, Wow. I just look like I’m — there’s nothing. There’s nothing happening,” Pattinson recalled with a laugh.
(Not) moving around in the Batsuit
Acting on advice Christian Bale gave him at a urinal, Pattinson wanted to make sure he would be able to pee in his Batsuit. He told Kimmel he asked the costume department to put a “flap on the back” for “easy access.” But according to his interview with People, he still had issues using the porta-potties on set. And in general, he found it difficult to move in the suit. “The main thing was the shoulders and also the neck,” he said. “I could technically get out of my clothes, but I couldn’t see where anything was. And when you try around, you’d get trapped in rooms. You could get in, but you couldn’t get out without going backwards.” He asserted to Access Hollywood that he’d sometimes get stuck while trying to “get something out of the cupboard under the stairs” or “put stuff in the washing machine.” It’s not exactly clear why he’d need to wear the Batsuit for these tasks. “Sometimes if you just lay on the floor, it’s very difficult to get back up again,” he added. (To be fair, you don’t need to be in a Batsuit for that to be true.)
The suit also posed challenges during shooting. Pattinson told CinemaBlend that a scene in which he removed a bat from a cage “took about a million takes” because his arm movements were restricted in the suit. He joked to USA Today that he had to immediately remove his cowl and put an ice bucket on his head after filming fight scenes, which were “boiling hot” in the Batsuit. “You’re trying to be like ‘the cool guy,’ but it’s embarrassing. The curtain is constantly being pulled back,” he said. “Minute one on set, you’re like, ‘I’m Batman.’ And then it’s like, ‘I’m dying!’” Ah, the duality of man.
‘Counting sips of water’
Pattinson told People he was careful about everything he ate or drank as shoot days approached. “You just cut down and cut down and cut down before the couple of scenes with your shirt off, and you’re counting sips of water,” he said. He seems to have grown tired of following a high-protein diet, complaining to On Demand Entertainment that after finishing the movie, he never wanted to see a piece of boiled white fish with a lemon on it again. Hey, it’s not the first time Batman’s diet has been restricted.
Angering fans
The actor riled fans multiple times throughout The Batman’s production timeline. First, there was the backlash to his casting as the titular character. Then he claimed in a December 2019 appearance on the Today show that Batman was not a superhero because he didn’t have magical powers. The following month, he quickly retracted his statement. “I wasn’t educated about the subject,” he told Time Out. “People got very angry about it. It’s bizarre. I still can’t understand the argument. Okay, he’s a superhero, I’m sorry!”
Finally, during an April 2020 lockdown interview with GQ, he joked that he was “barely” exercising for his Batman role. “I think if you’re working out all the time, you’re part of the problem,” he said. This attempt at dry humor was taken by some as a sign he wasn’t taking the role seriously. “That really came back to haunt me,” he said to MovieMaker. “I just always think it’s really embarrassing to talk about how you’re working out.” He explained to MTV that he had wanted to “undersell and overdeliver.” According to Pattinson, people instead called for him “to be canceled” for a lack of effort.
Dark, lonely shoots
While the gloomy filming conditions sound as though they’d be a good match for vampires like Edward Cullen, Pattinson is not his Twilight counterpart. According to Pattinson, he almost never saw the sun. “The nature of the shoot was so kind of insular, always shooting at night, just really dark all the time, and I felt very much alone,” he confessed to GQ. “Even just being in the suit all the time. You’re not really allowed out of the studio with the suit on, so I barely knew what was going on at all outside.” Per the L.A. Times, he was often alone with no one talking to him since he couldn’t hear with his cowl on. In the darkness and his suit, the actor entered what he called a “strangely simplistic state.” He told the Project that to pass the time in a tent on set, he made trance music on an MPC with headphones placed over his cowl.
Pattinson declared to Entertainment Weekly that the 18-month shoot that started in January 2020 was “one of the hardest things I’ve done in my life.” “I just stayed in a hotel for the whole week right next to the studio because I’d have to get there at like 4:30 a.m. to start training, and then you’d train after, so you’d be finished at like 9:30 at night,” Pattinson said. “You’re just constantly in that world.”
When filming resumed after a break prompted by COVID-19, measures were put in place to limit person-to-person interactions. Speaking to MovieMaker, Pattinson compared the set to a military operation. Many scenes were controlled remotely, the actor said, so there was frequently no one behind the camera. Either way, given the nighttime schedule and his limited peripheral vision from inside his cowl, he said in a CBR interview he could hardly tell if other people were there or not.
By the end of the shoot, Pattinson didn’t recognize himself in photos taken for his last makeup test. He told The Sun he didn’t look human; he told GQ he appeared “green.” But he was most descriptive with EW, stating that he looked like “a piece of bubble gum that’s been stuck on the streets for like three years and has just been scraped off and put in a Batman outfit.”
Hearing nothing, or everything
With Pattinson’s ears hidden away in the cowl, it makes sense that Kravitz said she often had to repeat his name multiple times while trying to get his attention. But Pattinson explained to Sun Showbiz he was also wearing an earpiece he couldn’t remove on his own. “And then occasionally they’d leave on every single person’s walkie-talkie on the entire set,” he said. “I couldn’t get it out of my cowl, so I’d be literally listening to every single thing that’s happening … in the middle of a scene.”
Locking down in London
After production on The Batman shut down because of the pandemic, Pattinson told GQin April 2020, he “almost immediately” lost all sense of time. According to GQ, he had come to London with only about three T-shirts. With the rest of his belongings reportedly at his home in Los Angeles, he found himself living in an apartment The Batman team procured for him. Unfortunately, there were technological hiccups along the way. “My phone broke, the internet broke, everything broke,” he said.
His exploding pasta
During that same GQ lockdown interview, Pattinson tried to pitch an idea for pasta that you can hold in your hand. He hoped the article could serve as a “proof of concept” that would attract a potential business partner. As he attempted to demonstrate this quarantine idea, according to GQ, Pattinson burned himself, ignited a latex glove, and ducked after “a lightning bolt erupted” from the foil-covered concoction he apparently put in a microwave. This explosive scene was not a joke, as some readers speculated. “I was fully, actually trying to make that pasta,” he assured GQ two years later.
Getting COVID-19 himself
The Batman got the green light to resume production in September 2020, according to EW. Then Pattinson contracted COVID-19. Vanity Fair reported that this caused filming to be halted only days after filming had started up again. Pattinson would later describe his positive test to GQ as “very embarrassing.”
Losing Batmobile privileges
It’s about drive; it’s about power. Pattinson reportedly told Empire Magazine he took the Batmobile on an unauthorized joyride. “They wanted me to drive it like only ten feet, but I immediately went off for 25 minutes, trying do all the stunts I’d learned in the normal cars,” Pattinson said. “After that, I was never allowed to drive it without someone else in the car.” He repeated the story to Access Hollywood, sharing more of the consequences of his impulsive decision. “They literally added a guy driving it on the roof afterwards because they didn’t trust me to drive the Batmobile anymore,” he said. “I think I actually, by accident, got it photographed by paparazzi as well.”
Shaving his head
The shooting took such a toll on Pattinson that he ended up changing his physical appearance. “Once you’re in the rhythm of it, I didn’t realize how much work it had actually been,” he reflected to Entertainment Tonight Canada. “And it took me quite a long time that I felt absolutely broken … I shaved my head afterwards.” Although production wrapped in March 2021, Pattinson didn’t recover right away. “I kinda only feel like I’m vaguely coming back to normal now,” he said in the February 2022 interview. Well, normal for him, anyway.
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();
// ]]