When Don Draper pulled the brim of his hat down over his eyes and said a dashing farewell to Joan in “Christmas Waltz,” I felt something I hadn’t yet felt during this otherwise excellent season of Mad Men: elation. Written by Victor Levin and Matthew Weiner and directed by Michael Uppendahl, it moved and felt more like an early episode, snappy and sexy. I don’t say this to take anything away from the rest of season five to date — for their creative ambition, I’d put episodes one through six up against any run of any series in TV history — but to acknowledge what some other fans have been saying. Except for bits of comedy (mostly involving Roger), this season has had a pervasive sense of unease. We haven’t been given too much sexy banter between funny, attractive grown-ups, like the lovely sequence between the just-divorce-papered Joan and the domestically unhappy Don at the bar. When we do get a scene like that, we feel a sense of cathartic relief, as if we’ve been crawling across a desert and somebody appeared before us with a parasol and a glass of ice water.
Historical context has something to do with it. Nearly every episode of season five has contained a nod to the violence of the era and the sense of impending generational upheaval that’s making Don and the other partners (including the young old fogey Pete Campbell) feel disconnected from their culture and old before their time. But it’s also a character thing: Nearly every major character, male and female, has been struggling under the burden of being something they’re not naturally inclined to be. Some have reacted by embracing that difference, albeit reluctantly: Roger and Jane splitting up, for example, or Peggy moving in with her boyfriend (though she doesn’t seem too satisfied with that change, otherwise why would she be practically living at the office?). Others have acted out, consciously or unconsciously: Pete Campbell’s dour fling with his traveling companion’s wife, Joan kicking her insensitive husband to the curb, and all the Megan-Don stuff, which has anchored most of the thematic action this season.
Jon Hamm alluded to a possible Don-Joan hookup this season, and the show now appears to be headed in that direction. When Don impulsively dragged her to the Jaguar dealership to get her mind off having been served divorce papers (I loved her blowup at the receptionist, which was a long time coming), they were playacting marriage and seemed very comfortable doing so; I especially loved Joan responding to the Jaguar salesman by saying they had four children “between us.” “That car does nothing to me,” Don said. “It’s because you’re happy, you don’t need it,” Joan replied — a great bit of writing for how it recognized the reality of Don’s situation by confirming his delusions. The car, of course, is Joan, which is why I laughed out loud at that moment when Don told the salesman, “She really wants me to take it for a ride.”
Playacting marriage has been a sub-theme this season. Recall that in “Lady Lazarus,” Don and Megan are asked to enact a husband-wife script in the Cool Whip test kitchen, and do it effortlessly at SCDP, but when Megan leaves the firm to pursue her acting career, Peggy has to step in, and her awkward, resentful version of the scene with Don is like a parody of a marriage gone sour. Then there was that bit last week with Roger asking his soon-to-be-ex Jane to accompany him to the Manischewitz client dinner and pretend that they were still married. Playacting has always been important to Mad Men and has been explored through many characters over the last five seasons. The fact that the main character is an imposter whose entire life is a performance makes it official. (And he married an actress. Perfect!) Problem is, can’t sell either an actual lifestyle or a scripted scene unless your heart is in it — unless you can commit.
Don committed to his marriage with Megan and has made a lot of noise about how her influence has made him a better man, and on a superficial level there’s some truth to this. He hasn’t cheated on her once (that we know of) and has pointedly rejected any opportunities that came his way — even during the brothel tour with the Jaguar contact, which according to the mores of the time would have been considered “off-books” by guys like Roger, Don, and Pete.
But Megan’s youth, beauty, and optimism have also started to weigh heavily on Don, reminding him of his advancing age (he recently turned 40, which, culturally speaking, felt a lot older then than it probably does now) and disconnecting him from the source of his power, his mastery of words and work. The scene in this episode where Megan and Don attend a stridently anti-commercial play exposed another fissure in Don’s second marriage: Megan’s the child of left-wing intellectuals and is thus predisposed to distrust and dislike the very industry that pays for her lavish lifestyle. (Like most Mad Men details, their evening’s entertainment is drawn from history: The trilogy American Hurrah premiered at the Pocket Theatre in Manhattan on November 7, 1966.) Megan has a reflexive anti-advertising bias that’s only now starting to surface. The argument between them immediately following the play suggested that, without meaning to, Don has somehow taken that scene between him and the condescending beatnik in season one and turned it into a marriage. “How do you sleep at night,” a beat asks him snidely. “On a bed made of money,” Don replies.
More playacting: Harry, Mad Men’s funniest character after Roger, finally gets half of an episode to himself, reconnecting with Paul Kinsey. Paul has remade himself as a Hare Krishna follower in thrall to the movement’s founder Srila Prabhupada. He also has a main squeeze, Mother Lakshmi. But despite all his nattering about the satisfactions of rejecting the material world and his apparently genuine belief in the value of spiritual inquiry, it’s clear that Paul isn’t happy — otherwise why would he push his apparently horrible Star Trek spec script on Harry and press him to forward it to NBC? (With its heavy-handed race-relations theme, Paul’s script, “The Negron Complex,” suggests a third-season Trek episode “Let That Be Your Last Battlefield.”) Paul’s praise for Star Trek’s storytelling formula could also describe Mad Men and many of the more notable modern TV dramas: “Moral complexities tinged with adventure.” On this show, of course, the adventures are mainly emotional rather than physical. The final frontier is interior.
The Harry-Paul subplot resolves with one of the season’s most moving scenes: Harry, unable to tell Paul the truth about his script, instead gives him $500 and encourages him to move to Los Angeles and make a go of it as a writer. It’s not the best solution, obviously — if Paul’s writing is that bad, he’ll end up working at the A&P in West Hollywood rather than in Gene Roddenberry’s writers’ room — but the genuine tenderness that flows between the two former officemates is unaffected and moving. Here, too, the word relief applies: The now-bald, robed Paul, who has no money and few prospects, is so overwhelmed by his old friend’s generosity that he hugs him right there in the coffee shop. At the same time, though, I was again reminded of one of Don’s lines from the season one beatnik tell-off scene: “People want to be told what to do so badly that they’ll listen to anyone.”
I loved the coffee shop scene so much that it made me almost (but not quite) forgive the scene between Lakshmi and Harry in Harry’s office, which is hands-down the dumbest and most incoherent scene in season five of Mad Men, and the one that most lends credence to the notion that this is ultimately a male-centered show that understands many of its female characters in an academic rather than intuitive way. Lakshmi was there to …
Well, what the hell was she there to do, anyway? The most charitable interpretation would be to say that her motivations made sense to her, but not to Harry. But seriously, can we just collectively agree that the scene was a hot mess, so much so that Harry, in his incredulity and confusion, seemed like an audience surrogate? Why was Lakshmi using her sexuality to influence Harry by banging him in his office instantly? Wouldn’t it have made more sense — as Harry, not normally the most clearheaded character, pointed out — to tease Harry with the possibility of sex but not actually go through with it? She says that when she was with Harry in the Krishna temple, she felt a tingling all over, “Especially one place,” and that she was on guard against Harry’s attempt to yank Paul out of the movement: “You want to make him into a gross materialist when he’s living in the spiritual world.” Whaaaaa???? “I’m confused,” Harry asks after banging her doggy-style atop his desk. “Why did we just do that?” “I’m trading the only thing I have,” she says. “But you already gave it away!” Harry exclaims. It’s as if a naysayer’s notes from a Mad Men writers’ room meeting got incorporated into the scene rather than being used to solve the scene’s problems.
Anyway, back to Don and Joan: We all wanted to see this (potential) hookup happen. Right? The stars are aligned. Not only are Don and Joan the two Mad Men characters who most obviously embody Old Movie notions of glamour, they’re both either emerging from (or dealing with) the realization that they are who they are, and that they can’t just remake their lives with the snap of a finger (or a proposal to a secretary at Disneyland). In retrospect, Joan’s marriage now seems an extreme and ill-advised reaction against her nature; in the early part of this season, the sight of her stuck at home with a baby was depressing, not because there’s anything inherently bad about being a parent or a military wife, but because Joan was always at her happiest in the office, acing the role of sexy mother hen, and negotiating relationships between employers and employees with a knowing grin and some not-so-sly innuendo. Don is at his best, and his happiest, pulling miracles out of his posterior.
The big speech at the end of the episode was a great example of this skill: Don turned a glass-half-empty situation (the Christmas bonuses barely paid for via partner deferments) into “Your cup runneth over.” And he did it through sheer enthusiasm and canny phrasing and nothing else. He even pulled a Tom Sawyer and made everyone (momentarily) thrilled to slave for several weekends on the Jaguar account during the holiday season when they should be spending time with their families. We have just three episodes left this season, and who knows where they’ll go, but I’m going to make a prediction anyway: Don Draper will be “back” by the end, but at terrible cost. He’ll either be standing in the smoldering ruins of his marriage to Megan or else duplicating the previous matrimonial scenario that he described to Joan at the bar: being bad, then going home and being good. When Megan confronted the drunk Don after his day with Joan and blasted him as “someone who doesn’t give a shit about anyone,” it was as if the spirit of Betty had invaded the room, though Don certainly asked for it by staying out all day without so much as a tipoff phone call and making that smart-ass remark about Megan getting out a “rolling pin.” “You like to get mad,” he said confidently, sidling up to her and trying and failing to turn on the Draper charm. “That’s what gets you going.” It’ll get her going, all right, but not in the way that Don hopes. Going, as in leaving.
Odds and ends:
• We see Lane Pryce forging a check with Don’s signature, presumably to take care of his tax issues. From the skillful, practiced way he traces Don’s signature atop a light table, it seems as if it’s not the first time he’s forged a check, though maybe he just has a knack for it.
• Peggy has been given very little to do this season, partly because so much screen time has been devoted to Don and Megan’s marriage and the misadventures of other supporting characters. Maybe there’ll be a narrative Hail Mary between now and the finale that’ll make Peggy’s marginalization seem worth it, but still, color me bummed.
• After making a big to-do out of integrating the firm, Mad Men has done nothing of note with Dawn’s character other than that one great scene between her and Peggy at Peggy’s apartment. I realize this is the show’s prerogative and that, given the characters’ near-total disconnect from African-American life, it’s not unbelievable. But I can’t help feeling that the show is just flat-out terrified of going there for fear of not getting the details right, and that in light of this, maybe they would have been better off not going there at all. What is stopping the series from giving us a glimpse into Dawn’s personal life, or maybe a few more juicy scenes, or even a half-episode? We’ve gotten to know a lot more about another new character, Michael Ginsberg, than we have about Dawn; they even gave his father a couple of scenes. What’s with the hesitance? Is it really harder for audiences, or the writers, to imagine their way into the life of a young black secretary than the life of the poor white prostitute’s son who stole a man’s identity in Korea and remade himself as an advertising genius? Go ahead, Mad Men, and boldly go there.
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();
// ]]