The Dragons Should Sound ‘Like You Can Pop Them on the Nose’
ByRoxana Hadadi,
a Vulture TV critic who also covers film and pop culture
Photo: Theo Whiteman/HBO
For a dozen years, sound designer Paula Fairfield has been bringing the dragons of George R.R. Martin’s HBO-adapted world to aural life. It’s always been a massive task, but on Game of Thrones, it was somewhat contained: three dragons with three vocal palates comprising 30 or so animal noises. Now, on House of the Dragon, Fairfield can’t even approximate how many sounds she’s working with to create the creatures’ vocals, wing sounds, and movements through the air and on land. There are more than a dozen dragons running around the Seven Kingdoms, and every one, Fairfield says, is “bespoke” — a combination of layers, pitch changes, and audio manipulation that gives each a distinct personality. And repetition isn’t really in Fairfield’s sonic vocabulary.
“The big thing I discovered about Ryan Condal this season is that he loves him some big, long roars, and those are the most difficult to do,” Fairfield says of HotD’s showrunner. “You don’t want to hear any looping going on. You want to hear some kind of progression of aggression or a diminution.”
Asseason two moved deeper into the Dance of the Dragons civil war that tears the Targaryen family apart, the dragons and their personalities, emotions, grudges, and lifestyles increasingly took center stage. That’s where Fairfield’s mixes came in, allowing the dragons to chirp, screech, sigh, sing, or laugh. Her sound designs are essential components of how we understand Westeros’ dragons as not just nuclear weapons or gods but complex creatures with their own inner lives and biological differences: Caraxes’s deviated septum, Vermithor’s throaty chuckle. And as Fairfield puts it, their physiology — particularly an organ she calls the “fire sphincter” — is an integral part of that story.
Do you follow a guiding principle for what the dragons should sound like? The brief for House of the Dragon was that each dragon was to sound completely different. I always ask Ryan what he’s thinking for the vibe of each one. He has given me some interesting prompts. Moondancer was one of the best. I got one word back, and it was “Bowie.” This is a sound designer’s dream and nightmare. [Laughs.]
The dragons are all custom; I start clean on each one of them. I don’t go back, because often I find that if I do that, it’ll lock me into a certain way of thinking. The only thing that I did cheat a little were wings, because I started to come up with something that was really good; Meleys and Seasmoke are using a similar palette for the wings because they’re pretty much the same size. But then the vocals, no. What’s amazing about this gig is that the dragons can be anything. If every dragon sounded the same in the show, it would be not only boring, but hard to follow along. So they just let me go and do whatever. We’re selling air. I mean, they don’t exist. We’re selling pixels in air. The visual effects are spectacular, and I comb every frame for an opportunity to find something. The old adage “seeing is believing” — hearing is believing. When you can see and hear together, that would even be stronger.
During Game of Thrones, you said you used approximately 30 animals for the dragons’ vocal palates. Is it the same on House of the Dragon? No, that’s the challenge. There’s like 17 dragons total in this series, whereas Thrones had only three. I came on in season three of GoT when they were toddlers, and it never occurred to me that they were getting bigger and bigger and bigger until season five. This season, we are on the backs of dragons quite often. I had been working on Caraxes and Daemon on their way to spooky Luigi’s Castle, and I had sent in a demo, and Ryan said something about how he wanted that feeling of being on the dragon more. That changed how I went about Rook’s Rest. I actually redid the wings. There’s a lot more definition and push [moves arms down] and whoop [moves arms up] to get that movement and make it really feel like you’re rocking and rolling on the backs of the dragons. It was a significant upgrade this season.
Do you have an idea of how many different sounds or different animals are in each mix? I have no idea. The most complex is Caraxes, because of the whole deviated septum thing. He’s got a lot of layers: He has four layers to his voice, and each layer has five or six layers. When you’ve got to do these extended roars, some of them as long as 12 seconds, that is incredibly difficult. You don’t want to hear repeating. I’m taking material that should not be used for dragons and pitching it down and stretching it out. I usually push in, so you hear the dragon pushing in, and getting harder and harder and harder because it’s building up aggression.
That end shot of seven, with all of them up roaring together, Ryan wanted it longer. We’d never heard Syrax scream that long, and he asked for a longer, harder, more aggressive scream. She’s not overtly aggressive. We haven’t seen her in any battle; she’s intimidating a little bit here and there. So, how can I manipulate sounds and have them change organically and up the ante? I work really hard to try to meet the visual effects to their gloriousness, and try to find something that is equally beautiful in sound.
Are all the dragon sounds organic and animal sounds, or are there inorganic or mechanical sounds in the mix? I hardly use humans. Animals, all their utterances are primal, pure emotion. They will make the weirdest sounds. I remember having this discussion on my very first episode of Thrones with Greg Spence, my producer at the time. We were talking about how dogs bark and lions roar, but it’s the sounds in between that are special and define personality. They’ll surprise you, and those are the things I’m looking for, things that pull you closer to them and make you feel like you can pop them on the nose.
What are the unexpected animal sounds in House of the Dragon? The brief on Vhagar was that she’s old, cranky, has IBS, has no fucks left to give. Where am I going to look for something that articulates “cranky”? It’s literally an infant being really cranky. If you listen, it makes sense because she’s like [sticks tongue out and grimaces] all the time. It’s pitched way, way down, and stretched out, but she is literally our old cranky baby. I have some jokes in there that I laugh about.
I have to ask you what the jokes are. It happens twice, once in Game of Thrones, when Drogon torches Varys, and in episode five this season, when Daemon is talking to that group of dudes and Caraxes’s head comes down. In both cases, embedded in that is me saying “fava beans.” I’ve not told anybody that, and HBO doesn’t even know it. You can’t really hear it. But the beats are “fava beans.” I work alone, so I’m using myself in whatever way. It’s me challenging myself to see how far I can go while still staying in the box.
The reason I asked about inorganic sounds is because when the dragons get ready to use their fire, it sounds to me like an engine revving up. Is the fire part of their vocal signature? Up until this season, we’ve not been in a dragon’s mouth when they’re shooting fire. We’re generally at quite a distance. Fire is fire, it spews, whatever. But I had a problem that started in Rook’s Rest. We have two gigantic dragons tumbling ass over teakettle, blowing each other with fire. And I thought, What the hell am I gonna do to differentiate this? Fire is white noise. To solve that, I started thinking about fire sphincters. [Laughs] Fire holes! The anatomy of the dragon, how does that work?
I went back to something I did in episode 109, when Meleys comes up through the floor. It appears that she is going to blow the shit out of Alicent, and then she screams. If you listen just before she screams, there’s a chirp. It’s a little bird thing I liked. That was the first time I thought about fire sphincters, and what she does there is clamp her fire hole shut before she blows. I went back to that for Rook’s Rest. You’ll hear it on Vhagar and you’ll hear it on Meleys, and a little on Sunfyre, but his fire sphincter isn’t quite as strong. I imagined it like a blowhole, what a dolphin or a whale has, but it shoots fire instead of water. And then that brings me to the idea of the deviated septum with Caraxes. In my mind, he has a split sphincter, and he knows that he can play around with that and whistle through it, and it’s become this perverse thing he does. In Rook’s Rest, with Meleys, if you listen carefully, they did downplay it a bit. I was a little disappointed by the mix. But there’s music there — goddamn Ramin. [Laughs] But you hear her priming her fire hole. It doesn’t matter that you don’t pick up on it. It adds another texture and movement. Now it comes into my version of dragon lore, which is: fire sphincter.
Did the sounds of a dolphin hole or whale blowhole make it into the mix? I just imagined it that way, but we do hear the dolphin stuff throughout: You hear it in the babies, in baby Drogon, in the little guys trying out their little fire hole, spitting and hissing. To me, the dolphin squeaky sounds come from the fire hole, actually, not necessarily from their vocal cords. That’s the beauty of dragons: There is no wrong answer here, but it sets up rules, a little bit of a structure, and it’s something I will use in the future. We’ve got some massive battles coming up next season, I’m sure. I’m terrified for season three, but one season at a time.
When Syrax and Seasmoke face off in episode seven, are they conversing with each other or just peacocking? How much of this is language, and how much of this is intimidation? There’s some peacocking going on, but in my mind, Seasmoke has a southern drawl, Syrax is randomly French, and they’re having an argument, which has been ongoing and continues. One of my pet peeves having moved to the United States from Canada was that some Americans say “foy-er.” I can’t stand that, it drives me crazy. The dragons are actually having an ongoing argument about “foy-er” or “foy-ay,” and that’s it, back and forth. When they’re flying out together, they’re still yelling back and forth, and then Caraxes pops up and yells “mudroom.” [Laughs.] That’s me, that’s me. That’s silly, and I was literally giggling. It’s conversation. It gives a cadence. If you go to a dog park with your dogs, and you’re having a conversation with one of the owners and your dogs are goofing around on the side, they don’t give two flying fucks what you’re talking about. They got their own deal going on: “Let me smell your butt.” “No, let me smell your butt.” So it was meant to be a full-blown conversation, with some peacocking and intimidation.
Later, with the Red Sowing, Vermithor goes full Jurassic Park. How did you approach that? Vermithor has to be intimidating. We did catch a very little glimpse of him at the end of season one, and the idea was this massive beast bumping around. He’s so big that he’s brushing the walls, and everybody’s staring at the darkness, and you see nothing but you hear him. The interaction with Rhaenyra and Vermithor is my favorite so far of the series. The brief was originally that Ryan wanted them to breathe together, but when I looked at it, you don’t really see Rhaenyra heaving. She’s not even breathing, almost. So I thought back to when Daemon was singing to Vermithor, and I thought, What if Vermithor sings to Rhaenyra? There’s a little bit of whale song in there. She calls and he starts humming to her, and then you hear it again when Vermithor claims Hugh. That moment where Vermithor and Rhaenyra connect says to me that even the dragons know who the queen is.
When I first saw the scene, I completely underestimated the off-screen stuff. To continue to create the narrative off-screen, you have to still hear what’s going on onscreen: burning, chewing, snacking, stomping, and then the turn with Vermithor and Hugh. I’m still exhausted from it.
That scene cycles us through so many genres. It really takes us on an emotional roller coaster. When Vermithor quietly comes out, a couple of people have noted that he’s kind of laughing. I meant that. He’s going, Ooh, look at all these snacks. There was even a meme with a big bucket of KFC, and I’m like, That’s exactly what he’s thinking.
In the finale, we finally see Sheepstealer, a wild dragon that is nomadic. What did you want its screech to tell us? The scene immediately after this is Mysaria and Rhaenyra standing on the balcony, watching Moondancer and Vermax frolicking, chittering, whistling — joyous dragons doing joyous dragon things. Ryan wanted to note the difference between a rider dragon, the dragons that live on Dragonstone and are pampered and hand-fed, and the riderless dragon. My solution is that Sheepstealer has no song in its voice. The frolicking, spoiled dragons are all singing and twirling and chittering, and this is like the working-class dragon, out here just trying to survive. She’s looking for her next meal, may not eat for weeks. I really tried to make it rough and raw and a little grungy in her voice. I don’t know what they’re going to do with this; maybe she gets a rider if Rhaena claims her. And if that becomes an aspect, perhaps she will find song. That’s an interesting TBD for the next season.
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(4),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(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 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,"4":4,"12":12,"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();
// ]]