New Jersey’s Education Rebellion Was a Long Time Coming
But Democrats didn’t heed the signs.
ByAndrew Rice,
a features writer at New York Magazineand has been a staff member since 2012. He is the author of two books, including ‘The Year That Broke America,’ a history of the contested 2000 election.
Is he listening? N.J. Gov. Phil Murphy with pre-K students.
Photo: Mary Altaffer/AP/Shutterstock
Is he listening? N.J. Gov. Phil Murphy with pre-K students.
Photo: Mary Altaffer/AP/Shutterstock
On Wednesday night, 24 hours later than expected, news organizations announced that Phil Murphy had been reelected governor of New Jersey. The narrow victory was a dumbfounding rebuke of the state’s Democrats, who went into the election with the drink-clinking serenity of the ensemble in the first act of the Poseidon Adventure. With the exception of one or two outliers, the polls all showed Murphy winning by eight or more points. Instead, his party got smacked by a Republican wave. Murphy managed to win by a whisker, thanks to late-arriving results out of machine-run North Jersey counties. But there were shocking results down the ballot. In South Jersey, the president of the state senate, an ally of the state’s most powerful political boss, lost to a truck driver who reported spending $2,160 on his campaign.
What happened? Political analysts are like weathermen — they’ll do a good job of telling us why it stormed yesterday, once they have a chance to parse the numbers. But in the absence of hard evidence, a consensus is already starting to emerge: It was the schools. Although culture-war controversies over race and curriculum are more muted in New Jersey than in Virginia, the Republican candidate Jack Ciattarelli, a former state legislator, ran as a Regular Jersey Guy who attacked high property taxes, Murphy’s mask and vaccine mandates, and the way schools are teaching about race. To say that the result was a cultural backlash, though, is an oversimplification. Or actually, come to think of it, an overcomplication. For a lot of parents, it was pretty simple. The public schools were closed for much longer than necessary, and Murphy did little to open them.
Who could have predicted this? Well, anyone with a kid in public school during the pandemic paralysis of last year. I won’t pretend that my own experience is more meaningful than anyone else’s. But the singular of data is anecdote, so let me tell you what happened in my town.
In 2015, when my son was 3, I moved to the suburb of Montclair, New Jersey, because, well, of course I would. One year later, an election was held, and Donald Trump won it. Everyone in town was very upset. There were marches and vigils. When an elderly Trump supporter was arrested for tagging a storefront across the street from my local coffee shop with MAGA graffiti, it made national news. A group called “NJ-11 for Change” spontaneously coalesced on Facebook and started to protest against the local Republican congressman, a moderate committee chairman whose family had held the seat on and off since the Revolutionary War. The group received adoring press coverage and went on Rachel Maddow’s show. The Republican decided to retire. An impressively credentialed former prosecutor and public school mom named Mikie Sherrill emerged to run for the seat. When Politicolater profiled her, calling her “the most important new woman in Congress,” they took her picture at the diner around the corner from the coffee shop, a place I often took my son for pancakes after soccer on Saturdays. It’s that kind of town.
A year after Trump’s election, my son went to kindergarten at the elementary school across the street from our house. We held his hand when we crossed at the corner, and didn’t think much about what happened once he walked in the door. The tax bill for our three-bedroom home was $19,000 a year.
Then, one day in 2020, school was dismissed, and the building across the street didn’t reopen to students for another 13 months. As a parent, this pandemic paralysis was emotionally excruciating. (I ended up writing about it, though for the purpose of maintaining some distance, and also my sanity, I focused my reporting mainly on Maplewood, a nearbytown.) Suddenly, it felt like everyone in Montclair was fighting over everything, but most of all about the schools. Some parents were protesting, organizing a pro-reopening group called Montclair FAIL. (The group later changed its leadership and it now goes by a less-polarizing acronym Montclair PAGE.) Some parents were deathly afraid to send their kids back. Some parents were starting to wonder why a district with an annual budget of roughly $130 million was unable to maintain basic systems like ventilation. And everyone was wondering where our Democratic governor was on all of this.
But Murphy was nowhere to be seen. The former Goldman Sachs man had won high marks from the public for his handling of the public-health emergency, implementing McKinsey-tested interventions and offering genial Irish eulogies for the dead, signing off with “God bless ‘em.” But when it came to education, he dodged the argument, delegating all the reopening decisions to beleaguered superintendents and school boards, citing the principle of local control.
There was a brief moment, in the summer of 2020, when it appeared as if Murphy might be edging toward a more proactive role. The scientific evidence was already pretty clear by this time: With masking and contact tracing, it would be possible to resume in-person learning. Other states were already doing so. But many teachers were understandably terrified. Over a few days in August, the state’s largest and most powerful teachers union, the New Jersey Education Association, declared that it was unsafe to return to classrooms, and Murphy immediately reversed himself, saying local districts could continue with remote learning if they provided a “good reason.” Oftentimes, that reason turned out to be the objection of the unionized workforce. It was hard to escape the suspicion that Murphy was removing himself because he was unwilling to cross NJEA, his most important political ally. Among other things, the union had secretly funneled millions into a super-PAC formed to advocate for Murphy’s policy objectives.
And who was in charge of the union? That’s where things got particularly interesting in Montclair. The most powerful official in NJEA, an ambitious up-and-comer named Sean Spiller, was also our town’s mayor. In the midst of the pandemic lockdown, Spiller had narrowly won a low-turnout election marred by the flawed implementation of the new vote-by-mail system. Murphy took time out from his crisis-management duties and came to swear in the union boss. In another town, this might not have presented a blatant conflict of interest. Most municipalities in New Jersey have elected school boards that control the budget and handle contract negotiations with teachers. But Montclair had an archaic form of government in which the mayor had the sole discretion to appoint all of the members of the school board. It was responsible for hiring — and, with depressing regularity, forcing out or firing — the district’s superintendent.
The present superintendent, a brand-new guy, had been handed the job of reopening the schools over the mayor’s organization’s objections. The teachers union refused to come back to the classroom, even after vaccines were widely available, and the two sides ended up in court. In the wake of the lawsuit, the mayor placed three new appointees on the board, kicking off one of the only parents of school-age children on it. The displaced board member attacked Spiller in turn, saying he had been removed “because I dared to represent the interests of our children, rather than a political machine.” Spiller has consistently refused to acknowledge the existence of any conflict of interest. He did not respond to a request for comment, but yesterday, in his capacity as the statewide union president, he put out a triumphant statement that trumpeted the NJEA’s status as one of “the first organizations to endorse” Murphy. The union’s new secretary-treasurer Petal Robertson, who, prior to her election to that extremely well-compensated position earlier this year, was the NJEA local head in Montclair and the vociferous leader of the opposition to reopening the schools for in-person learning, called Murphy’s victory “a win for New Jersey’s families.”
The height of the reopening conflict coincided with the 2020 presidential campaign and the ensuing postelection chaos. This created a bizarre bifurcation within communities like ours. The election results showed that people who lived in Montclair — with the exception of a few MAGA cranks — were overwhelmingly opposed to Trump. Meanwhile, everyone you talked to was furious with the local Democrats who were mismanaging the schools. The cognitive dissonance worked the other way, too. The Biden victory marked the culmination of the Trump-era realignment of the suburbs, driven primarily — both in terms of numbers and volunteer energy — by college-educated professional women. Yet the policy decisions made by local Democrats, particularly around schools, worked against the interests of these very valuable voters.
Many parents — women especially — found themselves acting as involuntary substitute teachers and full-time caregivers, continually on call to dig out crayons, serve snacks, and solve technical problems with the Zoom. It was only natural that many of these frustrated parents started to pay closer attention to what was happening in the classroom — it was right there in their home. In the run-up to the election in Virginia, which was considered the one to watch, the media mainly focused — probably too much, in retrospect — on Fox News–driven controversies over critical race theory that erupted in conservative suburbs in Virginia. These were only one culturally specific manifestation of a universal ramification of remote learning. Parents were watching. They were Zooming into school board meetings. They were bombarding principals with emails. They were livid; they wanted to know who was in charge.
But where was the manager? Last June, at the end of the school year, Murphy made a regulatory change that effectively prevented districts from using remote learning this fall, and all the kids went back to school, wearing masks, just as they maybe could have done 12 months earlier. Murphy’s aides concede that the delay was politically damaging, although they also say it could have been worse if the governor had not acted decisively when he did. “The bottom line is, you have to make tough decisions when you’re a governor, particularly during a pandemic,” says Mahen Gunaratna, Murphy’s communication director. “But sometimes there can be a backlash to making those tough calls.” Murphy’s campaign attributes the uncomfortably narrow margin to a confluence of two factors: Democrats saw the usual odd-year falloff in electoral participation on the Democratic side, while casual Trump voters turned out at a level closer to that of last year’spresidential race. One Murphy adviser said yesterday that he saw little evidence of a connection between that political dynamic and school closures. “What happened was we saw unbelievably historic turnout on the other side,” he said. “In a lot of the areas with red turnout, their schools were open.” Maybe the suburban Democrats will return in 2022, when Sherrill and a number of other members of Congress elected in the 2018 blue wave face potentially tough battles, albeit in new districts designed by a friendly administration.
Then again, maybe the effect will end up lasting longer than one cycle. On a localized level, the damage — to the kids, to the emotional health of parents and teachers, to the public school system, and to Democrats — cuts deep. The longtime principal of my son’s school announced her retirement and addressed a school board meeting, where she tried to talk about deeper issues in the schools that the pandemic had revealed. The chair of the school board muted her. The principal who replaced her is an energetic young educator, but the school’s student body appears to have decreased substantially. Over the summer, the Montclair Local newspaper reported that district-wide kindergarten enrollment was down 40 percent from where it was before the pandemic. Official figures have not yet been released, but informal estimates circulating among parents suggest a staggering drop on the elementary level, something in the vicinity of 20 percent.
The author’s first-ever political yard sign.
Photo: Andrew Rice
Parents who managed to get their kids through the endless wait list for the fancy private school in town, which held classes all last year, talk about the decision in furtive, mildly abashed tones, like they cut the line at the Kabul airport. Two of the Maplewood parents I wrote about in my story earlier this year decided to move to other towns, at least partly out of dismay with how the district handled reopening. One of our neighbors, whose son played baseball with my kid, ended up moving to North Carolina, citing the same reason. My wife and I have decided to stick it out in public school — we love the place and the people inside it — but this fall, for the first time in our lives, we stuck a campaign sign in our front yard. It was for a referendum that parents in Montclair managed to get on the ballot, calling for the abolition of the politically appointed school board, and its replacement with one elected by the community. “ELECTED BOE: YES,” it says, in Crayola-colored letters. The local Democratic machine tried to use demagoguery to defeat the referendum, claiming that elections would inevitably lead to the abolition of one of the best things about Montclair’s schools, its magnet system, which is meant to ensure racial balance.
The referendum passed with 70 percent of the vote. Even with that passionately contested issue on the ballot, though, turnout was around half of what it was for the 2020 presidential election, and roughly at the same level as 2017, when Murphy faced little serious opposition. My wife, a socially liberal professional woman, voted for the school board but left her ballot blank in the race for governor. She had sworn to me that she would never cast a vote for Phil Murphy again after our son spent the majority of last school year learning in our dining room. Many of the public school parents I know around here made similar decisions. “I feel like he harmed my daughter,” one of them texted me yesterday. “I just couldn’t do it.”
An extreme reaction? Maybe. But people tend to get mad — incandescently furious — when they think you’re hurting their kids. The provision of public education is among the most basic functions of government. And for many, many, many months, New Jersey’s government fucked it up. What’s more, the Democrats who run that government assured the public that they saw the problem yet acted like they had higher priorities. For the most part, they seem to have been complacent in the belief that the free-floating anger would remain confined to Facebook groups and school board Zooms.
But it finally found its object on Tuesday.
This story has been updated to more accurately reflect the amount Ed Durr spent to unseat the state senate president.
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();
// ]]