From 10ddaff8a462dd3ac00a9f8e48da2ee830fd9093 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Sat, 7 May 2016 19:04:13 +0100 Subject: [PATCH] for loop instead of do while --- src/ShallowWrapper.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ShallowWrapper.js b/src/ShallowWrapper.js index a0010ccff..444b30873 100644 --- a/src/ShallowWrapper.js +++ b/src/ShallowWrapper.js @@ -351,15 +351,15 @@ export default class ShallowWrapper { const eventProp = propFromEvent(event); const e = Object.assign(new SyntheticEvent(undefined, undefined, { type: event }), mock); withSetStateAllowed(() => { - let current = this; - - do { + for (let current = this; current.node !== undefined; current = current.parent()) { const handler = current.prop(eventProp); if (handler) { handler(e, ...args); + if (e.isPropagationStopped()) { + break; + } } - current = current.parent(); - } while (!e.isPropagationStopped() && current.node !== undefined); + } this.root.update(); });