Created
July 31, 2018 17:45
-
-
Save timfish/f69a0638f89b05f0dab44e95fa00b3a7 to your computer and use it in GitHub Desktop.
remove svg wrappers
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
<template> | |
<require from="./svg-rect"></require> | |
<svg width="100" height="100" style="background-color:lightblue"> | |
<svg-rect rect.bind="{x: 5, y: 5, width: 30, height: 20}"></svg-rect> | |
</svg> | |
</template> |
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
import { Container, inject, ViewResources } from 'aurelia-framework' | |
@inject(Container) | |
export class App { | |
constructor(container) { | |
const resources: ViewResources = container.get(ViewResources); | |
resources.registerViewEngineHooks({ | |
beforeCreate: (view, s, f) => { | |
for(var i = 0; i < f.children[0].children.length; i++){ | |
f.appendChild(f.children[0].children[i]) | |
}; | |
} | |
}); | |
} | |
} | |
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
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</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 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> | |
<svg> | |
<rect x.bind="rect.x" y.bind="rect.y" width.bind="rect.width" height.bind="rect.height" style="background-color:red"></rect> | |
</svg> | |
</template> |
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
import {containerless, bindable} from 'aurelia-framework' | |
@containerless | |
export class SvgRect { | |
@bindable rect; | |
constructor(){ | |
} | |
attached(){ | |
} | |
} |
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
import {inject, customAttribute} from 'aurelia-framework'; | |
@customAttribute('svg-remove') | |
@inject(Element) | |
export class SvgRemove { | |
constructor(element){ | |
this.element = element; | |
} | |
attached(){ | |
for(var i = 0; i< this.element.children.length; i++){ | |
this.element.parentNode.appendChild(this.element.children[i]) | |
} | |
this.element.remove(); | |
console.log(this.element.children) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment