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

[DO NOT MERGE] Eliminate deprecation warnings in >= 1.12 #41

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions addon/templates/components/modal-dialog-legacy.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{#ember-wormhole to=destinationElementId renderInPlace=renderInPlace}}
{{#if hasOverlay}}
<div {{bind-attr class="overlayClassNamesString translucentOverlay:translucent overlay-class"}} {{action 'close'}}></div>
{{/if}}
{{#if useEmberTether}}
{{#ember-tether classNameBindings="containerClassNamesString alignmentClass renderInPlaceClass container-class"
target=_alignmentTargetNormalized
attachment=_attachmentNormalized
targetAttachment=_targetAttachmentNormalized
targetModifier=_targetModifierNormalized
}}
{{yield}}
{{/ember-tether}}
{{else}}
{{#ember-modal-dialog-positioned-container classNameBindings="containerClassNamesString alignmentClass renderInPlaceClass container-class"
alignment=_alignmentNormalized
alignmentTarget=alignmentTarget
}}
{{yield}}
{{/ember-modal-dialog-positioned-container}}
{{/if}}
{{/ember-wormhole}}
2 changes: 1 addition & 1 deletion addon/templates/components/modal-dialog.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{#ember-wormhole to=destinationElementId renderInPlace=renderInPlace}}
{{#if hasOverlay}}
<div {{bind-attr class="overlayClassNamesString translucentOverlay:translucent overlay-class"}} {{action 'close'}}></div>
<div class="{{overlayClassNamesString}} {{if translucentOverlay 'translucent'}} {{overlay-class}}" {{action 'close'}}></div>
{{/if}}
{{#if useEmberTether}}
{{#ember-tether classNameBindings="containerClassNamesString alignmentClass renderInPlaceClass container-class"
Expand Down
33 changes: 32 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
/* jshint node: true */
'use strict';
var path = require('path');
var fs = require('fs');
var semver = require('semver');
var stew = require('broccoli-stew');

module.exports = {
name: 'ember-modal-dialog'
name: 'ember-modal-dialog',
treeForAddonTemplates: function treeForAddonTemplates (tree) {
if (useLegacyBindingSyntax(this)) {
tree = stew.rm(tree, 'components/modal-dialog.hbs');
tree = stew.mv(tree, 'components/modal-dialog-legacy.hbs', 'components/modal-dialog.hbs');
} else {
tree = stew.rm(tree, 'components/modal-dialog-legacy.hbs');
}
return tree;
}
};

function useLegacyBindingSyntax(addon){
var emberVersion = getEmberVersion(addon);
if (/canary/.test(emberVersion)) { return false; }
if (/beta/.test(emberVersion)) { return false; }
if (/beta/.test(emberVersion)) { return false; }
return semver.lt(emberVersion, '1.13.0');
}

function getEmberVersion(addon) {
if (!addon.project) {
return null;
}

var bowerPath = path.join(addon.project.root, 'bower.json')
var bowerObj = JSON.parse(fs.readFileSync(bowerPath, 'utf8'));
return bowerObj.dependencies.ember;
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
"glob": "4.4.0"
},
"dependencies": {
"broccoli-stew": "^0.3.1",
"ember-cli-babel": "^5.0.0",
"ember-cli-htmlbars": "^0.7.6",
"ember-wormhole": "^0.3.1"
"ember-wormhole": "^0.3.1",
"semver": "^4.3.6"
},
"keywords": [
"ember-addon"
Expand Down