Alright, I’m just going to come right out and say it because I know we’re all thinking it: Bethenny is a bitch. I always liked Ms. Frankel (if you’re nasty like her) and I wanted to give her the benefit of the doubt, but something has changed. Some core element of her personality has twisted and the new calibration is not the witty underdog that we used to know and love. The voice of reason that we followed for all those seasons has been supplanted with this shrill basket-case of frayed nerves, rude behavior, and crude put-downs. Bethenny is no longer the scrappy fighter telling truth to power; she is now the misuse of power. She is the Kim Jong-un of the Housewives, with no nukes and a slightly better haircut.
This episode was nothing if not a litany of Bethenny being awful to just about everyone on the show. It started with making us relive the end of the Berkshires dinner-party fight from last week, where Heather goes over and tries to lead Bethenny away from the table and she refuses to budge. It was too painful to watch. I had to pause the television and go get three handfuls of Triscuits from the cupboard just to unpause the DVR.
As we were promised last episode, the fight was continued. Bethenny did get up from the table to talk to Heather alone, but they didn’t go into another room or anything, they just stood up behind their ivy-printed chairs and stood around the table and talked in front of everyone. There was even a firing squad of scary green creatures sitting on a shelf behind them. From what rancid voodoo shop on the Haunted Tour of New Orleans did Dorinda possibly buy those?
It was precisely at that moment I realized that none of this was really Heather’s fault. She didn’t really do anything at all. This is all a manifestation of her own neuroses brought out and projected on Heather, who was just trying to help and be nice in the only way she knows how. Yes, it might have seemed a little bit much, and yes it might have seemed a little bit disingenuous, but Heather’s intentions were good. Bethenny can’t accept that, she can only lash out, and that is Bethenny’s problem, not Heather’s.
Bethenny’s whole argument doesn’t really make sense. She says that she doesn’t want any attention paid to her, but then, why is she doing what she’s doing? If she wants to fade into the background, fade into the damn background, don’t go shouting down people at a dinner party, crying at the table, and then giving ridiculous toasts making everyone focus on the fight that just happened. If Bethenny really wanted to make this go away, she’d smile and nod and just tune them all out, but she doesn’t. She fights and screeches and lets people know what she will and will not talk about, and generally tries to commandeer every interaction that she has with any single person. That is not trying to blend in. It’s like trying not to get noticed in gym class while wearing a highlighter-yellow leotard, Jazzercising, and singing the national anthem off-key.
I have vast stores of sympathy for Bethenny and having to endure her gnarly custody battle and a painful divorce from a snaggletoothed Maloof, one of the race of mole people that live under the mountain. But if you are this fragile and really don’t want people focusing on you, then why are you on a freaking reality show in the first place? There’s no way to disappear like having a bunch of cameras around you all the time. There’s no way to stop interacting with people when being forced into a situation where you have to make friends with strangers and then talk about your interactions ad nauseam with a bunch of other professional gator-wranglers. So, yes, I have sympathy for her, but she brought this particular torture on herself. To then pretend like she can’t hack it or she’s too good for it is disingenuous and a little bit dumb.
I’m taking a deep breath now (and another handful of Triscuits, and the rest of this bag of Bugles that I found behind the box of Triscuits) because we will get back to Bethenny later. Right now there is someone else we need to talk about: Avery Singer. How on Gloria’s green Earth did Avery Singer turn out to be a normal human being? It must be some strange alchemy of fate, wishes, and dragon semen, because it certainly wasn’t from emulating her mother. Whatever this magic spell is (or curse, maybe?), it’s the same one cast on Brianna, the daughter of Vicki Gunvalson (née Velociraptor Furioso). How can this monster spawn grow into such cute, cuddly adults?
It was so great to see Avery being a normal college student who can’t put up with her mother’s nonsense and has to finish her paper instead of going out to dinner because she was flirting with some random boy in the computer lab. Then she told her mother exactly what everyone at home was thinking when she said, “It’s not Ramona blue. You can’t claim a color. It sounds obnoxious.” Thank Gloria there is at least one person in Ramona’s life who will tell her the truth. But seriously, Avery is a nice real person, and I’m so glad to watch her grow up.
There was also a great exchange between Ramona and Avery regarding Mario. Ramona seemed to be trying to fill her in or pump her for information, and Avery just said, “I don’t ask too many questions.” It was the perfect response to shut her mother down, and also the perfect way to approach the situation. She wants to keep this fight between her parents and not get in the middle, so it’s best not to be too informed.
Contrast that with what Sonja Tremont Morgan of the Mamaroneck Morgans said in the scene just before that, when she was at Bethenny’s branding summit. “You know me,” she told Bethenny. “I don’t ask questions.” While it is essentially the same thing that Avery just said, it is entirely the wrong answer. When you go into a business meeting or try to strike some deal, you should ask a ton of questions. You should ask a Dom DeLuise, a Mama Cass, two Andre the Giants, and a before picture Valerie Bertinelli of questions. That is how you end up staying out of, oh, I don’t know, a million-dollar lawsuit over a John Travolta movie that never got made. Ask questions, Sonja. You ask questions like it’s lighting an abundance candle.
That said, it really was nice for Bethenny to try to help Sonja out on Take Your Friend With a Clothing Line to Work Day. However, there is nothing worse than meetings. The reason that I am a writer is because it is a solitary pursuit, which means that the closest I get to human interaction is shouting at my editor over email that the name of the store is Posche and it should not be changed to Posh or Porsche. It is and forever will be Posche, so please stop changing it, thank you. The best part of being a writer is that there are no meetings, except sometimes with said editor when she tells you that your book is six months overdue and you should probably start writing or, you know, not yell at her about the spelling vagaries of boutiques in New Jersey strip malls. The only thing that could possibly be worse than your own meetings is other people’s meetings. Sartre got it wrong. Hell is not other people; hell is other people’s meetings.
The dinner between Ramona, Dorinda, Bethenny, and Carole was fairly uneventful, except Bethenny trash-talked Heather in front of her best friend Carole, and then when Carole tried to defend her, Bethenny said, “I know she’s your best friend, but I just don’t want to hear it.” What kind of nonsense is that? She’s just made up her mind about Heather and once again tries to mitigate what will and what will not be discussed in her presence?
Ugh, now we have to talk about Ramona’s awful party at AOA, the kind of place where even the mozzarella sticks are bad and the Bud Light is somehow even worse than usual. I can’t believe Ramona’s pretend boyfriend Peter brought her on to bring a hip crowd to the place, and she shows up with a bunch of ladies who have spent more time in the waiting room of their “dermatologist” than they have a nightclub and two underage girls who aren’t even supposed to be in a bar. And then, to make it worse, Josh, the dried pus that makes your sock painfully adhere to a popped blister, showed up wearing that hat again. That is the third time we have seen him in that hat, which not only means that he thinks that hat is cool but also that it is a regular thing that he is wearing all the time. It’s his signature piece, like Anna Wintour’s sunglasses, Karl Lagerfeld’s fan, or the devil’s horns. Seriously, that hat is what you would get if you combined Saddam Hussein’s testicles, the uranium from Chernobyl, two pieces of birthday-cake-flavored bubblegum, and one of your great aunt Suzy’s mouth kisses in Adolf Hitler’s barbecue and left it to smoke for about 45 minutes. God, I hate Josh, a constellation of runny dog diarrhea that turns half a city block into a minefield.
We’re here to talk about Bethenny, though. First, she is absolutely insane with Countess Crackerjacks, who comes over to check on Bethenny after she went berserk at the dinner party. The Countess was right to check in. Like she said, Bethenny’s behavior made it seem like something awful was going down with her, and, as a friend, LuAnn wanted to check on it. Naturally, she wanted to rehash the events a little bit, either to get into the shit or just to figure out what was going on with her friend. Bethenny somehow took that concern and turned it into some kind of attack and started yelling at LuAnn. Again, that is not a way to be put in a corner without Baby. Then she tells the Countess just to be real and shoot straight with her, but what does she think that LuAnn really intends? What sort of secret agenda might she possibly have other than being a good reality-show cast member? Does she have some plot to smuggle all of Bethenny’s statement necklaces out of her apartment? It was entirely unclear.
While this was going on, they both shooed away Kristen, who is more and more like a ghost every week, like some kind of specter that shows up in the fleekest of fleek outfits that she bought on FleekOnTheStreet.fleek, a new retail website for the closet fleek in all of us. Oh, poor Kristen. I wouldn’t be surprised if they just Photoshopped a picture of Avery over her face in the opening credits and pretended like she never existed.
Kristen was upset because Carole stirred some shit and told her that Bethenny said she didn’t hold the trademark to Pop of Color, the name she wants to use for her nail-polish line (don’t laugh), and that she was stupid. Kristen goes over to talk to Bethenny and gets rebuffed. Then Bethenny leaves the Countess to go apologize to Heather, and Kristen intercepts. She explains to Bethenny that she is really, really, really, really, really excited about her nail-polish line (a phrase that should not be uttered by anyone over the age of 29 ever) and wants to know why Bethenny thinks she’s stupid and why she has so much time to Google her company to figure out if she has the trademark.
Bethenny responds by getting up and walking away, to which Heather says, “Get back here,” and Bethenny just shakes her head and says, “It was really nice talking to you,” and walks away, leaving Kristen to trail after her. First of all, who treats people like that? What sort of human thinks it is acceptable to just walk away while someone is trying to talk to you? And what sort of reality-television cast member, which Bethenny is of her own free will, would behave like that? Didn’t Bethenny, just two minutes before, tell Crackerjacks to be real with her but then she goes and acts all fake to Kristen? What is up with that? This is someone she is going to have to continue to work with for a number of months. How does she think their relationship will be after this? Sure, Kristen is about as interesting and useful as a Magic 8 Ball whose internal cube will no longer give an answer other than “Ask Again Later,” but that is no reason to treat her like trash. (Her husband’s hat, on the other hand, is.)
Kristen was sort of asking for it with her snide tone and her “it’s great you have so much time to Google my company,” yes. This isn’t someone she knows well, and she could have sat her down and said, “I heard this and I want to clear it up,” but she did not. Is that a reason for someone to just get up and walk away? No. It is not. Again, this is not a way to blend into the background. Bethenny needs to realize that she cannot control every personal interaction she has and how people talk to her. Until she tries to relate to people on the level, she’s going to come across looking like a howler monkey with a fist full of its own poo.
Bethenny left the bar early, as she leaves everything these days, and ran out into the night to find her driver. She left so quickly she didn’t even put her coat on, and as she paused in front of AOA, the light snow was falling like little bits of the stars were being shaken loose on the city. She picked her phone out of her purse and saw that her driver said he was at the end of the block. She walked down the sidewalk and heard “I found a hobby” coming from the wall next to her. At least that’s what she thought she heard. She looked behind her, scanning the wall but not seeing anything but a garage door, some shuttered storefronts, and random puddles of darkness.
As she passed one of those puddles, a figure stepped out from the wall, pulling a white fur hood away from her face. She took two steps in Bethenny’s direction, then thought better of it. Best not to get too close, at least not yet. There were so many things that she needed to put in place before she revealed herself. There was still so much work to be done. She let Bethenny make her way safely to her car and pivoted to walk down the sidewalk in the other direction. At the intersection, while the red hand of the crosswalk stared down at her, Jill Zarin stopped for a moment to look up at the snow as it cascaded down through the night, but all she could see was falling.
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();
// ]]