Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow svg symbol to be placed into another location #33

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/examples.md
Expand Up @@ -77,6 +77,21 @@ let app = new EmberApp(defaults, {
});
```

#### [`symbol` strategy] change location of svgJar symbol object into a div IE:ember-testing-container

```javascript
let app = new EmberApp(defaults, {
svgJar: {
strategy: ['symbol'],

symbol: {
loaderLocationEnabled: true,
loaderLocation: 'ember-testing-container',
}
}
});
```

#### Using both `symbol` and `inline` strategies at the same time:

```javascript
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Expand Up @@ -113,7 +113,9 @@ module.exports = {

if (type === 'body' && includeLoader) {
return symbolsLoaderScript
.replace('{{FILE_PATH}}', this.optionFor('symbol', 'outputFile'));
.replace('{{FILE_PATH}}', this.optionFor('symbol', 'outputFile'))
.replace('{{LOADER_LOCATION}}', this.optionFor('symbol', 'loaderLocation'))
.replace('{{LOADER_LOCATION_ENABLED}}', this.optionFor('symbol', 'loaderLocationEnabled'));
}

return '';
Expand Down
3 changes: 3 additions & 0 deletions symbols-loader.html
Expand Up @@ -5,6 +5,9 @@
ajax.onload = function(e) {
var div = document.createElement('div');
div.innerHTML = ajax.responseText;
if ({{LOADER_LOCATION_ENABLED}}) {
return document.getElementById('{{LOADER_LOCATION}}').appendChild(div)
}
document.body.insertBefore(div, document.body.childNodes[0]);

Choose a reason for hiding this comment

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

@kiwiupover It looks like you're duplicating the insertion of the div, rather than changing it's location. I think you just want to make document.body.childNodes[0] on this line dynamic, right? Maybe adding a single config property like loaderLocation and having it default to 'body'?

};
</script>