Doctor Strange Cameo Watch: Who Will and Won’t Be in Multiverse of Madness?
BySavannah Salazar,
a Vulture editor who writes about streaming, movies, and TV a Vulture associate editor who writes about streaming, movies, and television.
Me manifesting correct predictions.
Photo: Courtesy of Marvel Studios
Potential spoilers for Doctor Strange in the Multiverse of Madness follow.
After the devastation and then restoration of Avengers: Infinity War and Endgame, maybe you wondered how the Marvel Cinematic Universe would top the threats of Thanos and the Blip. Two years into Phase Four, turns out Marvel’s main strategy is to introduce worlds upon worlds of story through the concept of a multiverse. The plots of WandaVision, Loki, What If?, Spider-Man: No Way Home, and now Doctor Strange in the Multiverse of Madness all rely heavily on the idea of infinite selves and possibilities, with the latter film (in theaters Friday) introducing the inevitable: a way to hop between those universes at will.
Disney+’s WandaVision first feinted at the notion of a multiversal cameo, recruiting Evan Peters (a.k.a the Fox X-Men films’ former Quicksilver, a character known in the MCU as Wanda Maximoff’s brother) as a red herring. Loki then introduced us to Sylvie, who blows up the Sacred Timeline that we’re told keeps all universes on an ordered path. No Way Home saw Doctor Strange accidentally tear New York City apart with a spell that summoned rampaging variants of past Spider-Man villains from Sony films, along with returning web-slingers Andrew Garfield and Tobey Maguire. And now, in Multiverse of Madness, our heroes Strange, Wong, and the Scarlet Witch are all poised to face variants of themselves across the multiverse. All of which basically means one thing for the Doctor Strange sequel: Buckle up for an unprecedented number of fan-gratifying cameos from both within the established MCU and beyond.
Trailers for Multiverse of Madness confirm the first appearance of the Illuminati — a secret group of select heroes in Marvel Comics who observe their fellow superheroes, not the real-world conspiratorial group. That opens up a number of opportunities for fan-casting, long-simmering rumors, and more surprises out of left field. Which cameos are a pipe dream and which are plausible? Below, we’ll try to parse through all the variants — I mean, variables — in both chart and written form. And if any of these guesses age horribly, just know they were not written by me, Savannah Salazar, they were written by one of my multiversal variants, so take it up with them. Now, without further ado, let’s dive into the cameo-verse!
Just know I did my best.
Photo-Illustration: Vulture; Photos by Marvel, Getty Images and HBO
WandaVision cast
Possible cameos: Julian Hilliard and Jett Klyne as Billy and Tommy, Teyonah Parris (or Lashana Lynch) as a Captain Marvel variant, Paul Bettany as Vision, and Kathryn Hahn as Agatha Harkness
Who’s most likely to show up? The last time we saw Wanda, she was still reeling from the loss of her twin boys and studying the Darkhold, the ancient Book of Sins whose black magic she hopes might bring them back. Considering the role of Wanda’s grief in this story, it’s a safe bet that Billy and Tommy will appear in Multiverse of Madness. We see them in this teaser trailer, but are they real? Or just a cruel trick of magic?
Another trailer reveals a glimpse of a glowing, Captain Marvel–esque figure, who doesn’t look much like Brie Larson. Could it be Teyonah Parris’s Monica Rambeau, finally taking on her alter ego from the comics? Maybe her variant has a place among the Illuminati. She certainly has a place in Wanda’s story after the events of WandaVision. But I’m also partial to the idea of the mysterious character actually being Monica’s mother, Maria Rambeau (Lashana Lynch). Maybe in a different universe, it was Maria who crossed paths with the Tesseract instead of Carol Danvers.
And while we’re not yet sure where Multiverse of Madness will leave Wanda, one logical path leads to Agatha Harkness, her WandaVision nemesis. Hahn has been busy post-WandaVision working on projects like the upcoming Knives Out 2. But I don’t see how Marvel could resist shooting a quick post-credit scene with her, especially with House of Harkness on the way.
Who’s least likely to show up? Personally, I don’t think we need Vision here. Wanda’s Vision is dead and his stoic counterpart, the White Vision, doesn’t have a real or tender connection with Wanda worth exploring here. But White Vision did fly off somewhere at the end of WandaVision. Maybe he appears in a, uh, vision of Wanda’s. We already know she’ll find herself back in some version of the couple’s old Westview house.
The X-Men (from the Fox Universe)
Possible cameos: Patrick Stewart and James McAvoy as Professor X, Sophie Turner as Jean Grey, Michael Fassbender as Magneto, and Evan Peters as Quicksilver
Who’s most likely to show up? In the most gratuitous IP flex of them all, Fox’s formerly off-limits roster of X-Men might finally be making their MCU debuts. We already know Patrick Stewart is out there cashing his big ol’ Marvel check. He’s in the trailer — granted, intentionally obscured but that voice (and bald head) are unmistakably his. He’ll be reprising his role as Charles Xavier, no doubt, but will it be the Fox universe Professor X we know? Even after the character passed away in Logan?
Who’s least likely to show up? Stewart’s involvement has rumors swirling about other X-Men favorites, though for the most part, they seem like dream castings. On the one hand, Sophie Turner has been flaunting a classic, Jean Grey–esque shade of red hair again. On the other hand, it’s been that way since at least summer 2021. Multiverse of Madness was in reshoots around then — but Turner’s upcoming project The Staircase was also shooting that summer. So really, it’s anyone’s guess.
Michael Fassbender’s Magneto, meanwhile, has comics history to draw on for a potential connection to Wanda: For a time in the characters’ histories, Magneto was Scarlet Witch’s father. But without the proper build-up to such a dramatic turn, it’d be an odd move. Meanwhile, McAvoy’s recently shaved head has sparked rumors about him joining Patrick Stewart as a younger Professor X. But when asked during an Instagram Live if he’d be in the movie, he kept it short and sweet: “No.”
As for Evan Peters’s potential return to playing Quicksilver … Okay, fine, this is just my silly wish, with Peters already cast as WandaVision’s Ralph Bohner. I just want him back!
What If …? cast
Possible cameos: Hayley Atwell as Captain Carter, Michael B. Jordan as Killmonger (as a Black Panther variant), and Jeffrey Wright as the Watcher
Who’s most likely to show up? Remember when you thought you could skip What If …? The MCU is pulling from their multiversal animated series quicker than we thought it would. Fans have predicted an appearance from Atwell’s Captain America variant, Captain Carter, ever since her Union Jack shield was spotted on a fractured piece of glass on the first Doctor Strange poster. And the person seen to Strange’s right in this trailerdoes look like it could be Captain Carter in live action. Illuminati, anyone?
Since Marvel is planning to introduce audiences to the Illuminati, they’re going to need to fill out the rest of the roster beyond Professor X and Captain Carter. The trailer indicates the group will occupy five to six seats, with one for Mordo, presumably, since he introduces them all. Captain Carter and Professor X will likely take up two more. But who are the other three? Let’s turn to What If …? for more ideas. Black Panther was once an Illuminati member in the comics — and while Marvel has promised not to recast the role after original star Chadwick Boseman’s passing, episode six of What If …? points to a potential way around that. In the episode (spoiler alert), Killmonger (Michael B. Jordan) murders T’Challa and becomes Wakanda’s new Black Panther. MoM could show us a Killmonger variant of Black Panther, and the switch-up wouldn’t even have to be permanent — this is the multiverse, after all. There’s always another reality.
Who’s least likely to show up? That brings us to our last What If …? possibility: the Watcher. The character whiles away eons observing the multiverse — and has partnered with a variant of Doctor Strange before, in the animated series. That alone qualifies him to appear in Multiverse of Madness. But I just don’t know how easily that character can be translated into live action, or if Wright’s busy schedule — in the past year, he’s shot The Batman, Westworld, and Wes Anderson’s Asteroid City — might have allowed it. But hey, I’m happy to be proven wrong.
Loki cast
Possible cameos: Tom Hiddleston as Loki, Sophia Di Martino as Sylvie, and Jonathan Majors as Kang the Conqueror (He Who Remains)
Who’s most likely to show up? The Disney+ series Loki was the MCU’s first foray into multiverses and variants. And the show’s head writer, Michael Waldron, is credited as Multiverse of Madness’s screenwriter, too. Naturally, then, speculation about the film’s reshoots has led to rumors that a few Lokis might magic their way into Doctor Strange and Wanda’s orbit. We can take this with a grain of salt. But consider this: The Loki variant Sylvie is responsible for breaking the multiversal timeline — a move whose full repercussions we have yet to see — and Jonathan Majors is being teed up as the next big Marvel baddie, Kang the Conqueror. We know he’ll appear in Ant-Man and the Wasp: Quantumania. So why not put Majors in the MoM post-credits scene to keep us on the edge of our seats?
Who’s least likely to show up? Probably Morbius? Sorry, Owen.
The Absolute Wild Cards
Possible cameos: Ryan Reynolds as Deadpool, ??? as Mister Fantastic, Aaron Taylor-Johnson as Pietro Maximoff, and Tom Cruise as Iron Man Supreme
Who’s most likely to show up? If any of these guys show up, minus Taylor-Johnson’s Pietro, I will have to laugh. What a bunch.
Who’s least likely to show up? Let’s start with the least gratuitous possibility of the bunch, Aaron Taylor-Johnson’s Pietro. The return of Wanda’s brother would strike a bittersweet note, especially after she finally got a moment to process his death in WandaVision. Maybe Wanda’s chaos magic conjures an illusion of him in Multiverse of Madness, or he turns up as a variant from a different universe. There is one source of doubt, though (and it’s a big one). Taylor-Johnson is already suiting up to play Kraven the Hunter in a future Sony/Marvel movie, and I could see Marvel Studios president Kevin Feige not wanting (even more) confusing crossover. Booooo.
Which brings us the most unhinged guess on this list: Tom Cruise as a variant of Iron Man called Superior Iron Man. Marvel enthusiasts have been gunning for this one all throughout the Doctor Strange 2 promo cycle because, once upon a time, before Robert Downey Jr. stole the show, Cruise was in talks to step inside the iron suit. And, sure, Iron Man has a role in the Illuminati in the comics. But Tom Cruise has been booked and busy with back-to-back shoots for Mission: Impossible 7 and 8. It feels unlikely that he’d make time to appear here.
Another possible Illuminati candidate, meanwhile, is the Fantastic Four’s Mister Fantastic, a.k.a. Reed Richards, but it’s anyone’s guess as to who will play him. Would Marvel stuff a major new headline character into just a cameo? We know Richards is coming eventually: Feige announced a Fantastic Four reboot all the way back in 2020. And ever since then, the internet’s been convinced John Krasinski is the man for the job. This particular fan-casting has run rampant for so long, in fact, that I’m already dreadfully bored by the concept. (Remember how sure some folks were that Reed Richards would appear in WandaVision?)
Finally, and unfortunately, we would be remiss to forget Ryan Reynolds’s Deadpool. The snarky mutant has apparently survived the Disney-Fox merger — his third film is on its way — and some fans swear they see a red smudge vaguely resembling Deadpool’s mug on another piece of fractured glass in that same, aforementioned Doctor Strange poster. Unlike Captain Carter’s Union Jack shield, though, I cannot for the life of me see Deadpool here. Good!
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();
// ]]