@@ -4,6 +4,7 @@ import { createStorage, Storage } from './customStorage.js';
4
4
import WombatLocation from './wombatLocation.js' ;
5
5
import AutoFetcher from './autoFetcher.js' ;
6
6
import { wrapEventListener , wrapSameOriginEventListener } from './listeners.js' ;
7
+ import { OBJECT_TO_IFRAME_TYPES , createObjectWrapper } from "./objectwrapper.js" ;
7
8
import {
8
9
addToStringTagToClass ,
9
10
autobind ,
@@ -1637,7 +1638,12 @@ Wombat.prototype.rewriteNodeFuncArgs = function(
1637
1638
if ( newNode ) {
1638
1639
switch ( newNode . nodeType ) {
1639
1640
case Node . ELEMENT_NODE :
1640
- this . rewriteElemComplete ( newNode ) ;
1641
+ if ( this . wb_info . isSW && ! newNode . parentElement &&
1642
+ newNode . tagName === "OBJECT" && newNode . __WB_object_proxy__ ) {
1643
+ newNode = newNode . __WBProxyRealObj__ ;
1644
+ } else {
1645
+ this . rewriteElemComplete ( newNode ) ;
1646
+ }
1641
1647
break ;
1642
1648
case Node . TEXT_NODE :
1643
1649
// newNode is the new child of fnThis (the parent node)
@@ -1993,7 +1999,7 @@ Wombat.prototype.rewriteAttr = function(elem, name, absUrlOnly) {
1993
1999
return changed ;
1994
2000
}
1995
2001
1996
- var value = this . wb_getAttribute . call ( elem , name ) ;
2002
+ var value = this . wb_getAttribute . call ( this . proxyToObj ( elem ) , name ) ;
1997
2003
1998
2004
if ( ! value || this . startsWith ( value , 'javascript:' ) ) return changed ;
1999
2005
@@ -2216,7 +2222,7 @@ Wombat.prototype.rewriteElem = function(elem) {
2216
2222
}
2217
2223
break ;
2218
2224
case 'OBJECT' :
2219
- if ( this . wb_info . isSW && elem . parentElement && elem . getAttribute ( 'type' ) === 'application/pdf' ) {
2225
+ if ( this . wb_info . isSW && elem . parentElement && OBJECT_TO_IFRAME_TYPES . includes ( elem . getAttribute ( 'type' ) ) ) {
2220
2226
var iframe = this . $wbwindow . document . createElement ( 'IFRAME' ) ;
2221
2227
for ( var i = 0 ; i < elem . attributes . length ; i ++ ) {
2222
2228
var attr = elem . attributes [ i ] ;
@@ -4772,6 +4778,26 @@ Wombat.prototype.initCreateElementNSFix = function() {
4772
4778
this . $wbwindow . document . createElementNS = createElementNS ;
4773
4779
} ;
4774
4780
4781
+
4782
+ Wombat . prototype . initCreateElement = function ( ) {
4783
+ var orig_createElement = this . $wbwindow . document . createElement ;
4784
+ var wombat = this ;
4785
+
4786
+ var createElement = function createElement ( tagName , opts ) {
4787
+ var result = orig_createElement . call (
4788
+ wombat . proxyToObj ( this ) , tagName , opts
4789
+ ) ;
4790
+ if ( tagName === "object" ) {
4791
+ return createObjectWrapper ( result ) ;
4792
+ }
4793
+
4794
+ return result ;
4795
+ } ;
4796
+
4797
+ this . $wbwindow . Document . prototype . createElement = createElement ;
4798
+ this . $wbwindow . document . createElement = createElement ;
4799
+ }
4800
+
4775
4801
/**
4776
4802
* Applies an override to Element.insertAdjacentHTML in order to ensure
4777
4803
* that the strings of HTML to be inserted are rewritten and to
@@ -6710,6 +6736,8 @@ Wombat.prototype.wombatInit = function() {
6710
6736
// ensure namespace urls are NOT rewritten
6711
6737
this . initCreateElementNSFix ( ) ;
6712
6738
6739
+ this . initCreateElement ( ) ;
6740
+
6713
6741
// DOM
6714
6742
// OPT skip
6715
6743
if ( ! this . wb_opts . skip_dom ) {
0 commit comments