Last active
October 28, 2016 16:56
-
-
Save fabioluz/97d086162f5e686de5c5e3d5b49affe0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<template> | |
<require from="./inline-svg"></require> | |
<div> | |
<inline-svg class="${style}"></inline-svg> | |
<div></div> | |
</div> | |
</template> |
This file contains hidden or 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
export class App { | |
style = "worked"; | |
} | |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"> | |
<link rel="stylesheet" href="https://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/css/bootstrap-datepicker3.min.css"> | |
</head> | |
<body aurelia-app> | |
<h1>Loading...</h1> | |
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script> | |
<script> | |
require(['aurelia-bootstrapper']); | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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
import {bindable, containerless, customElement, | |
inject, inlineView, Loader} from 'aurelia-framework'; | |
@containerless() | |
@inlineView('<template></template>') | |
@customElement('inline-svg') | |
@inject(Element, Loader) | |
export class InlineSvg { | |
@bindable svg; | |
constructor(el, loader) { | |
this.el = el; | |
this.loader = loader; | |
} | |
bind() { | |
debugger; | |
let nextSibling = this.el.nextElementSibling; | |
let containerDiv = document.createElement("div"); | |
containerDiv.innerHTML = '<a>111</a>'; | |
let svgElem = containerDiv.children[0]; | |
svgElem.setAttribute('class', this.el.class); | |
if(nextSibling && nextSibling.tagName.toLowerCase() == 'svg'){ | |
curSvgElem.parentElement.replaceChild(svgElem, nextSibling); | |
} else { | |
this.el.parentElement.insertBefore(svgElem, this.el.nextSibling); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment