-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproperty-breakpoints.html
85 lines (72 loc) · 2.17 KB
/
property-breakpoints.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!doctype html>
<html lang="en" data-theme="dark">
<head>
<meta charset="utf-8">
<title>Property breakpoints</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="icon.png">
<link rel="stylesheet" href="css/pico.css">
<link rel="stylesheet" href="css/main.css">
</head>
<body>
<main class="container">
<section>
<h1>Property breakpoints</h1>
<p>
Allows you to pause on property get or set.
<br>
As a part of a DevTools property breakpoints are present in Firefox.
</p>
<article id="content">
</article>
<template id="article-template">
<h2>Under the hood</h2>
<p>In Firefox property breakpoints are based on property descriptors</p>
<img src="img/ff-descriptors.png" alt="Property descriptors in Firefox" style="max-height: 250px;">
<h2>DIY property breakpoints</h2>
<p>Nothing stops you from doing it yourself</p>
<code style="width: 100%">
<b>var</b> obj = { prop: <i>10</i> };
<br>
<br>
<s>Object</s>.<u>defineProperty</u>(obj, <i>'prop'</i>, {
<br>
  <u>get</u>() { <b>debugger</b>; },
<br>
  <u>set</u>(v) { <b>debugger</b>; },
<br>
});
<br>
<br>
<s>obj</s>.prop = <i>20</i>; <em>// debugger will stop here</em>
</code>
</template>
<template id="error-template">
<h2>Error happened here</h2>
<p>Maybe try to reload the page?</p>
<p>Or restart browser?</p>
<p>Our code is fine the problem should be on your side.</p>
</template>
<script>
window.templates = {
templateArticle: document.getElementById('article-template').content,
templateError: document.getElementById('error-template').content,
};
</script>
<div class="grid">
<a href="other-breakpoints.html">
<button class="secondary">Back</button>
</a>
<div></div>
<a href="overrides.html">
<button>Next</button>
</a>
</div>
</section>
</main>
<footer class="container">
WebCore 2021
</footer>
<script id="overrides-script" src="js/overrides.js"></script>
</body>
</html>