Skip to content

feat: Support iframe rendering#4828

Merged
shaohuzhang1 merged 1 commit intov2from
pr@v2@feat_iframe
Feb 28, 2026
Merged

feat: Support iframe rendering#4828
shaohuzhang1 merged 1 commit intov2from
pr@v2@feat_iframe

Conversation

@shaohuzhang1
Copy link
Contributor

feat: Support iframe rendering

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Feb 28, 2026

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@f2c-ci-robot
Copy link

f2c-ci-robot bot commented Feb 28, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

height: 100%;
border: none;
}
</style>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code template has some potential areas for improvement in terms of security, readability, and performance. Here are my suggestions:

Security Improvements

  1. Content Security Policy (CSP):
    • Ensure that the sandbox attributes include necessary CSP directives like 'content-security-policy': "default-src 'self';" to prevent XSS attacks.
@sandbox="'allow-scripts' 'allow-same-origin'" + (
  !props.script_exec ? '; object-src \'none\'' : ''
)
  1. Frame-Busting Protection:
    • Add basic frame-busting protection by checking against common anti-framebuster methods.
@if (iframes && Array.isArray(iframes)) {
  <script>
    try {
      document.top.location.href = window.self.location.toString();
    } catch (e) {}
  </script>
}
  1. Script Execution Control:
    • If you intend to allow scripts programmatically, ensure they're trusted sources or sanitize them before adding them manually.

Readability and Style Optimization

  1. Inline Styles in CSS:
    • Consider moving the styles inline rather than defining them globally in a separate style block. This can make the component more self-contained.
<style scoped>
.iframe-wrapper {
  width: 100%;
  height: 100%;
}

.iframe {
  width: 100%;
  height: 100%;
  border: none;
}
</style>
  1. Variable Naming Consistency:

    • Use consistent naming conventions. For example, resize, finalSource, iframe, etc., should be clear and descriptive.
  2. Whitespace Reduction:

    • Remove unnecessary spaces around operators and braces to improve legibility.

Performance Improvements

  1. Async/Await Best Practices:
    • Use await without wrapping promises in parentheses when not needed.
async function resize() {
  await nextTick()

  const iframe = iframeRef.value
  if (!iframe) return

  // ...
}
  1. Conditional Rendering Optimization:
    • Avoid unnecessarily re-running watch functions each time props change. Instead, optimize based on prop changes directly.
watch(
  () => props.visible,
  (newVisible) => {
    if (newVisible && iframeRef.value) {
      iframeRef.value.srcdoc = finalSource.value
    }
  },
)

By implementing these improvements, you can enhance the robustness, security, and efficiency of your Vue.js component using Vue Composition API.

Security Note: Always consider the security implications of your implementation when handling external data, especially if it involves executing scripts or allowing arbitrary content loading (<source>).

@shaohuzhang1 shaohuzhang1 merged commit 46105e7 into v2 Feb 28, 2026
3 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@v2@feat_iframe branch February 28, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant