It’s never easy when a co-worker becomes your boss, and as this episode opens, Galadriel does not deal with it well. Elrond asks if she knows any good archers or swordsmen for their expedition to Eregion, but she replies with some un-elvish snark. She’s called out on it, replies earnestly, and dutifully begins making plans. Once so cordial, even friendly, this relationship has suddenly picked up sharp edges. Then, as if they’d used the fast travel option, they move across the map where they discover Eregion’s going to be a little harder to access than they’d planned due the destruction of the bridge they’d planned to cross. If they go north, it’ll take an extra two weeks. And if they go south, they might be walking into a den of evil, per the vision offered by Galadriel’s ring. Elrond still hates Galadriel’s ring and its visions and resents her bad attitude. But, bound by a sense of shared duty, they press on together.
Galadriel is filled with vague worries about a future threat, while over in Rhûn, the Stranger has more immediate worries: He’s lost his harfoot friends. He quickly gains a new friend, however: a hermit (Rory Kinnear) humming a happy song and sporting a knowing grin. (It’s as if he’s traded to small friends for one big one, though the Stranger thankfully doesn’t see it that way.) After the Stranger asks for help finding his harfoot companions he’s told, “There is what yer searchin’ for and there’s what ya find now isn’t there?” Then the Stranger’s star map blows away, and when he attempts to break off a branch that resembles the staff he used to fend off the riders stalking his party, he’s swallowed by the tree (ent?) to which it’s attached. Nothing seems to be going his way.
Happily, both Nori and Poppy survived the Wizard of Oz–level storm that whisked them away in the previous episode. They awake to find themselves in the middle of nowhere. (True, they were pretty much in the middle of nowhere before, but at least they kind of knew which way to head.) It’s not an uninhabited middle of nowhere; they’re soon greeted by Nobody (also known as Merrimac and played by Gavi Singh Chera). Which is to say they’re greeted by a halfling everyone calls Nobody, a friendly but puzzled-looking fellow who introduces himself, asks who they are, and then exchanges a meaningful look with Poppy (while Nori looks on skeptically). But their meeting takes a turn after the visitors (rightly) suspect he’s stealing water. As Nobody flees, he tells them that outsiders aren’t allowed in the village and that there isn’t even a village anyway.
Under threat, however, Nobody agrees to introduce them to the village elder, “The Gund” (or “Gundable Earthauler” as the credits list the character played by Tanya Moodie), so long as they promise to treat her with respect (which includes not calling her “The Gund.”) Following Nobody, they find a thriving village built inside a small canyon. It’s a place where children laugh and play, trade thrives, and The Gund is not going to let anything change that, certainly, not outsiders who don’t know the difference between harfoots and stoors.
She’s really intimidating! Unless, that is, you’re Nori, who does not like the sharp tone the Gund takes with Nobody and, in the Gund’s words, back-sasses her. She hasn’t come this far to be foiled by an overprotective mayor. But when Nori mentions her lost friend is a wizard, a hush falls over the stoors. They only know the Dark Wizard. And they don’t like him. In no time, Nori and Poppy go from being uninvited guests to prisoners.
Speaking of Dark Wizards, the episode then cuts to this mysterious Saruman-resembling figure as he expresses his frustration at not yet having the Stranger in his hands to the chief of the riders. It’s division of labor time: they’ll hunt for the harfoots while the Dark Wizard looks for the Stranger. Given that he’s still stuck in a tree, that shouldn’t be too hard.
Fortunately for the Stranger, his new acquaintance is happy to rescue him from the hungry tree. Does this fellow have a name? It’s seemingly been a long while since anyone called him anything, but, yes, they used to call him “Bombadil. Tom Bombadil.”) He’s a friendly fellow, asking the Stranger into his home. But he’s odd, too. He likes to sing and, from the other room, the Stranger hears a woman’s voice joining the tune, even though there’s no woman around.
So what’s his deal? Tom Bombadil seems to be old. Extremely old. As in older than the stars in the sky, which he calls “newcomers.” In his words, he’s not just old; he’s “eldest,” no further explanation is needed. And it’s quite possible he’s telling the truth, given the way the fire reacts to a mere yawn. Impressed, the Stranger asks, in so many words, if he can play Luke Skywalker to Tom Bombadil’s Yoda, perhaps starting with that staff he tried to claim from the tree. In return, he gets a bit of wisdom that might baffle even the wizened Jedi Master: “A wizard’s staff is like a name. It’s yours to wield already if you prove yourself worthy of it.” And, Tom Bombadil informs him, he is not. But maybe he will be, with the proper training.
Not that Tom Bombadil’s in any great hurry to take on another protege given that his last one became the Dark Wizard. What’s more, Tom Bombadil knows what could happen next: the Dark Wizard could team up with Sauron to rule the world unless the right heroes step up to stop them. But who could those heroes be? Oh, right. It’s the Stranger.
Elsewhere, Galadriel’s vision of dark foes on the southern route to Eregion. That’s because it passes through the Barrow-downs where “even the trees seem ill at ease.” There’s a good reason for that. The Barrow-downs are home to evil skeletons called Barrow-wights. (And, yes, per Tolkien lore, Barrow-wights should not be in the Barrow-downs at this point in Middle Earth history. Take it up with the showrunners.) They’re pretty scary, if ultimately no match for the elves, despite being impervious to their weaponry. Their own weaponry, however, is another story.
Lest you think The Lord of the Rings: The Rings of Power had forgotten about the refugees at the old Númenórean settlement of Pelargir, the action then shifts to the hunt for Theo from the mysterious attackers who snatched him in the previous episode while attacking the Wild Men. The discovery of corpses and severed limbs seemingly does not bode well, but Isildur and Arondir hold out hope and, at the suggestion of Estrid, they decide to head north. (Remember, she knows a thing or two about the Wild Men.)
Isildur and Estrid enjoy a meaningful moment by the fountain (though Isildur does acknowledge the existence of her betrothed). But it’s cut short when Arondir starts asking questions about the wound on her neck, which he soon reveals to be an attempt to hide Adar’s mark. That’s bad news for Arondir and Estrid’s burgeoning flirtation, but good news for the search for Theo. While they bicker, Arondir stumbles across the clue that cracks the case. Theo wasn’t taken by men, wild or otherwise. He’s being held by the Ents. After Estrid gets a shot at redemption by rescuing both her companions from the giant, mud-dwelling worm that attempted to eat them, they continue on their way. Then, later that night, Isildur chooses to let her go, and after a brief moment when it looks like she’s going to take his sword and flee, he promises to protect her despite her wild men. It’s a meaningful moment interrupted by the sudden arrival of ents.
Unfortunately, back at the stoor village, it’s to be a sentence of exile for the harfoot visitors. Or it would be if not for Poppy dropping the name of the harfoots’ leader. The name rings a bell, recalling an old legend of a stoor who set off on his own with a promise to return for those he left behind and lead them to a promised land called the Sûza. Then this rings a bell for Nori, explaining why her people are perpetual wanderers who have perhaps forgotten what they were originally looking for. Their historical puzzle-solving gets interrupted by the arrival of the riders. But, despite the threat of violence, the Gund does not give up her unwanted guests.
If Estrid and Arondir can put their differences aside, can Galadriel and Elrond do the same? Galadriel’s use of the ring of power has been a wedge between the two, but perhaps it doesn’t have to be. They both want the same thing, after all, and an object that offers grim visions of what might be could be useful. Elrond remains skeptical, but they both agree that defeating Sauron is their top priority. Then they exchange a meaningful look that looks like it could turn even more meaningful until a third elf shows up with a report of something potentially dreadful: the sound of drums.
Sure, drums are scary. But are they as scary as ents with a grudge against anyone who’s taken an ax to a tree? It looks for a moment like Arondir’s past transgressions against trees will be his doom. But they find common ground with Arondir and his friends, after a tense meeting, an apology from Arondir, some friendly handholding (if what ents have on the ends of their limbs can be called hands), and a promise to protect the ents from future harm. (If the ents Snaggleroot and Winterbloom sound familiar, that’s because they’re voiced by Jim Broadbent and Olivia Williams.) After that, the ents let loose their prisoners. Theo, seemingly realizing what a jerk he’s been, hugs Arondir. And, uh oh, there’s Estrid’s betrothed who’s not, as it turns out, imaginary or dead and has a name: Hagen. (He’s played by Gabriel Akuwudike.)
About those drums: they are, indeed, bad news, heralding the approach of a whole army of orcs. They avoid capture only after Galadriel uses the ring the heal an injured member of their party whose moans of pain would have been a dead giveaway. This seems to soften Elrond’s view of the ring, which is good because Galadriel hands it off to him as she effectively gives herself up as a prisoner to protect her companions (but not before taking out an impressive number of orcs in the process). Or maybe, Elrond speculates, it wasn’t her friends she was protecting after all, but the ring. That question will have to wait. As the episode draws to a close, she finds herself face-to-face with Adar himself.
It’s a busy episode, even without check-ins at Númenór and Khazad-dûm. That makes sense, too. Though the first episode of this season only appeared on Prime Video last week, by the end of this episode we’ve reached the halfway mark. The trick, of course, is to find a balance between advancing the plot (or, more accurately, plots) while still giving the characters room to breathe. Episode four keeps the balance pretty well, mixing breathless action scenes (Skeletons! Worms!) with touches like Poppy becoming almost instantly lovestruck after meeting Nobody (and vice versa). All that and it still finds room to bring in some old favorites from Tolkien and the Jackson films, from characters to that overhead shot of Galadriel leaning back in the saddle as a sword just barely misses her. If there’s nothing really new here, beyond new takes on old favorite characters and moments, it’s a good example of The Rings of Power’s ability to recycle creatively.
Mithril Links
• In the run-up to this season’s debut, The Lord of the Rings: The Rings of Power promised Tom Bombadil. In this episode the show delivered on that promise. Tom Bombadil is among the most notable omissions from Peter Jackson’s films, because Jackson felt his appearance didn’t really advance the plot. Here he has a role to play, and a bit more of an active role than in Tolkien’s book, nudging the Stranger toward his destiny. Undoubtedly, this take on Tom Bombadil will not please everyone, but casting Rory Kinnear and letting him play him as a warmhearted weirdo goes a long way.
• After Bombadil tells the Stranger, referring to Sauron and the Dark Wizard, “Your task is to face them both” is there any doubt who this guy is? Still, he’s officially the Stranger so the Stranger he remains until he’s officially somebody else.
• The first season concentrated most of its romantic energy on the semi-forbidden love between Arondir and Bronwyn. Bronwyn’s departure has seemingly awakened other characters’ romantic longings. This episode finds Poppy and Nobody, Isildur and Estrid, and (probably) Galadriel and Elrond at various stages of infatuation. (With elves it’s hard to tell. Maybe those looks just communicate the deep respect they feel for one another.)
• Speaking of Tom Bombadil, that’s Rufus Wainwright singing his song over the closing credits, in collaboration with show composer Bear McCreary.
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();
// ]]