-
-
Save justinfagnani/fea819776d77eee5a108a3bcf873e7f4 to your computer and use it in GitHub Desktop.
Untrusted 3rd Party Web Components
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<body> | |
<!-- Define the tag name to use for an isolated/untrusted component --> | |
<define | |
name="facespace-share" | |
isolated | |
constructor="ShareButton" | |
src="facespace.com/modules/share-button.js"> | |
</define> | |
<style> | |
/* This styles a part in the isolated component */ | |
facespace-share::part(site-logo) { | |
background: url(application.com/logo.png); | |
} | |
</style> | |
<article id="1234"> | |
<!-- This is a proxy to a ShareButton instance in an isolated realm --> | |
<facespace-share url="application.com/1234"></facespace-share> | |
</article> | |
<article id="5678"> | |
<facespace-share url="application.com/5678"></facespace-share> | |
</article> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
You could also define an element decalratively in an HTML module | |
--> | |
<define name="my-element"> | |
<template shadowmode="open"> | |
<button> | |
<!-- this part is exposed for styling to the including document --> | |
<div class="site-logo" part="site-logo"></div> | |
Share | |
</button> | |
</template> | |
</define> | |
<!-- | |
^ this requires a <define> + <template> to make an includable chunk | |
of HTML, but we could make short-hands just using <template> | |
--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment