Permalink
Browse files

Changing a view's elementId is not allowed - closes #425

  • Loading branch information...
1 parent d777ea7 commit 286b7b008b7039d116a7bcf6d90ee5e3cfc71d90 @wagenet wagenet committed Feb 24, 2012
Showing with 14 additions and 0 deletions.
  1. +5 −0 packages/ember-views/lib/views/view.js
  2. +9 −0 packages/ember-views/tests/views/view/element_test.js
@@ -720,6 +720,11 @@ Ember.View = Ember.Object.extend(Ember.Evented,
return value !== undefined ? value : Ember.guidFor(this);
}).cacheable(),
+ /** @private */
+ _elementIdDidChange: Ember.observer(function() {
+ throw "Changing a view's elementId after creation is not allowed.";
+ }, 'elementId'),
+
/**
Attempts to discover the element in the parent element. The default
implementation looks for an element with an ID of elementId (or the view's
@@ -68,3 +68,12 @@ test("discovers element if has no element but parent view does have element", fu
equal(child.$().attr('id'), 'child-view', 'view discovered child');
});
+test("should not allow the elementId to be changed", function() {
+ view = Ember.View.create({
+ elementId: 'one'
+ });
+
+ raises(function() {
+ view.set('elementId', 'two');
+ }, /Changing a view's elementId after creation is not allowed./, "raises elementId changed exception");
+});

0 comments on commit 286b7b0

Please sign in to comment.