Skip to content

Commit a9315e8

Browse files
Copilotdaohoangson
andcommitted
Fix iframe src/data-src priority: src now takes priority over data-src
Co-authored-by: daohoangson <[email protected]>
1 parent d0208b4 commit a9315e8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/fwfh_webview/lib/src/web_view_factory.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ mixin WebViewFactory on WidgetFactory {
135135
final dataSrc = a[kAttributeIframeDataSrc];
136136
final srcAttr = a[kAttributeIframeSrc];
137137
final src = urlFull(
138-
(dataSrc?.isNotEmpty == true) ? dataSrc! : (srcAttr ?? '')
138+
(srcAttr?.isNotEmpty == true) ? srcAttr! : (dataSrc ?? '')
139139
);
140140
if (src == null) {
141141
return widgets;

packages/fwfh_webview/test/web_view_factory_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -332,22 +332,22 @@ void main() {
332332
);
333333
});
334334

335-
testWidgets('data-src takes priority over src', (tester) async {
335+
testWidgets('src takes priority over data-src', (tester) async {
336336
const dataSrcUrl = 'http://data-src.com';
337337
const html = '<iframe data-src="$dataSrcUrl" src="$src"></iframe>';
338338
final explained = await explain(tester, html);
339339
expect(
340340
explained,
341341
equals(
342342
'[CssSizing:$sizingConstraints,child='
343-
'[WebView:url=$dataSrcUrl,aspectRatio=$defaultAspectRatio,js=true,gestureRecognizers={}]'
343+
'[WebView:url=$src,aspectRatio=$defaultAspectRatio,js=true,gestureRecognizers={}]'
344344
']',
345345
),
346346
);
347347
});
348348

349-
testWidgets('falls back to src when data-src is empty', (tester) async {
350-
const html = '<iframe data-src="" src="$src"></iframe>';
349+
testWidgets('falls back to data-src when src is empty', (tester) async {
350+
const html = '<iframe data-src="$src" src=""></iframe>';
351351
final explained = await explain(tester, html);
352352
expect(
353353
explained,
@@ -359,7 +359,7 @@ void main() {
359359
);
360360
});
361361

362-
testWidgets('falls back to src when data-src is missing', (tester) async {
362+
testWidgets('uses src when data-src is missing', (tester) async {
363363
const html = '<iframe src="$src"></iframe>';
364364
final explained = await explain(tester, html);
365365
expect(

0 commit comments

Comments
 (0)