Skip to content

Commit 52cd9fc

Browse files
Update article.md
1 parent 6a6e6d9 commit 52cd9fc

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

2-ui/4-forms-controls/2-focus-blur/article.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,32 +167,33 @@
167167
<!-- را اضافه کنید class -- روی فرم focus در مورد -->
168168
169169
<form *!*onfocus="this.className='focused'"*/!*>
170-
<input type="text" name="name" value="Name">
171-
<input type="text" name="surname" value="Surname">
170+
<input type="text" name="name" value="نام">
171+
<input type="text" name="surname" value="نام خانوادگی">
172172
</form>
173173
174174
<style> .focused { outline: 1px solid red; } </style>
175175
```
176176

177-
The example above doesn't work, because when user focuses on an `<input>`, the `focus` event triggers on that input only. It doesn't bubble up. So `form.onfocus` never triggers.
177+
مثال بالا کار نمی‌کند زیرا وقتی کاربر روی یک `<input>` فوکوس می‌کند، `focus` event فقط روی آن input فعال می‌شود. رفتار بالا رفتن حبابی ندارد. پس `form.onfocus` هیچوقت فعال نمی‌شود.
178+
179+
دو راه حل وجود دارد.
178180

179-
There are two solutions.
181+
ابندا یک ویژگی قدیمی خنده‌دار وجود دارد: `focus/blur` بالا رفتن حبابی ندارند، بلکه در مرحله‌ی capturing به پایین منتشر می‌شوند.
180182

181-
First, there's a funny historical feature: `focus/blur` do not bubble up, but propagate down on the capturing phase.
182183

183-
This will work:
184+
این کار می‌کند:
184185

185186
```html autorun height=80
186187
<form id="form">
187-
<input type="text" name="name" value="Name">
188-
<input type="text" name="surname" value="Surname">
188+
<input type="text" name="name" value="نام">
189+
<input type="text" name="surname" value="نام خانوادگی">
189190
</form>
190191

191192
<style> .focused { outline: 1px solid red; } </style>
192193

193194
<script>
194195
*!*
195-
// put the handler on capturing phase (last argument true)
196+
//قرار دهید (آخرین آرگومان درست) capturing کنترلگر را روی فاز
196197
form.addEventListener("focus", () => form.classList.add('focused'), true);
197198
form.addEventListener("blur", () => form.classList.remove('focused'), true);
198199
*/!*

0 commit comments

Comments
 (0)