Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Monster
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Javascript
Monster
Commits
0e23cb22
Verified
Commit
0e23cb22
authored
7 months ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
feat: new iframe feature for replace target
parent
21e832dc
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
development/issues/closed/243-test2.html
+19
-5
19 additions, 5 deletions
development/issues/closed/243-test2.html
source/components/layout/iframe.mjs
+260
-241
260 additions, 241 deletions
source/components/layout/iframe.mjs
with
279 additions
and
246 deletions
development/issues/closed/243-test2.html
+
19
−
5
View file @
0e23cb22
...
...
@@ -18,8 +18,22 @@
main
{
width
:
200px
;
height
:
1200px
;
background-color
:
#
bc05a9
;
background-color
:
#
ede5eb
;
}
</style>
</head><body><main>
TEST 2
</main></body></html>
</head>
<body>
<main>
TEST 2
<ul>
<li><a
href=
"./243-test1.html"
target=
"_blank"
>
Doc 1 (_blank)
</a>
<li><a
href=
"./243-test1.html"
target=
"_self"
>
Doc 1 (_self)
</a>
<li><a
href=
"./243-test1.html"
target=
"_parent"
>
Doc 1 (_parent)
</a>
<li><a
href=
"./243-test1.html"
target=
"_top"
>
Doc 1 (_top)
</a>
<li><a
href=
"./243-test1.html"
target=
"iframe"
>
Doc 1 (iframe)
</a>
</ul>
</main>
</body>
</html>
This diff is collapsed.
Click to expand it.
source/components/layout/iframe.mjs
+
260
−
241
View file @
0e23cb22
...
...
@@ -119,6 +119,12 @@ class Iframe extends CustomElement {
* @property {Object} actions Callbacks
* @property {string} actions.click="throw Error" Callback when clicked
* @property {Object} features Features
* @property {boolean} features.allowFullScreen=true Allow fullscreen
* @property {boolean} features.allowPaymentRequest=true Allow payment request
* @property {boolean} features.replaceTargets=true Replace parent target in iframe
* @property {string} loading="eager" Loading state
* @property {string} referrerPolicy="no-referrer" Referrer policy
* @property {string} src Source
* @property {Object} classes CSS classes
* @property {boolean} disabled=false Disabled state
*/
...
...
@@ -137,14 +143,17 @@ class Iframe extends CustomElement {
name
:
""
,
referrer
p
olicy
:
"
no-referrer
"
,
referrer
P
olicy
:
"
no-referrer
"
,
disabled
:
false
,
features
:
{
allow
f
ull
s
creen
:
true
,
allow
p
ayment
r
equest
:
true
,
loading
:
"
egager
"
,
allow
F
ull
S
creen
:
true
,
allow
P
ayment
R
equest
:
true
,
replaceTargets
:
true
,
},
loading
:
"
eager
"
,
actions
:
{
click
:
()
=>
{
throw
new
Error
(
"
the click action is not defined
"
);
...
...
@@ -309,6 +318,16 @@ function initEventHandler() {
callback
.
call
(
self
,
event
);
});
this
[
iframeElementSymbol
].
addEventListener
(
"
load
"
,
()
=>
{
calcHeight
.
call
(
this
);
if
(
this
.
getOption
(
"
features.replaceParentTarget
"
))
{
var
links
=
this
[
iframeElementSymbol
].
contentDocument
.
querySelectorAll
(
'
a[target="_parent"], form[target="_parent"], a[target="_top"], form[target="_top"]
'
);
links
.
forEach
(
function
(
link
)
{
link
.
target
=
'
_self
'
;
});
}
});
return
this
;
}
...
...
@@ -341,10 +360,10 @@ function getTemplate() {
<iframe data-monster-role="iframe"
data-monster-attributes="sandbox path:sandbox,
name path:name,
referrerpolicy path:referrer
p
olicy,
loading path:
features.
loading,
allowpaymentrequest path:features.allow
p
ayment
r
equest,
allowfullscreen path:features.allow
f
ull
s
creen,
referrerpolicy path:referrer
P
olicy,
loading path:loading,
allowpaymentrequest path:features.allow
P
ayment
R
equest,
allowfullscreen path:features.allow
F
ull
S
creen,
src path:src"
></iframe>
</div>`
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment