Skip to content

Commit fe716b3

Browse files
committed
minor js fixes & name chunks
1 parent 42960b4 commit fe716b3

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

src/scripts/components/async-loading.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ function loadPage(newUrl) {
205205
gtag('config', gaTag, { page_path: pathName });
206206

207207
// Marketo
208-
if (typeof window.Munchkin !== 'undefined') {
208+
if (typeof window.Munchkin !== 'undefined' && typeof window.Munchkin.munchkinFunction === 'function') {
209209
window.Munchkin.munchkinFunction('clickLink', { href: newUrl });
210210
} else {
211211
window.DD_LOGS.logger.info('Munchkin called before ready..');

src/scripts/components/security-rules.js

+14-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ export function initializeSecurityRules() {
2323
let results = [];
2424

2525
if (filterCategoryValue && filterCategoryValue !== 'all') {
26-
results = document.querySelectorAll(`.${filterCategoryValue}`);
26+
const val = (filterCategoryValue.startsWith('.')) ? filterCategoryValue.slice(1) : filterCategoryValue;
27+
results = document.querySelectorAll(`.${val}`);
2728
} else {
2829
results = allRules;
2930
}
@@ -54,10 +55,13 @@ export function initializeSecurityRules() {
5455

5556
const handleEmptyResultSet = () => {
5657
const searchQuery = inputSearch.value;
57-
const activeCategoryFilter = stringToTitleCase(document.querySelector('.controls .active').text);
58+
const txt = (document.querySelector('.controls .active')) ? document.querySelector('.controls .active').text : '';
59+
const activeCategoryFilter = stringToTitleCase(txt);
5860
const message = `No results found for query "${searchQuery}" in category ${activeCategoryFilter}`;
59-
jsEmptyResults.innerText = message;
60-
jsEmptyResults.classList.remove('d-none');
61+
if(jsEmptyResults) {
62+
jsEmptyResults.innerText = message;
63+
jsEmptyResults.classList.remove('d-none');
64+
}
6165
}
6266

6367
const showResults = (filteredResults) => {
@@ -77,7 +81,7 @@ export function initializeSecurityRules() {
7781
// Handle empty result set
7882
if (filteredResults.length < 1) {
7983
handleEmptyResultSet();
80-
} else {
84+
} else if (jsEmptyResults) {
8185
jsEmptyResults.innerText = '';
8286
jsEmptyResults.classList.add('d-none');
8387
}
@@ -92,11 +96,11 @@ export function initializeSecurityRules() {
9296
})
9397
}
9498

95-
const handleCategoryFilterClick = (event) => {
99+
const handleCategoryFilterClick = (event) => {
96100
// If button is already active, or an operation is in progress, ignore the click
97101
if (event.target.classList.contains('active') || !event.target.getAttribute('data-filter'))
98102
return;
99-
103+
100104
const searchValue = inputSearch.value.length > 2 ? inputSearch.value.toLowerCase().trim() : '';
101105
const filtered = filterResults(event.target.dataset.filter, searchValue);
102106
activateButton(event.target, filters);
@@ -105,7 +109,8 @@ export function initializeSecurityRules() {
105109

106110
const handleKeyup = () => {
107111
const searchValue = inputSearch.value.length > 2 ? inputSearch.value.toLowerCase().trim() : '';
108-
const activeCategoryFilter = document.querySelector('.controls .active').dataset.filter;
112+
const activeCategory = document.querySelector('.controls .active');
113+
const activeCategoryFilter = (activeCategory) ? activeCategory.dataset.filter : '';
109114
const { hash } = window.location;
110115
const replaceUrl = hash ? `?q=${searchValue}${hash}` : `?q=${searchValue}`
111116

@@ -150,4 +155,4 @@ export function initializeSecurityRules() {
150155
activateButton(activeFilterButton, filters);
151156
showResults(filtered);
152157
}
153-
}
158+
}

webpack.common.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ const commonConfig = env => {
4343
},
4444
output: {
4545
path: path.join(__dirname, 'public', 'static'),
46-
publicPath: 'static'
46+
publicPath: 'static',
47+
chunkFilename:
48+
process.env.NODE_ENV === 'preview' || process.env.NODE_ENV === 'production'
49+
? '[name].[chunkhash].js'
50+
: '[name].js'
4751
},
4852

4953
context: path.join(__dirname, 'src'),

0 commit comments

Comments
 (0)