Skip to content

Commit 89a9f5b

Browse files
authored
Merge pull request #7 from DealerDotCom/feature/DE145600
DE145600 : Web Integration API : Fix issue with document.currentScript in Firefox.
2 parents e02afc8 + 8110564 commit 89a9f5b

File tree

7 files changed

+42
-42
lines changed

7 files changed

+42
-42
lines changed

source/includes/_debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
```javascript
66
(async APILoader => {
7-
const API = await APILoader.create();
7+
const API = await APILoader.create(document.currentScript);
88
API.subscribe('page-load-v1', ev => {
99
if (ev.payload.searchPage) {
1010
API.log('My integration has loaded and this is a search results page.');

source/includes/_events.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ To receive data for events, you must opt-in to event subscriptions. Each event i
211211
212212
```javascript
213213
(async APILoader => {
214-
const API = await APILoader.create();
214+
const API = await APILoader.create(document.currentScript);
215215
API.subscribe('page-load-v1', ev => {
216216
API.log(ev);
217217
});
@@ -234,7 +234,7 @@ The page load event is useful to determine the context of the current page. By m
234234
235235
```javascript
236236
(async APILoader => {
237-
const API = await APILoader.create();
237+
const API = await APILoader.create(document.currentScript);
238238
API.subscribe('dealership-info-v1', ev => {
239239
API.log(ev);
240240
});
@@ -257,7 +257,7 @@ The dealership info event is useful if you need to know the name and address of
257257
258258
```javascript
259259
(async APILoader => {
260-
const API = await APILoader.create();
260+
const API = await APILoader.create(document.currentScript);
261261
API.subscribe('vehicle-shown-v1', ev => {
262262
API.log(ev);
263263
});
@@ -281,7 +281,7 @@ On a vehicle deals page, a single event is fired because you are viewing a singl
281281
282282
```javascript
283283
(async APILoader => {
284-
const API = await APILoader.create();
284+
const API = await APILoader.create(document.currentScript);
285285
API.subscribe('vehicle-data-updated-v1', data => {
286286
API.log(data.payload.pageData); // Outputs the Page Data object to the console.
287287
API.log(data.payload.vehicleData); // Outputs the updated Vehicle Data object to the console.

source/includes/_locations.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ See the <a href="#api-insert-name-callback-elem-meta">insert documentation</a> f
1010
1111
```javascript
1212
(async APILoader => {
13-
const API = await APILoader.create();
13+
const API = await APILoader.create(document.currentScript);
1414
API.insert('vehicle-media', (elem, meta) => {
1515
// This element is positioned below the vehicle image area on vehicle search pages.
1616
});
@@ -21,7 +21,7 @@ See the <a href="#api-insert-name-callback-elem-meta">insert documentation</a> f
2121
2222
```javascript
2323
(async APILoader => {
24-
const API = await APILoader.create();
24+
const API = await APILoader.create(document.currentScript);
2525
API.subscribe('page-load-v1', ev => {
2626
if (ev.payload.searchPage) {
2727
API.insert('vehicle-media', (elem, meta) => {
@@ -49,7 +49,7 @@ This element is positioned below the vehicle image area on vehicle search pages.
4949
5050
```javascript
5151
(async APILoader => {
52-
const API = await APILoader.create();
52+
const API = await APILoader.create(document.currentScript);
5353
API.insert('vehicle-badge', (elem, meta) => {
5454
// This element is positioned below the vehicle tech specs area on vehicle search and detail pages.
5555
});
@@ -60,7 +60,7 @@ This element is positioned below the vehicle image area on vehicle search pages.
6060
6161
```javascript
6262
(async APILoader => {
63-
const API = await APILoader.create();
63+
const API = await APILoader.create(document.currentScript);
6464
API.subscribe('page-load-v1', ev => {
6565
if (ev.payload.searchPage || ev.payload.detailPage) {
6666
API.insert('vehicle-badge', (elem, meta) => {
@@ -94,7 +94,7 @@ This element is positioned below the vehicle tech specs area on vehicle search a
9494
9595
```javascript
9696
(async APILoader => {
97-
const API = await APILoader.create();
97+
const API = await APILoader.create(document.currentScript);
9898
API.insert('vehicle-pricing', (elem, meta) => {
9999
// This element is positioned below the vehicle pricing area on vehicle search and detail pages.
100100
});
@@ -105,7 +105,7 @@ This element is positioned below the vehicle tech specs area on vehicle search a
105105
106106
```javascript
107107
(async APILoader => {
108-
const API = await APILoader.create();
108+
const API = await APILoader.create(document.currentScript);
109109
API.subscribe('page-load-v1', ev => {
110110
// Only execute the code on search results and vehicle details pages.
111111
if (ev.payload.searchPage || ev.payload.detailPage) {
@@ -133,7 +133,7 @@ This element is positioned below the vehicle pricing area on vehicle search and
133133
134134
```javascript
135135
(async APILoader => {
136-
const API = await APILoader.create();
136+
const API = await APILoader.create(document.currentScript);
137137
API.insert('vehicle-media-container', (elem, meta) => {
138138
// This element is the media gallery container on vehicle details pages.
139139
// Injecting into this location will replace the media gallery with the elements you insert.
@@ -145,7 +145,7 @@ This element is positioned below the vehicle pricing area on vehicle search and
145145
146146
```javascript
147147
(async APILoader => {
148-
const API = await APILoader.create();
148+
const API = await APILoader.create(document.currentScript);
149149
API.subscribe('page-load-v1', ev => {
150150
if (ev.payload.detailPage) {
151151
API.insert('vehicle-media-container', (elem, meta) => {
@@ -167,7 +167,7 @@ This element is the media gallery container on vehicle details pages. Injecting
167167
168168
```javascript
169169
(async APILoader => {
170-
const API = await APILoader.create();
170+
const API = await APILoader.create(document.currentScript);
171171
API.insert('primary-banner', (elem, meta) => {
172172
// This element is typically positioned in a prominent location above the vehicle listings on the Search Results Page.
173173
// On the Details page, it is near the top of the vehicle information, below the media gallery.
@@ -179,7 +179,7 @@ This element is the media gallery container on vehicle details pages. Injecting
179179
180180
```javascript
181181
(async APILoader => {
182-
const API = await APILoader.create();
182+
const API = await APILoader.create(document.currentScript);
183183
API.subscribe('page-load-v1', ev => {
184184
if (ev.payload.searchPage || ev.payload.detailPage) {
185185
API.insert('primary-banner', (elem, meta) => {
@@ -212,7 +212,7 @@ You can target either the listings or details page by first subscribing to the <
212212
213213
```javascript
214214
(async APILoader => {
215-
const API = await APILoader.create();
215+
const API = await APILoader.create(document.currentScript);
216216
API.insert('secondary-content', (elem, meta) => {
217217
// This element is the a secondary content container on vehicle details pages roughly 2/3 of the way down.
218218
// It may also be added custom to one or more standalone pages on the website.
@@ -224,7 +224,7 @@ You can target either the listings or details page by first subscribing to the <
224224
225225
```javascript
226226
(async APILoader => {
227-
const API = await APILoader.create();
227+
const API = await APILoader.create(document.currentScript);
228228
API.subscribe('page-load-v1', ev => {
229229
if (ev.payload.detailPage) {
230230
API.insert('secondary-content', (elem, meta) => {
@@ -248,7 +248,7 @@ Since this may also be present on one or two standalone pages as custom addition
248248
249249
```javascript
250250
(async APILoader => {
251-
const API = await APILoader.create();
251+
const API = await APILoader.create(document.currentScript);
252252
API.insert('content', (elem, meta) => {
253253
// This element is will only insert on pages created by us for your purposes.
254254
// It may also be present on pages created for another integration.
@@ -260,7 +260,7 @@ Since this may also be present on one or two standalone pages as custom addition
260260
261261
```javascript
262262
(async APILoader => {
263-
const API = await APILoader.create();
263+
const API = await APILoader.create(document.currentScript);
264264
API.subscribe('page-load-v1', ev => {
265265
if (ev.payload.pageName === 'YOUR_LANDING_PAGE') { // Note: Replace 'pageName' with the one we provide at page creation.
266266
API.insert('content', (elem, meta) => {

source/includes/_methods.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
```javascript
88
(async APILoader => {
9-
const API = await APILoader.create();
9+
const API = await APILoader.create(document.currentScript);
1010
API.subscribe('event-name-and-version', ev => {
1111
API.log(ev);
1212
});
@@ -20,7 +20,7 @@ Please see the <a href="#event-subscriptions">specific event documentation</a> f
2020
2121
```javascript
2222
(async APILoader => {
23-
const API = await APILoader.create();
23+
const API = await APILoader.create(document.currentScript);
2424
API.insertCallToAction('button', 'value-a-trade', meta => {
2525
return {
2626
"type": "default",
@@ -113,7 +113,7 @@ After creating the callback object, you must then return it for the API to creat
113113
(async APILoader => {
114114

115115
// Initialize an instance of the API
116-
const API = await APILoader.create();
116+
const API = await APILoader.create(document.currentScript);
117117

118118
// Receive a notification each time vehicle data is updated on the page (or a new page is loaded).
119119
API.subscribe('vehicle-data-updated-v1', ev => {
@@ -165,7 +165,7 @@ Field Name | Purpose | Field Format
165165
166166
```javascript
167167
(async APILoader => {
168-
const API = await APILoader.create();
168+
const API = await APILoader.create(document.currentScript);
169169
API.insertGalleryContent('vehicle-media', [
170170
{
171171
type: 'image',
@@ -207,7 +207,7 @@ Name | Description
207207
208208
```javascript
209209
(async APILoader => {
210-
const API = await APILoader.create();
210+
const API = await APILoader.create(document.currentScript);
211211
API.insert('location-name', (elem, meta) => {
212212
API.log(elem); // The DOM element where markup may be inserted.
213213
API.log(meta); // The payload object for the current insertion point.
@@ -229,7 +229,7 @@ If you need to execute additional code before determining if you wish to insert
229229
230230
```javascript
231231
(async APILoader => {
232-
const API = await APILoader.create();
232+
const API = await APILoader.create(document.currentScript);
233233
// Receive a notification each time vehicle data is updated on the page (or a new page is loaded).
234234
API.subscribe('vehicle-data-updated-v1', ev => {
235235
// Insert content into each vehicle location now present on the page.
@@ -247,7 +247,7 @@ If you need to execute additional code before determining if you wish to insert
247247
(async APILoader => {
248248

249249
// Initialize an instance of the API
250-
const API = await APILoader.create();
250+
const API = await APILoader.create(document.currentScript);
251251

252252
// Receive a notification each time vehicle data is updated on the page (or a new page is loaded).
253253
API.subscribe('vehicle-data-updated-v1', ev => {
@@ -298,7 +298,7 @@ Field Name | Purpose | Field Format
298298
299299
```javascript
300300
(async APILoader => {
301-
const API = await APILoader.create();
301+
const API = await APILoader.create(document.currentScript);
302302
const button = API.create('button', {
303303
href: 'https://www.google.com/',
304304
text: {
@@ -364,7 +364,7 @@ Field Key | Example Value | Field Format | Purpose
364364
365365
```javascript
366366
(async APILoader => {
367-
const API = await APILoader.create();
367+
const API = await APILoader.create(document.currentScript);
368368
API.append(targetEl, appendEl);
369369
})(window.DDC.APILoader);
370370
```
@@ -373,7 +373,7 @@ Field Key | Example Value | Field Format | Purpose
373373
374374
```javascript
375375
(async APILoader => {
376-
const API = await APILoader.create();
376+
const API = await APILoader.create(document.currentScript);
377377
API.insert('target-location-name', (elem, meta) => {
378378
let lowPrice = Math.round(meta.finalPrice - 1000);
379379
let highPrice = Math.round(meta.finalPrice + 1000);
@@ -399,7 +399,7 @@ When calling the insert method, the goal is to insert some markup into a locatio
399399
400400
```javascript
401401
(async APILoader => {
402-
const API = await APILoader.create();
402+
const API = await APILoader.create(document.currentScript);
403403
// Loads a JavaScript file
404404
API.loadJS('https://www.company.com/script.js')
405405
.then(() => {
@@ -416,7 +416,7 @@ The loadJS method is a simple way to include additional JavaScript files require
416416
417417
```javascript
418418
(async APILoader => {
419-
const API = await APILoader.create();
419+
const API = await APILoader.create(document.currentScript);
420420
// Loads a CSS stylesheet
421421
API.loadCSS('https://www.company.com/integration.css')
422422
.then(() => {

source/includes/_requirements.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ When you begin development of your script, it's easy to test on any Dealer.com s
1818

1919
```javascript
2020
(async APILoader => {
21-
const API = await APILoader.create();
21+
const API = await APILoader.create(document.currentScript);
2222
API.test('https://www.yourdomain.com/your-javascript-file.js');
2323
})(window.DDC.APILoader);
2424
```
@@ -41,7 +41,7 @@ Your code should be minimal and perform only actions necessary to bootstrap your
4141
4242
```javascript
4343
(async APILoader => {
44-
const API = await APILoader.create();
44+
const API = await APILoader.create(document.currentScript);
4545
// API.subscribe(...);
4646
// Your code here
4747
})(window.DDC.APILoader);

source/includes/_samples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if (window.ResizeObserver) {
2929
3030
```javascript
3131
(async APILoader => {
32-
const API = await APILoader.create();
32+
const API = await APILoader.create(document.currentScript);
3333

3434
API.insert('content', (elem, meta) => {
3535
const iframeElem = document.createElement('iframe');

source/includes/_utilities.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ In addition to the event based system for working with sites, some utility metho
88
99
```javascript
1010
(async APILoader => {
11-
const API = await APILoader.create();
11+
const API = await APILoader.create(document.currentScript);
1212
API.subscribe('vehicle-data-updated-v1', data => {
1313

1414
API.log(data.payload.pageData); // Logs the Page Data object
@@ -36,7 +36,7 @@ This can be used to obtain an array of attributes for the currently displayed ve
3636
3737
```javascript
3838
(async APILoader => {
39-
const API = await APILoader.create();
39+
const API = await APILoader.create(document.currentScript);
4040
const testConfig = {
4141
dealerId: "12345",
4242
showOnSRP: true,
@@ -60,7 +60,7 @@ This fetches a JavaScript object of your integration's configuration for the cur
6060
6161
```javascript
6262
(async APILoader => {
63-
const API = await APILoader.create();
63+
const API = await APILoader.create(document.currentScript);
6464
API.utils.getDealerData().then(dealerData => {
6565
// Logs the Dealership Info Event object for the current website.
6666
API.log(dealerData);
@@ -76,7 +76,7 @@ This fetches the <a href="#dealership-info-event">Dealership Info Event object</
7676
7777
```javascript
7878
(async APILoader => {
79-
const API = await APILoader.create();
79+
const API = await APILoader.create(document.currentScript);
8080
API.utils.getJwtForSite().then(jwtObject => {
8181
API.log(jwtObject);
8282
// Returns a data structure like this:
@@ -96,7 +96,7 @@ This fetches an object containing a Java Web Token which can be used to secure/v
9696
9797
```javascript
9898
(async APILoader => {
99-
const API = await APILoader.create();
99+
const API = await APILoader.create(document.currentScript);
100100
API.utils.getJwtForVehicles().then(jwtObject => {
101101
API.log(jwtObject);
102102
// Returns a data structure like this:
@@ -116,7 +116,7 @@ This fetches an object containing the array of VINs on the current page and a co
116116
117117
```javascript
118118
(async APILoader => {
119-
const API = await APILoader.create();
119+
const API = await APILoader.create(document.currentScript);
120120
API.utils.getPageData().then(pageData => {
121121
// Outputs the Page Data Object for the current page.
122122
API.log(pageData);
@@ -132,7 +132,7 @@ This fetches the <a href="#page-event">Page Event object</a> for the current web
132132
133133
```javascript
134134
(async APILoader => {
135-
const API = await APILoader.create();
135+
const API = await APILoader.create(document.currentScript);
136136
const urlParams = API.utils.getUrlParams(); // Returns the current URL parameters as object attributes, so you can easily access the values.
137137
API.log(urlParams); // Log the entire object.
138138
API.log(urlParams.query); // Access just the `query` parameter, for example.
@@ -161,7 +161,7 @@ Will return the following object:
161161
162162
```javascript
163163
(async APILoader => {
164-
const API = await APILoader.create();
164+
const API = await APILoader.create(document.currentScript);
165165
const config = API.utils.getVehicleData().then(vehicleData => {
166166
// Outputs the current set of vehicle data.
167167
API.log(vehicleData);

0 commit comments

Comments
 (0)