Skip to content

Instantly share code, notes, and snippets.

@csuwildcat
Created April 14, 2013 01:34
Show Gist options
  • Save csuwildcat/5380969 to your computer and use it in GitHub Desktop.
Save csuwildcat/5380969 to your computer and use it in GitHub Desktop.
/*** Option 1 - no ES6, all using defaults ***/
<element tagname="x-foo">
<script>
// By default, the tag name is used to generate the
// named constructor object - without rebinding 'this'
XFooElement.prototype.bar = ...
</script>
</element>
/*** Option 2 - no ES6, using optional attributes ***/
<element tagname="x-foo" extends="SVGElement" constructor="SuperVG">
<script>
// By choice, the developer can extend from an existing
// tag using extends="", and/or specify a non-default constructor
// name via constructor="" - again, without rebinding 'this'
SuperVG.prototype.bar = ...
</script>
</element>
/*** Option 3 - dev-optional use of ES6 ***/
<element tagname="x-foo" constructor="SuperVG">
<script>
// By choice, the developer can specify a non-default constructor
// name via constructor="", then extend that using ES6.
class SuperVG extends SVGElement {}
</script>
</element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment