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

Rename LinkView to LinkComponent and deprecate the former #11394

Merged
merged 3 commits into from
Jun 10, 2015
Merged
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: 11 additions & 11 deletions packages/ember-routing-htmlbars/lib/keywords/link-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ import merge from "ember-metal/merge";

any passed value to `disabled` will disable it except `undefined`.
to ensure that only `true` disable the `link-to` helper you can
override the global behaviour of `Ember.LinkView`.
override the global behaviour of `Ember.LinkComponent`.

```javascript
Ember.LinkView.reopen({
Ember.LinkComponent.reopen({
disabled: Ember.computed(function(key, value) {
if (value !== undefined) {
this.set('_isDisabled', value === true);
Expand Down Expand Up @@ -235,7 +235,7 @@ import merge from "ember-metal/merge";
```

### Overriding attributes
You can override any given property of the Ember.LinkView
You can override any given property of the Ember.LinkComponent
that is generated by the `{{link-to}}` helper by passing
key/value pairs, like so:

Expand All @@ -245,18 +245,18 @@ import merge from "ember-metal/merge";
{{/link-to}}
```

See [Ember.LinkView](/api/classes/Ember.LinkView.html) for a
See [Ember.LinkComponent](/api/classes/Ember.LinkComponent.html) for a
complete list of overrideable properties. Be sure to also
check out inherited properties of `LinkView`.
check out inherited properties of `LinkComponent`.

### Overriding Application-wide Defaults
``{{link-to}}`` creates an instance of Ember.LinkView
``{{link-to}}`` creates an instance of Ember.LinkComponent
for rendering. To override options for your entire
application, reopen Ember.LinkView and supply the
application, reopen Ember.LinkComponent and supply the
desired values:

``` javascript
Ember.LinkView.reopen({
Ember.LinkComponent.reopen({
activeClass: "is-active",
tagName: 'li'
})
Expand All @@ -266,7 +266,7 @@ import merge from "ember-metal/merge";
this manner:

``` javascript
Ember.LinkView.reopen({
Ember.LinkComponent.reopen({
eventName: 'customEventName'
});
```
Expand All @@ -275,9 +275,9 @@ import merge from "ember-metal/merge";
@for Ember.Handlebars.helpers
@param {String} routeName
@param {Object} [context]*
@param [options] {Object} Handlebars key/value pairs of options, you can override any property of Ember.LinkView
@param [options] {Object} Handlebars key/value pairs of options, you can override any property of Ember.LinkComponent
@return {String} HTML string
@see {Ember.LinkView}
@see {Ember.LinkComponent}
@public
*/
export default {
Expand Down
8 changes: 4 additions & 4 deletions packages/ember-routing-htmlbars/tests/helpers/link-to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { Registry } from "ember-runtime/system/container";
import { runAppend, runDestroy } from "ember-runtime/tests/utils";
import EmberObject from "ember-runtime/system/object";
import ComponentLookup from "ember-views/component_lookup";
import LinkView from "ember-routing-views/views/link";
import LinkComponent from "ember-routing-views/views/link";

var view;
var container;
var registry = new Registry();

// These tests don't rely on the routing service, but LinkView makes
// These tests don't rely on the routing service, but LinkComponent makes
// some assumptions that it will exist. This small stub service ensures
// that the LinkView can render without raising an exception.
// that the LinkComponent can render without raising an exception.
//
// TODO: Add tests that test actual behavior. Currently, all behavior
// is tested integration-style in the `ember` package.
Expand All @@ -28,7 +28,7 @@ registry.register('service:-routing', EmberObject.extend({
}));

registry.register('component-lookup:main', ComponentLookup);
registry.register('component:-link-to', LinkView);
registry.register('component:-link-to', LinkComponent);

QUnit.module("ember-routing-htmlbars: link-to helper", {
setup() {
Expand Down
5 changes: 3 additions & 2 deletions packages/ember-routing-views/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

import Ember from "ember-metal/core";
import isEnabled from "ember-metal/features";
import LinkView from "ember-routing-views/views/link";
import LinkComponent, { DeprecatedLinkView } from "ember-routing-views/views/link";
import {
OutletView,
CoreOutletView
} from "ember-routing-views/views/outlet";

Ember.LinkView = LinkView;
Ember.LinkView = DeprecatedLinkView;
Ember.LinkComponent = LinkComponent;
Ember.OutletView = OutletView;
if (isEnabled('ember-routing-core-outlet')) {
Ember.CoreOutletView = CoreOutletView;
Expand Down
70 changes: 43 additions & 27 deletions packages/ember-routing-views/lib/views/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ import ControllerMixin from "ember-runtime/mixins/controller";
import linkToTemplate from "ember-htmlbars/templates/link-to";
linkToTemplate.meta.revision = 'Ember@VERSION_STRING_PLACEHOLDER';

var linkViewClassNameBindings = ['active', 'loading', 'disabled'];
var linkComponentClassNameBindings = ['active', 'loading', 'disabled'];
if (isEnabled('ember-routing-transitioning-classes')) {
linkViewClassNameBindings = ['active', 'loading', 'disabled', 'transitioningIn', 'transitioningOut'];
linkComponentClassNameBindings = ['active', 'loading', 'disabled', 'transitioningIn', 'transitioningOut'];
}

/**
`Ember.LinkView` renders an element whose `click` event triggers a
`Ember.LinkComponent` renders an element whose `click` event triggers a
transition of the application's instance of `Ember.Router` to
a supplied route by name.

Instances of `LinkView` will most likely be created through
Instances of `LinkComponent` will most likely be created through
the `link-to` Handlebars helper, but properties of this class
can be overridden to customize application-wide behavior.

@class LinkView
@class LinkComponent
@namespace Ember
@extends Ember.View
@extends Ember.Component
@see {Handlebars.helpers.link-to}
@private
**/
Expand All @@ -50,15 +50,15 @@ var LinkComponent = EmberComponent.extend({
currentWhen: null,

/**
Used to determine when this LinkView is active.
Used to determine when this LinkComponent is active.

@property currentWhen
@private
*/
'current-when': null,

/**
Sets the `title` attribute of the `LinkView`'s HTML element.
Sets the `title` attribute of the `LinkComponent`'s HTML element.

@property title
@default null
Expand All @@ -67,7 +67,7 @@ var LinkComponent = EmberComponent.extend({
title: null,

/**
Sets the `rel` attribute of the `LinkView`'s HTML element.
Sets the `rel` attribute of the `LinkComponent`'s HTML element.

@property rel
@default null
Expand All @@ -76,7 +76,7 @@ var LinkComponent = EmberComponent.extend({
rel: null,

/**
Sets the `tabindex` attribute of the `LinkView`'s HTML element.
Sets the `tabindex` attribute of the `LinkComponent`'s HTML element.

@property tabindex
@default null
Expand All @@ -85,7 +85,7 @@ var LinkComponent = EmberComponent.extend({
tabindex: null,

/**
Sets the `target` attribute of the `LinkView`'s HTML element.
Sets the `target` attribute of the `LinkComponent`'s HTML element.

@since 1.8.0
@property target
Expand All @@ -95,7 +95,7 @@ var LinkComponent = EmberComponent.extend({
target: null,

/**
The CSS class to apply to `LinkView`'s element when its `active`
The CSS class to apply to `LinkComponent`'s element when its `active`
property is `true`.

@property activeClass
Expand All @@ -106,7 +106,7 @@ var LinkComponent = EmberComponent.extend({
activeClass: 'active',

/**
The CSS class to apply to `LinkView`'s element when its `loading`
The CSS class to apply to `LinkComponent`'s element when its `loading`
property is `true`.

@property loadingClass
Expand All @@ -117,7 +117,7 @@ var LinkComponent = EmberComponent.extend({
loadingClass: 'loading',

/**
The CSS class to apply to a `LinkView`'s element when its `disabled`
The CSS class to apply to a `LinkComponent`'s element when its `disabled`
property is `true`.

@property disabledClass
Expand All @@ -129,7 +129,7 @@ var LinkComponent = EmberComponent.extend({
_isDisabled: false,

/**
Determines whether the `LinkView` will trigger routing via
Determines whether the `LinkComponent` will trigger routing via
the `replaceWith` routing strategy.

@property replace
Expand Down Expand Up @@ -160,7 +160,7 @@ var LinkComponent = EmberComponent.extend({
@default ['active', 'loading', 'disabled']
@private
*/
classNameBindings: linkViewClassNameBindings,
classNameBindings: linkComponentClassNameBindings,

/**
By default the `{{link-to}}` helper responds to the `click` event. You
Expand All @@ -181,7 +181,7 @@ var LinkComponent = EmberComponent.extend({
// section of the API documentation, which is where
// people will likely go looking for it.
/**
Triggers the `LinkView`'s routing behavior. If
Triggers the `LinkComponent`'s routing behavior. If
`eventName` is changed to a value other than `click`
the routing behavior will trigger on that custom event
instead.
Expand All @@ -191,12 +191,12 @@ var LinkComponent = EmberComponent.extend({
*/

/**
An overridable method called when LinkView objects are instantiated.
An overridable method called when LinkComponent objects are instantiated.

Example:

```javascript
App.MyLinkView = Ember.LinkView.extend({
App.MyLinkComponent = Ember.LinkComponent.extend({
init: function() {
this._super.apply(this, arguments);
Ember.Logger.log('Event is ' + this.get('eventName'));
Expand Down Expand Up @@ -226,7 +226,7 @@ var LinkComponent = EmberComponent.extend({
_routing: inject.service('-routing'),

/**
Accessed as a classname binding to apply the `LinkView`'s `disabledClass`
Accessed as a classname binding to apply the `LinkComponent`'s `disabledClass`
CSS `class` to the element when the link is disabled.

When `true` interactions with the element will not trigger route changes.
Expand All @@ -245,11 +245,11 @@ var LinkComponent = EmberComponent.extend({
}),

/**
Accessed as a classname binding to apply the `LinkView`'s `activeClass`
Accessed as a classname binding to apply the `LinkComponent`'s `activeClass`
CSS `class` to the element when the link is active.

A `LinkView` is considered active when its `currentWhen` property is `true`
or the application's current route is the route the `LinkView` would trigger
A `LinkComponent` is considered active when its `currentWhen` property is `true`
or the application's current route is the route the `LinkComponent` would trigger
transitions into.

The `currentWhen` property can match against multiple routes by separating
Expand All @@ -258,7 +258,7 @@ var LinkComponent = EmberComponent.extend({
@property active
@private
*/
active: computed('attrs.params', '_routing.currentState', function computeLinkViewActive() {
active: computed('attrs.params', '_routing.currentState', function computeLinkComponentActive() {
var currentState = get(this, '_routing.currentState');
return computeActive(this, currentState);
}),
Expand Down Expand Up @@ -330,15 +330,15 @@ var LinkComponent = EmberComponent.extend({

/**
Sets the element's `href` attribute to the url for
the `LinkView`'s targeted route.
the `LinkComponent`'s targeted route.

If the `LinkView`'s `tagName` is changed to a value other
If the `LinkComponent`'s `tagName` is changed to a value other
than `a`, this property will be ignored.

@property href
@private
*/
href: computed('models', 'targetRouteName', '_routing.currentState', function computeLinkViewHref() {
href: computed('models', 'targetRouteName', '_routing.currentState', function computeLinkComponentHref() {

if (get(this, 'tagName') !== 'a') { return; }

Expand Down Expand Up @@ -504,4 +504,20 @@ function getResolvedQueryParams(queryParamsObject, targetRouteName) {
return resolvedQueryParams;
}

/* DeprecatedLinkView - Start: TODO: Delete in Ember 2.0 */
var DeprecatedLinkView = LinkComponent.extend({
init() {
Ember.deprecate('Ember.LinkView is deprecated. Please use Ember.LinkComponent.', false);
this._super.apply(this, arguments);
}
});
var originalReopen = DeprecatedLinkView.reopen;

DeprecatedLinkView.reopen = function reopenWithDeprecation() {
Ember.deprecate('Ember.LinkView is deprecated. Please use Ember.LinkComponent.', false);
originalReopen.apply(this, arguments);
};
export { DeprecatedLinkView };
/* DeprecatedLinkView - End*/

export default LinkComponent;
12 changes: 11 additions & 1 deletion packages/ember-routing-views/tests/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import Ember from 'ember-routing-views';
QUnit.module("ember-routing-views");

QUnit.test("exports correctly", function() {
ok(Ember.LinkView, "LinkView is exported correctly");
ok(Ember.LinkComponent, "LinkComponent is exported correctly");
ok(Ember.OutletView, "OutletView is exported correctly");
});

QUnit.test("Ember.LinkView throws a deprecation warning when instantiated", function() {
expectDeprecation(/Ember.LinkView is deprecated. Please use Ember.LinkComponent/);
Ember.LinkView.create();
});

QUnit.test("Ember.LinkView throws a deprecation warning when reopened", function() {
expectDeprecation(/Ember.LinkView is deprecated. Please use Ember.LinkComponent/);
Ember.LinkView.reopen({});
});
2 changes: 1 addition & 1 deletion packages/ember-routing/lib/services/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import keys from "ember-metal/keys";
import merge from "ember-metal/merge";

/**
The Routing service is used by LinkView, and provides facilities for
The Routing service is used by LinkComponent, and provides facilities for
the component/view layer to interact with the router.

While still private, this service can eventually be opened up, and provides
Expand Down
4 changes: 2 additions & 2 deletions packages/ember/tests/helpers/link_to_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,10 +754,10 @@ QUnit.test("link-to with null/undefined dynamic parameters are put in a loading
function assertLinkStatus($link, url) {
if (url) {
equal(normalizeUrl($link.attr('href')), url, "loaded link-to has expected href");
ok(!$link.hasClass('i-am-loading'), "loaded linkView has no loadingClass");
ok(!$link.hasClass('i-am-loading'), "loaded linkComponent has no loadingClass");
} else {
equal(normalizeUrl($link.attr('href')), '#', "unloaded link-to has href='#'");
ok($link.hasClass('i-am-loading'), "loading linkView has loadingClass");
ok($link.hasClass('i-am-loading'), "loading linkComponent has loadingClass");
}
}

Expand Down