• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

frontend-collective / react-image-lightbox / 3935384978

pending completion
3935384978

Pull #701

github

GitHub
Merge 2f12cc353 into f16424690
Pull Request #701: build(deps-dev): bump eslint-plugin-import from 2.23.4 to 2.27.5

141 of 318 branches covered (44.34%)

Branch coverage included in aggregate %.

257 of 556 relevant lines covered (46.22%)

8.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/util.js
1
/**
2
 * Placeholder for future translate functionality
3
 */
4
export function translate(str, replaceStrings = null) {
31✔
5
  if (!str) {
31✔
6
    return '';
1✔
7
  }
8

9
  let translated = str;
30✔
10
  if (replaceStrings) {
30!
11
    Object.keys(replaceStrings).forEach(placeholder => {
×
12
      translated = translated.replace(placeholder, replaceStrings[placeholder]);
×
13
    });
14
  }
15

16
  return translated;
30✔
17
}
18

19
export function getWindowWidth() {
20
  return typeof global.window !== 'undefined' ? global.window.innerWidth : 0;
70!
21
}
22

23
export function getWindowHeight() {
24
  return typeof global.window !== 'undefined' ? global.window.innerHeight : 0;
11!
25
}
26

27
const isCrossOriginFrame = () => {
1✔
28
  try {
1✔
29
    return (
1✔
30
      global.window.location.hostname !== global.window.parent.location.hostname
31
    );
32
  } catch (e) {
33
    return true;
×
34
  }
35
};
36

37
// Get the highest window context that isn't cross-origin
38
// (When in an iframe)
39
export function getHighestSafeWindowContext(self = global.window.self) {
7✔
40
  // If we reached the top level, return self
41
  if (self === global.window.top) {
8✔
42
    return self;
7✔
43
  }
44

45
  // If parent is the same origin, we can move up one context
46
  // Reference: https://stackoverflow.com/a/21965342/1601953
47
  if (!isCrossOriginFrame()) {
1!
48
    return getHighestSafeWindowContext(self.parent);
1✔
49
  }
50

51
  // If a different origin, we consider the current level
52
  // as the top reachable one
53
  return self;
×
54
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc