Photo: David M. Russell/?2011 CBS Broadcasting Inc. All Rights Reserved.
First off, I’d like to thank the great, new(ish) Twitter feed from The Good Wife writers for not only making my job easier but for filling fans’ heads with the kinds of fantasies that would get us more hot and bothered than a Josh Charles shirtless episode (yes, please): Sigourney Weaver as a possible ex–Mrs. Eli Gold? Nathan Fillion as guest star? Sarah Silverman definitely coming on as the owner of a website that connects people looking to have affairs? Stop! Cannot. Take. It. Anymore.
The live-tweeting of episodes, along with a new(ish) blog of the campaign, nicely ties into the show’s reputation for being extremely web-savvy. At the same time, I don’t know if I want to know this much about the process of the show. Does it really add to the experience to know that Kalinda’s doozy of a revelation at the end of last episode has been planned since the beginning of the series? Or that the Kings held off until now to make it even more devastating when Alicia finds out that Kalinda and Peter slept together? Not really. It is devastating. Just let us feel it. And stop tweeting about how Alicia will find out by season’s end. We knew that was inevitable. We just didn’t need to know for sure.
Anyway, to this episode, which begins right where we ended last time, in a scary parking garage with Blake being all menacing and sexual tension-y, circling Kalinda and telling her that he spoke to an ASA about how Peter helped her change her name. For now, it seems, we’re going to gloss over the why of why Kalinda changed her name. As fine commenters have pointed out, doing it out of boredom seems pretty lame, and wouldn’t explain why Peter would risk his job and future fraud charges to help her. Kalinda does seem extremely upset that Alicia might find out she slept with Peter, though.
Via her amazing cell-phone reception that lets her phone people from within the bowels of an underground parking lot, she calls Alicia. Is it to confess before Alicia finds out from someone else? Perhaps, but the second she talks to her friend, she realizes that would be a mistake. She doesn’t want to lose the friendship and she knows it probably wouldn’t survive a reveal like, “So, you know how Peter’s cheating on you with a bunch of random chicks and prostitutes ruined your life? Well, I was one of them, and became your best friend anyway, and I know I’m the person you trust most in the world, but, um, I’ve been lying to you for the past year and a half.”
So, instead, Kalinda calls Cary. Aw. When are those two crazy kids going to get together for real? We learn that Cary is a stomach-sleeper and has one of those tastefully decorated bachelor pads with good linens. Why Alicia was awake and he’s acting like it’s five in the morning, we don’t know. Nor can we figure out why he’d answer a phone, “It’s me,” and THEN figure out it was Kalinda who was calling. Seems like those events are out of order. But he’s never too sleepy to help out Kalinda. Kalinda wants to know if Cary was the ASA who conducted Blake’s final, potentially destructive interview, and if not, could he find out who did. In Kalinda fashion, that’s all she’s willing to reveal, but Cary can tell it’s bad. This is a girl who never gets fazed, so for her to sound this vulnerable and upset means that … Archie Panjabi probably deserves another Emmy.
Cary does look into it, and the next day tells Alicia that he couldn’t find anything about another Blake interview and that Kalinda should stop worrying. He later explains that he talked to Alicia because she’s Kalinda’s lawyer, but we all know it’s so that two episodes down the line, something will happen that makes Alicia connect Cary’s message with Kalinda’s cover-up of the affair.
Alicia is working on a civil case representing Rhonda Cerone (the excellent Gaby Hoffmann). She’s trying to stop a man named Jarvis Bowes from profiting off a song he wrote about carjacking her mom, driving her to a deserted field, and raping and murdering her. It’s a play off the controversy over Guns ‘N’ Roses recording songs written by Charles Manson, combined with, perhaps, all those songs rappers keep writing from prison. Gruesome, fascinating stuff. This monster of a man (played by Sam Robards, a.k.a. Nate’s dad “The Captain” Archibald on Gossip Girl and, fun fact, Lauren Bacall’s son) has been declared sane after 30 years in a mental ward and now he’s planning to reenter society as an artist “inspired by Elvis Costello and Gerard Manley Hopkins.” A terrible British band with an even more awful name, Ag47, has recorded a song he wrote called “Just Drive On Out,” and it’s No. 3 on the Billboard “Top 100.” That means Jarvis has $800,000 in royalties coming to him, and probably more on the way. Will and Diane decide to take on the case, despite it being one of Bond’s leftovers, because it makes them look good to sue a monster. We wish Will were motivated by wanting to stop anyone from profiting off terrible, whiny Brit rock, but we sadly suspect he’s the kind of guy who listens to Oasis.
Now that we know Kalinda’s secret, the clever writers are making sure that she and Alicia do every single possible work task together, including listening to the song on repeat for lyrical clues that might tie it directly to Rhonda’s mom’s murder. The current version of the song is too generic, but through some ace flirting with the Brit band’s slimy lead singer, Kalinda gets her hands on the original tape Jarvis sent them from the mental institution. It really does sound, as described, “like a dying porpoise,” but contains new details like the rape occurring “under a Christmas tree,” near “a bloody cow guard,” and the victim having a “popcorn smell that won’t come off.” (Also — tangent — the Brit asks Kalinda where her accent is from. Significant?)
At the crime scene, Kalinda finds a Christmas-tree farm and a cow guard, and Will thinks he’s got this case nailed. We’re also pretty sure that Will is about to nail Jarvis’s defense attorney, Babette Penn. They have mad chemistry, and Tammy’s return in next week’s episode could very well be for a breakup.
We digress. A distracted Kalinda neglects to find out that the Christmas-tree farm wasn’t around 30 years ago, torpedoing the case. Confident he’ll be both a free and rich man, Jarvis, delusional sociopath that he is, starts talking directly to Alicia. He’s a “fan” of how she remade her life (he even wrote a song about her), and wants to retain her as both a life coach and his lawyer when he battles illegal downloads of the song.
It’s looking grim for our heroes until — AWESOME PLOT TWIST — Rhonda realizes that while the lyrics don’t describe her mother’s murder, they do describe the unsolved murder of a movie-theater worker whose daughter is in Rhonda’s murder-survivors support group. Whoa! Cue an amazing fake-out by Will. He gets Jarvis on the stand and asks him to detail why the song is different from his murder. Jarvis explains that while the song describes him carrying the victim to the field in the trunk, he couldn’t have carried her in the trunk since he can’t drive a stick. Will: “So you only put her in the trunk after you killed her?” Jarvis: “Yes, I … ” But he never put Rhonda’s mom in the trunk! He mixed up the victims! And in the unsolved murder, there was a Christmas-tree ornament hanging from the rearview mirror. He wins the music suit, and then Cary marches in and arrests him for murder. Again.
Elsewhere in the episode, we see the return of Natalie Flores (America Ferrara), the girl Eli wants to date but kinda-sorta exposed as an illegal alien for the sake of Peter’s campaign. Oops. In a very cute exchange with his sassy daughter, Marissa, Eli reveals himself to be a secret patriot (“America does not suck. People suck”), then lies, badly, about how he’d only taken Natalie out to dinner because he was doing “information gathering.” Marissa calls him on it; she saw his face and how happy he looked. And Eli turns into an embarrassed schoolboy. “I have great control over my face!” We love how Marissa gets to bust Eli’s chops and get away with it. It also adds to the canon of great scenes of Eli fighting his teenage nemeses.
Eli and Natalie clearly have a connection. It has a romantic edge, but mostly seems to be about mutual admiration and how rare it is to meet someone who can see past your surface layers, and both gets and accepts the person beneath. Eli talks Diane into representing Natalie in her legal fight for citizenship but keeping his involvement on the DL.
This all gets more complicated when Natalie’s dad, Luis Flores, also undocumented, gets picked up in a “hunt and peck” for a Hispanic man who committed armed robbery. Natalie’s dad is way older than the suspect, and his car only sort of looked like the car in question. He’ll get off, easily. But as soon as he entered into the system, he’ll be red-flagged for ICE and subject to deportation. Eli gets Diane to step in and she bungles it badly, liberal righteousness ablaze, by basically accusing the arresting officer of racially profiling Luis. The office, who, like most of law enforcement, is probably a Republican and not a big fan of illegal immigrants, presses the “Enter” key on Luis’s arrest paperwork just to spite Diane.
Now that Luis is in the system, they have until 3 p.m. the next day to get him out on a bond before ICE comes to his holding cell and take him away. Diane and Eli work their white-person political connections for everything they’re worth. The judge in the bond hearing recognizes Diane’s name as a member of Emily’s List, which probably helped that judge get her job, and processes the bond with haste. Eli knows the officer at the holding cell from Sherriff’s Associating fund-raisers, and appeals to him by claiming Luis is his gardener. “You can’t find good gardeners these days, you know.”
We were a little confused with why everyone is so jubilant when Luis gets out. Even if he’s out of holding, isn’t he still in the system as undocumented, and can’t ICE just hunt him down at home? And what is Eli’s motivation for helping Natalie? Is he attracted to her? Is he assuaging guilt over screwing up his life? Or is this a pattern, as his psycho-babbling ex-wife has told Marissa? Does Eli always find a crush to fixate on during the last month of the campaign, and does he have a savior complex because he hates himself? We think he just likes Natalie and is more of a softie than he likes to let on. Either way, Eli’s heroism in keeping her family together seems to have prompted Natalie to forgive him. Her contortionist boyfriend is back from Vegas, but we’re sure Eli and Natalie will have another moment.
We’re a month away from election day, and things are going so well that you just know the Kalinda issue is going to bring that whole Jenga stack tumbling down for Peter, not just politically but personally. As Cary discovers, his fellow ASA Matan Brody did do one last interview with Blake, but suspiciously didn’t file the notes. Cary knows this means Kalinda is right about being in trouble. He also seems to sense that Matan is hiding the contents of that interview for some reason, just as Cary is hiding his reasons for inquiring into a dead case.
After-hours at the campaign office, Kalinda and Peter meet for the third time ever, and we learn that they did, indeed, sleep together. Both know the stakes if Alicia finds out. Peter has, as he says, fallen in love with his wife again. He could lose her, not to mention lose the campaign and possibly face more jail time. Kalinda risks jail, as well as losing her best friend, possibly losing Cary, and proving to Alicia that there is no one in the world she can trust.
Sprinkled throughout are brief mentions of Lana Timmerman, wife of a congressman who got caught in an affair. She’s sold her memoirs for $1.3 million. This seems excessive. But you just know that Lana is going to play big in the next five episodes. And you don’t give Alicia a line about coming through a storm without being prepared to make it rain again.
Back at Chez Florrick, Alicia is making pizza and the kids are playing air hockey on the countertop while quoting from a viral video about murderous llamas with hats. There’s hope for the future; once Peter wins the campaign, will they move back to Highland Park or just to a bigger apartment? All the while, Peter is on the phone in the bedroom, offering Matan job security in exchange for his silence, which he accepts, on the condition that Peter wins. Things are, as Peter says, “as good as they can be.” But the sky is looking mighty ominous.
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()}});
}, {"3":3,"6":6,"17":17,"35":35,"40":40}];
window.modules["global-nav.client"] = [function(require,module,exports){"use strict";const dom=require(4),auth=require(17),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(3),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 i=t.querySelector(".dropdown");!n||t.contains(e.target)&&27!==e.keyCode||i.classList.remove("open")})}function gtmSendReport(e,n,t){let i={eventCategory:"ecommerce",eventAction:"componentClick",brand:e,dimension23:"global-nav",list:pageUri,pageZone:"header",variant:"nav-link"};"global-nav-link"===t&&(i.eventLabel=n.href),gtm.reportNow(i)}function updateElementTargetUrlsIfQueryStrings(e){if(searchString){const n=new URLSearchParams(searchString);let t=e.href;if(t.includes("?")){const i=t.split("?"),o=new URLSearchParams(i[1]);for(let e of n.entries())o.set(e[0],e[1]);t=`${i[0]}?${o.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()||auth.isMobileAppRequest())&&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;
}, {"3":3,"4":4,"17":17,"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();
// ]]