language stringclasses 1
value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2
classes |
|---|---|---|---|---|---|---|---|
Other | emberjs | ember.js | dd1851eea9fc6979570ba761cd1931c3a1ee7e57.json | Add support for #each foo in bar
This implementation takes on some new technical
debt, mostly caused by existing technical debt.
Because this is a very bad thing, we plan to work
on refactoring and paying down as much of the
templateData technical debt as possible tomorrow. | packages/ember-handlebars/tests/helpers/each_test.js | @@ -148,3 +148,29 @@ test("it works with the controller keyword", function() {
equal(view.$().text(), "foobarbaz");
});
+
+module("{{#each foo in bar}}");
+
+test("#each accepts a name binding and does not change the context", function() {
+ view = Ember.View.create({
+ template: templateFor("{{#each item in items}}{{title}} {{debugger}}{{item}}{{/each}}"),
+ title: "My Cool Each Test",
+ items: Ember.A([1, 2])
+ });
+
+ append(view);
+
+ equal(view.$().text(), "My Cool Each Test 1My Cool Each Test 2");
+});
+
+test("#each accepts a name binding and can display child properties", function() {
+ view = Ember.View.create({
+ template: templateFor("{{#each item in items}}{{title}} {{item.name}}{{/each}}"),
+ title: "My Cool Each Test",
+ items: Ember.A([{ name: 1 }, { name: 2 }])
+ });
+
+ append(view);
+
+ equal(view.$().text(), "My Cool Each Test 1My Cool Each Test 2");
+}); | true |
Other | emberjs | ember.js | dd1851eea9fc6979570ba761cd1931c3a1ee7e57.json | Add support for #each foo in bar
This implementation takes on some new technical
debt, mostly caused by existing technical debt.
Because this is a very bad thing, we plan to work
on refactoring and paying down as much of the
templateData technical debt as possible tomorrow. | packages/ember-handlebars/tests/views/collection_view_test.js | @@ -96,41 +96,6 @@ test("empty views should be removed when content is added to the collection (reg
Ember.run(function(){ window.App.destroy(); });
});
-test("collection helper should accept emptyViewClass attribute", function() {
- window.App = Ember.Application.create();
-
- App.EmptyView = Ember.View.extend({
- classNames: ['empty']
- });
-
- App.ListController = Ember.ArrayProxy.create({
- content : Ember.A()
- });
-
- view = Ember.View.create({
- template: Ember.Handlebars.compile('{{#collection emptyViewClass="App.EmptyView" contentBinding="App.ListController" tagName="table"}} <td>{{content.title}}</td> {{/collection}}')
- });
-
- Ember.run(function() {
- view.appendTo('#qunit-fixture');
- });
-
- equal(view.$('tr').length, 0, 'emptyViewClass has no effect without inverse');
- view.remove();
-
- view = Ember.View.create({
- template: Ember.Handlebars.compile('{{#collection emptyViewClass="App.EmptyView" contentBinding="App.ListController" tagName="table"}} <td>{{content.title}}</td> {{else}} <td>No Rows Yet</td> {{/collection}}')
- });
-
- Ember.run(function() {
- view.appendTo('#qunit-fixture');
- });
-
- equal(view.$('tr').hasClass('empty'), 1, 'if emptyViewClass is given it is used for inverse');
-
- Ember.run(function(){ window.App.destroy(); });
-});
-
test("if no content is passed, and no 'else' is specified, nothing is rendered", function() {
TemplateTests.CollectionTestView = Ember.CollectionView.extend({
tagName: 'ul', | true |
Other | emberjs | ember.js | dd1851eea9fc6979570ba761cd1931c3a1ee7e57.json | Add support for #each foo in bar
This implementation takes on some new technical
debt, mostly caused by existing technical debt.
Because this is a very bad thing, we plan to work
on refactoring and paying down as much of the
templateData technical debt as possible tomorrow. | packages/ember-views/lib/views/collection_view.js | @@ -134,6 +134,15 @@ Ember.CollectionView = Ember.ContainerView.extend(
*/
content: null,
+ /**
+ @private
+
+ This provides metadata about what kind of empty view class this
+ collection would like if it is being instantiated from another
+ system (like Handlebars)
+ */
+ emptyViewClass: Ember.View,
+
/**
An optional view to display if content is set to an empty array.
| true |
Other | emberjs | ember.js | dd1851eea9fc6979570ba761cd1931c3a1ee7e57.json | Add support for #each foo in bar
This implementation takes on some new technical
debt, mostly caused by existing technical debt.
Because this is a very bad thing, we plan to work
on refactoring and paying down as much of the
templateData technical debt as possible tomorrow. | packages/ember-views/lib/views/container_view.js | @@ -321,7 +321,10 @@ Ember.ContainerView = Ember.View.extend({
initializeViews: function(views, parentView, templateData) {
forEach(views, function(view) {
set(view, '_parentView', parentView);
- set(view, 'templateData', templateData);
+
+ if (!get(view, 'templateData')) {
+ set(view, 'templateData', templateData);
+ }
});
},
| true |
Other | emberjs | ember.js | dd1851eea9fc6979570ba761cd1931c3a1ee7e57.json | Add support for #each foo in bar
This implementation takes on some new technical
debt, mostly caused by existing technical debt.
Because this is a very bad thing, we plan to work
on refactoring and paying down as much of the
templateData technical debt as possible tomorrow. | packages/ember-views/lib/views/view.js | @@ -721,6 +721,23 @@ Ember.View = Ember.Object.extend(Ember.Evented,
});
}, '_parentView'),
+ cloneKeywords: function() {
+ var templateData = get(this, 'templateData'),
+ controller = get(this, 'controller');
+
+ var keywords = templateData ? Ember.copy(templateData.keywords) : {};
+ keywords.view = get(this, 'concreteView');
+
+ // If the view has a controller specified, make it available to the
+ // template. If not, pass along the parent template's controller,
+ // if it exists.
+ if (controller) {
+ keywords.controller = controller;
+ }
+
+ return keywords;
+ },
+
/**
Called on your view when it should push strings of HTML into a
Ember.RenderBuffer. Most users will want to override the `template`
@@ -739,19 +756,8 @@ Ember.View = Ember.Object.extend(Ember.Evented,
var template = get(this, 'layout') || get(this, 'template');
if (template) {
- var context = get(this, '_templateContext'),
- templateData = this.get('templateData'),
- controller = this.get('controller');
-
- var keywords = templateData ? Ember.copy(templateData.keywords) : {};
- keywords.view = get(this, 'concreteView');
-
- // If the view has a controller specified, make it available to the
- // template. If not, pass along the parent template's controller,
- // if it exists.
- if (controller) {
- keywords.controller = controller;
- }
+ var context = get(this, '_templateContext');
+ var keywords = this.cloneKeywords();
var data = {
view: this,
@@ -1740,10 +1746,11 @@ Ember.View = Ember.Object.extend(Ember.Evented,
@test in createChildViews
*/
createChildView: function(view, attrs) {
- var coreAttrs;
+ var coreAttrs, templateData;
if (Ember.View.detect(view)) {
- coreAttrs = { _parentView: this };
+ coreAttrs = { _parentView: this, templateData: get(this, 'templateData') };
+
if (attrs) {
view = view.create(coreAttrs, attrs);
} else {
@@ -1756,7 +1763,14 @@ Ember.View = Ember.Object.extend(Ember.Evented,
// consumers of the view API
if (viewName) { set(get(this, 'concreteView'), viewName, view); }
} else {
+ if (attrs) { throw "EWOT"; }
+
Ember.assert('must pass instance of View', view instanceof Ember.View);
+
+ if (!get(view, 'templateData')) {
+ set(view, 'templateData', get(this, 'templateData'));
+ }
+
set(view, '_parentView', this);
}
| true |
Other | emberjs | ember.js | 8bdde5937e0a000da65b2458c272e1fac107c9ec.json | Add webhooks notification | .travis.yml | @@ -6,4 +6,5 @@ before_script:
- "sh -e /etc/init.d/xvfb start"
- "rake clean"
script: "rake test[all]"
-after_script: "rake upload_to_url"
+notifications:
+ webhooks: http://emberjs-uploader.herokuapp.com/upload | true |
Other | emberjs | ember.js | 8bdde5937e0a000da65b2458c272e1fac107c9ec.json | Add webhooks notification | Gemfile | @@ -5,10 +5,10 @@ gem "rake-pipeline-web-filters", :git => "https://github.com/wycats/rake-pipelin
gem "colored"
# Using git to prevent deprecation warnings
gem "uglifier", :git => "https://github.com/lautis/uglifier.git"
-gem "rest-client"
group :development do
gem "rack"
+ gem "rest-client"
gem "github_api"
gem "ember-docs", :git => "https://github.com/emberjs/docs-generator.git"
gem "kicker" | true |
Other | emberjs | ember.js | 955b869dcc12413299dd8903ec63006fc336da31.json | Add gathering of credentials from ENV | .travis.yml | @@ -6,3 +6,4 @@ before_script:
- "sh -e /etc/init.d/xvfb start"
- "rake clean"
script: "rake test[all]"
+after_script: "rake upload_to_url" | true |
Other | emberjs | ember.js | 955b869dcc12413299dd8903ec63006fc336da31.json | Add gathering of credentials from ENV | Gemfile | @@ -5,10 +5,10 @@ gem "rake-pipeline-web-filters", :git => "https://github.com/wycats/rake-pipelin
gem "colored"
# Using git to prevent deprecation warnings
gem "uglifier", :git => "https://github.com/lautis/uglifier.git"
+gem "rest-client"
group :development do
gem "rack"
- gem "rest-client"
gem "github_api"
gem "ember-docs", :git => "https://github.com/emberjs/docs-generator.git"
gem "kicker" | true |
Other | emberjs | ember.js | 955b869dcc12413299dd8903ec63006fc336da31.json | Add gathering of credentials from ENV | Rakefile | @@ -25,10 +25,12 @@ def setup_uploader
# git@github.com:emberjs/ember.js
repoUrl = origin.match(/github\.com[\/:]((.+?)\/(.+?))(\.git)?$/)
- username = repoUrl[2] # username part of origin url
- repo = repoUrl[3] # repository name part of origin url
+ username = ENV['GH_USERNAME'] || repoUrl[2] # username part of origin url
+ repo = ENV['GH_REPO'] || repoUrl[3] # repository name part of origin url
- uploader = GithubUploader.new(login, username, repo)
+ token = ENV['GH_OAUTH_TOKEN']
+
+ uploader = GithubUploader.new(login, username, repo, token)
uploader.authorize
uploader
@@ -77,7 +79,6 @@ task :upload_latest => :dist do
upload_file(uploader, 'ember-latest.js', "Ember.js Master", "dist/ember.js")
end
-
namespace :docs do
def doc_args
"#{Dir.glob("packages/ember-*").join(' ')} -E #{Dir.glob("packages/ember-*/tests").join(' ')} -t docs.emberjs.com" | true |
Other | emberjs | ember.js | 955b869dcc12413299dd8903ec63006fc336da31.json | Add gathering of credentials from ENV | lib/github_uploader.rb | @@ -3,12 +3,12 @@
class GithubUploader
- def initialize(login, username, repo, root=Dir.pwd)
+ def initialize(login, username, repo, token, root=Dir.pwd)
@login = login
@username = username
@repo = repo
@root = root
- @token = check_token
+ @token = token || check_token
end
def authorized? | true |
Other | emberjs | ember.js | 00b8940af1c948dd1974be184e022269a87a461d.json | Add currentView property to Ember.ContainerView | packages/ember-views/lib/views/container_view.js | @@ -175,13 +175,34 @@ var childViewsProperty = Ember.computed(function() {
And the `Ember.View` instance stored in `aContainer.aView` will be removed from `aContainer`'s
`childViews` array.
-
## Templates and Layout
A `template`, `templateName`, `defaultTemplate`, `layout`, `layoutName` or `defaultLayout`
property on a container view will not result in the template or layout being rendered.
The HTML contents of a `Ember.ContainerView`'s DOM representation will only be the rendered HTML
of its child views.
+ ## Binding a View to Display
+
+ If you would like to display a single view in your ContainerView, you can set its `currentView`
+ property. When the `currentView` property is set to a view instance, it will be added to the
+ ContainerView's `childViews` array. If the `currentView` property is later changed to a
+ different view, the new view will replace the old view. If `currentView` is set to `null`, the
+ last `currentView` will be removed.
+
+ This functionality is useful for cases where you want to bind the display of a ContainerView to
+ a controller or state manager. For example, you can bind the `currentView` of a container to
+ a controller like this:
+
+ // Controller
+ App.appController = Ember.Object.create({
+ view: Ember.View.create({
+ templateName: 'person_template'
+ })
+ });
+
+ // Handlebars template
+ {{view Ember.ContainerView currentViewBinding="App.appController.view"}}
+
@extends Ember.View
*/
@@ -319,7 +340,27 @@ Ember.ContainerView = Ember.View.extend({
} else {
this.domManager.prepend(this, view);
}
- }
+ },
+
+ currentView: null,
+
+ _currentViewWillChange: Ember.beforeObserver(function() {
+ var childViews = get(this, 'childViews'),
+ currentView = get(this, 'currentView');
+
+ if (currentView) {
+ childViews.removeObject(currentView);
+ }
+ }, 'currentView'),
+
+ _currentViewDidChange: Ember.observer(function() {
+ var childViews = get(this, 'childViews'),
+ currentView = get(this, 'currentView');
+
+ if (currentView) {
+ childViews.pushObject(currentView);
+ }
+ }, 'currentView')
});
// Ember.ContainerView extends the default view states to provide different | true |
Other | emberjs | ember.js | 00b8940af1c948dd1974be184e022269a87a461d.json | Add currentView property to Ember.ContainerView | packages/ember-views/tests/views/container_view_test.js | @@ -1,11 +1,10 @@
-var get = Ember.get, getPath = Ember.getPath;
+var get = Ember.get, getPath = Ember.getPath, set = Ember.set;
module("ember-views/views/container_view_test");
test("should be able to insert views after the DOM representation is created", function() {
var container = Ember.ContainerView.create({
classNameBindings: ['name'],
-
name: 'foo'
});
@@ -112,3 +111,140 @@ test("views that are removed from a ContainerView should have their child views
});
equal(getPath(view, 'childViews.length'), 0, "child views are cleared when removed from container view");
});
+
+test("if a ContainerView starts with an empy currentView, nothing is displayed", function() {
+ var container = Ember.ContainerView.create();
+
+ Ember.run(function() {
+ container.appendTo('#qunit-fixture');
+ });
+
+ equal(container.$().text(), '', "has a empty contents");
+ equal(getPath(container, 'childViews.length'), 0, "should not have any child views");
+});
+
+test("if a ContainerView starts with a currentView, it is rendered as a child view", function() {
+ var container = Ember.ContainerView.create();
+ var mainView = Ember.View.create({
+ template: function() {
+ return "This is the main view.";
+ }
+ });
+
+ set(container, 'currentView', mainView);
+
+ Ember.run(function() {
+ container.appendTo('#qunit-fixture');
+ });
+
+ equal(container.$().text(), "This is the main view.", "should render its child");
+ equal(getPath(container, 'childViews.length'), 1, "should have one child view");
+ equal(getPath(container, 'childViews').objectAt(0), mainView, "should have the currentView as the only child view");
+});
+
+test("if a ContainerView starts with no currentView and then one is set, the ContainerView is updated", function() {
+ var container = Ember.ContainerView.create();
+ var mainView = Ember.View.create({
+ template: function() {
+ return "This is the main view.";
+ }
+ });
+
+ Ember.run(function() {
+ container.appendTo('#qunit-fixture');
+ });
+
+ equal(container.$().text(), '', "has a empty contents");
+ equal(getPath(container, 'childViews.length'), 0, "should not have any child views");
+
+ Ember.run(function() {
+ set(container, 'currentView', mainView);
+ });
+
+ equal(container.$().text(), "This is the main view.", "should render its child");
+ equal(getPath(container, 'childViews.length'), 1, "should have one child view");
+ equal(getPath(container, 'childViews').objectAt(0), mainView, "should have the currentView as the only child view");
+});
+
+test("if a ContainerView starts with a currentView and then is set to null, the ContainerView is updated", function() {
+ var container = Ember.ContainerView.create();
+ var mainView = Ember.View.create({
+ template: function() {
+ return "This is the main view.";
+ }
+ });
+ container.set('currentView', mainView);
+
+ Ember.run(function() {
+ container.appendTo('#qunit-fixture');
+ });
+
+ equal(container.$().text(), "This is the main view.", "should render its child");
+ equal(getPath(container, 'childViews.length'), 1, "should have one child view");
+ equal(getPath(container, 'childViews').objectAt(0), mainView, "should have the currentView as the only child view");
+
+ Ember.run(function() {
+ set(container, 'currentView', null);
+ });
+
+ equal(container.$().text(), '', "has a empty contents");
+ equal(getPath(container, 'childViews.length'), 0, "should not have any child views");
+});
+
+test("if a ContainerView starts with a currentView and then is set to null, the ContainerView is updated", function() {
+ var container = Ember.ContainerView.create();
+ var mainView = Ember.View.create({
+ template: function() {
+ return "This is the main view.";
+ }
+ });
+ container.set('currentView', mainView);
+
+ Ember.run(function() {
+ container.appendTo('#qunit-fixture');
+ });
+
+ equal(container.$().text(), "This is the main view.", "should render its child");
+ equal(getPath(container, 'childViews.length'), 1, "should have one child view");
+ equal(getPath(container, 'childViews').objectAt(0), mainView, "should have the currentView as the only child view");
+
+ Ember.run(function() {
+ set(container, 'currentView', null);
+ });
+
+ equal(container.$().text(), '', "has a empty contents");
+ equal(getPath(container, 'childViews.length'), 0, "should not have any child views");
+});
+
+test("if a ContainerView starts with a currentView and then a different currentView is set, the old view is removed and the new one is added", function() {
+ var container = Ember.ContainerView.create();
+ var mainView = Ember.View.create({
+ template: function() {
+ return "This is the main view.";
+ }
+ });
+
+ var secondaryView = Ember.View.create({
+ template: function() {
+ return "This is the secondary view.";
+ }
+ });
+
+ container.set('currentView', mainView);
+
+ Ember.run(function() {
+ container.appendTo('#qunit-fixture');
+ });
+
+ equal(container.$().text(), "This is the main view.", "should render its child");
+ equal(getPath(container, 'childViews.length'), 1, "should have one child view");
+ equal(getPath(container, 'childViews').objectAt(0), mainView, "should have the currentView as the only child view");
+
+ Ember.run(function() {
+ set(container, 'currentView', secondaryView);
+ });
+
+ equal(container.$().text(), "This is the secondary view.", "should render its child");
+ equal(getPath(container, 'childViews.length'), 1, "should have one child view");
+ equal(getPath(container, 'childViews').objectAt(0), secondaryView, "should have the currentView as the only child view");
+}); | true |
Other | emberjs | ember.js | bf7f87a52b61ed7f01394be3878c60274827b1bc.json | Fix spelling mistakes | packages/ember-debug/package.json | @@ -1,8 +1,8 @@
{
"name": "ember-debug",
"summary": "Debugging for Ember",
- "description": "Dubugging helpers for Ember",
- "homepage": "http://www.ember`js.com",
+ "description": "Debugging helpers for Ember",
+ "homepage": "http://www.emberjs.com",
"author": "Peter Wagenet",
"version": "0.9.7.1",
| false |
Other | emberjs | ember.js | c94ccdc249ceae0f8132bf779a321bf956a92f23.json | Change the context in which {{view}} renders
Rather than binding to the view being rendered,
bind to the parent context. You can bind to the
view instead by prefixing your path with `.view`.
More information is available here:
https://gist.github.com/2494968 | packages/ember-handlebars/lib/controls/select.js | @@ -5,7 +5,7 @@ var indexOf = Ember.ArrayUtils.indexOf, indexesOf = Ember.ArrayUtils.indexesOf;
Ember.Select = Ember.View.extend({
tagName: 'select',
- defaultTemplate: Ember.Handlebars.compile('{{#if prompt}}<option>{{prompt}}</option>{{/if}}{{#each content}}{{view Ember.SelectOption contentBinding="this"}}{{/each}}'),
+ defaultTemplate: Ember.Handlebars.compile('{{#if view.prompt}}<option>{{view.prompt}}</option>{{/if}}{{#each view.content}}{{view Ember.SelectOption contentBinding="this"}}{{/each}}'),
attributeBindings: ['multiple'],
multiple: false,
@@ -108,7 +108,7 @@ Ember.Select = Ember.View.extend({
Ember.SelectOption = Ember.View.extend({
tagName: 'option',
- defaultTemplate: Ember.Handlebars.compile("{{label}}"),
+ defaultTemplate: Ember.Handlebars.compile("{{view.label}}"),
attributeBindings: ['value', 'selected'],
init: function() { | true |
Other | emberjs | ember.js | c94ccdc249ceae0f8132bf779a321bf956a92f23.json | Change the context in which {{view}} renders
Rather than binding to the view being rendered,
bind to the parent context. You can bind to the
view instead by prefixing your path with `.view`.
More information is available here:
https://gist.github.com/2494968 | packages/ember-handlebars/tests/handlebars_test.js | @@ -212,13 +212,13 @@ test("child views can be inserted using the {{view}} Handlebars helper", functio
TemplateTests.LabelView = Ember.View.extend({
tagName: "aside",
- cruel: "cruel",
world: "world?",
templateName: 'nested',
templates: templates
});
view = Ember.View.create({
+ cruel: "cruel",
world: "world!",
templateName: 'nester',
templates: templates
@@ -227,8 +227,8 @@ test("child views can be inserted using the {{view}} Handlebars helper", functio
appendView();
ok(view.$("#hello-world:contains('Hello world!')").length, "The parent view renders its contents");
- ok(view.$("#child-view:contains('Goodbye cruel world?')").length === 1, "The child view renders its content once");
- ok(view.$().text().match(/Hello world!.*Goodbye cruel world\?/), "parent view should appear before the child view");
+ ok(view.$("#child-view:contains('Goodbye cruel world!')").length === 1, "The child view renders its content once");
+ ok(view.$().text().match(/Hello world!.*Goodbye cruel world\!/), "parent view should appear before the child view");
});
test("should accept relative paths to views", function() {
@@ -258,7 +258,6 @@ test("child views can be inserted inside a bind block", function() {
tagName: "blockquote",
cruel: "cruel",
world: "world?",
- content: Ember.Object.create({ blah: "wot" }),
templateName: 'nested',
templates: templates
});
@@ -270,15 +269,16 @@ test("child views can be inserted inside a bind block", function() {
view = Ember.View.create({
world: "world!",
+ content: Ember.Object.create({ blah: "wot" }),
templateName: 'nester',
templates: templates
});
appendView();
ok(view.$("#hello-world:contains('Hello world!')").length, "The parent view renders its contents");
- ok(view.$("blockquote").text().match(/Goodbye.*wot.*cruel.*world\?/), "The child view renders its content once");
- ok(view.$().text().match(/Hello world!.*Goodbye.*wot.*cruel.*world\?/), "parent view should appear before the child view");
+ ok(view.$("blockquote").text().match(/Goodbye.*wot.*cruel.*world\!/), "The child view renders its content once");
+ ok(view.$().text().match(/Hello world!.*Goodbye.*wot.*cruel.*world\!/), "parent view should appear before the child view");
});
test("Ember.View should bind properties in the parent context", function() {
@@ -730,7 +730,7 @@ test("Template views add an elementId to child views created using the view help
equal(view.$().children().first().children().first().attr('id'), get(childView, 'elementId'));
});
-test("Template views set the template of their children to a passed block", function() {
+test("views set the template of their children to a passed block", function() {
var templates = Ember.Object.create({
parent: Ember.Handlebars.compile('<h1>{{#view "TemplateTests.NoTemplateView"}}<span>It worked!</span>{{/view}}</h1>')
});
@@ -746,6 +746,47 @@ test("Template views set the template of their children to a passed block", func
ok(view.$('h1:has(span)').length === 1, "renders the passed template inside the parent template");
});
+test("views render their template in the context of the parent view's context", function() {
+ var templates = Ember.Object.create({
+ parent: Ember.Handlebars.compile('<h1>{{#with content}}{{#view}}{{firstName}} {{lastName}}{{/view}}{{/with}}</h1>')
+ });
+
+ view = Ember.View.create({
+ templates: templates,
+ templateName: 'parent',
+
+ content: {
+ firstName: "Lana",
+ lastName: "del Heeeyyyyyy"
+ }
+ });
+
+ appendView();
+ equal(view.$('h1').text(), "Lana del Heeeyyyyyy", "renders properties from parent context");
+});
+
+test("views make a view keyword available that allows template to reference view context", function() {
+ var templates = Ember.Object.create({
+ parent: Ember.Handlebars.compile('<h1>{{#with content}}{{#view subview}}{{view.firstName}} {{lastName}}{{/view}}{{/with}}</h1>')
+ });
+
+ view = Ember.View.create({
+ templates: templates,
+ templateName: 'parent',
+
+ content: {
+ subview: Ember.View.extend({
+ firstName: "Brodele"
+ }),
+ firstName: "Lana",
+ lastName: "del Heeeyyyyyy"
+ }
+ });
+
+ appendView();
+ equal(view.$('h1').text(), "Brodele del Heeeyyyyyy", "renders properties from parent context");
+});
+
test("should warn if setting a template on a view with a templateName already specified", function() {
view = Ember.View.create({
childView: Ember.View.extend({
@@ -771,31 +812,6 @@ test("should warn if setting a template on a view with a templateName already sp
}, Error, "raises if conflicting template and templateName are provided via a Handlebars template");
});
-test("should pass hash arguments to the view object", function() {
- TemplateTests.bindTestObject = Ember.Object.create({
- bar: 'bat'
- });
-
- TemplateTests.HashArgTemplateView = Ember.View.extend({
- });
-
- Ember.run(function() {
- view = Ember.View.create({
- template: Ember.Handlebars.compile('{{#view TemplateTests.HashArgTemplateView fooBinding="TemplateTests.bindTestObject.bar"}}{{foo}}{{/view}}')
- });
-
- appendView();
- });
-
- equal(view.$().text(), "bat", "prints initial bound value");
-
- Ember.run(function() {
- set(TemplateTests.bindTestObject, 'bar', 'brains');
- });
-
- equal(view.$().text(), "brains", "prints updated bound value");
-});
-
test("Child views created using the view helper should have their parent view set properly", function() {
TemplateTests = {};
@@ -1443,15 +1459,11 @@ test("should be able to log a property", function(){
});
test("should allow standard Handlebars template usage", function() {
- TemplateTests.StandardTemplate = Ember.View.extend({
+ view = Ember.View.create({
name: "Erik",
template: Handlebars.compile("Hello, {{name}}")
});
- view = Ember.View.create({
- template: Ember.Handlebars.compile("{{view TemplateTests.StandardTemplate}}")
- });
-
Ember.run(function() {
view.appendTo('#qunit-fixture');
});
@@ -1760,7 +1772,7 @@ test("bindings should be relative to the current context", function() {
}),
museumView: Ember.View.extend({
- template: Ember.Handlebars.compile('Name: {{name}} Price: ${{dollars}}')
+ template: Ember.Handlebars.compile('Name: {{view.name}} Price: ${{view.dollars}}')
}),
template: Ember.Handlebars.compile('{{#if museumOpen}} {{view museumView nameBinding="museumDetails.name" dollarsBinding="museumDetails.price"}} {{/if}}')
@@ -1785,7 +1797,7 @@ test("bindings should respect keywords", function() {
},
museumView: Ember.View.extend({
- template: Ember.Handlebars.compile('Name: {{name}} Price: ${{dollars}}')
+ template: Ember.Handlebars.compile('Name: {{view.name}} Price: ${{view.dollars}}')
}),
template: Ember.Handlebars.compile('{{#if museumOpen}}{{view museumView nameBinding="controller.museumDetails.name" dollarsBinding="controller.museumDetails.price"}}{{/if}}')
@@ -1806,7 +1818,7 @@ test("bindings can be 'this', in which case they *are* the current context", fun
name: "SFMoMA",
price: 20,
museumView: Ember.View.extend({
- template: Ember.Handlebars.compile('Name: {{museum.name}} Price: ${{museum.price}}')
+ template: Ember.Handlebars.compile('Name: {{view.museum.name}} Price: ${{view.museum.price}}')
})
}),
@@ -1924,10 +1936,11 @@ test("should update bound values after the view is removed and then re-appended"
test("should update bound values after view's parent is removed and then re-appended", function() {
var parentView = Ember.ContainerView.create({
childViews: ['testView'],
+ showStuff: true,
+ boundValue: "foo",
+
testView: Ember.View.create({
- template: Ember.Handlebars.compile("{{#if showStuff}}{{boundValue}}{{else}}Not true.{{/if}}"),
- showStuff: true,
- boundValue: "foo"
+ template: Ember.Handlebars.compile("{{#if showStuff}}{{boundValue}}{{else}}Not true.{{/if}}")
})
});
@@ -1938,28 +1951,28 @@ test("should update bound values after view's parent is removed and then re-appe
equal(Ember.$.trim(view.$().text()), "foo");
Ember.run(function() {
- set(view, 'showStuff', false);
+ set(parentView, 'showStuff', false);
});
equal(Ember.$.trim(view.$().text()), "Not true.");
Ember.run(function() {
- set(view, 'showStuff', true);
+ set(parentView, 'showStuff', true);
});
equal(Ember.$.trim(view.$().text()), "foo");
parentView.remove();
Ember.run(function() {
- set(view, 'showStuff', false);
+ set(parentView, 'showStuff', false);
});
Ember.run(function() {
- set(view, 'showStuff', true);
+ set(parentView, 'showStuff', true);
});
Ember.run(function() {
parentView.appendTo('#qunit-fixture');
});
Ember.run(function() {
- set(view, 'boundValue', "bar");
+ set(parentView, 'boundValue', "bar");
});
equal(Ember.$.trim(view.$().text()), "bar");
}); | true |
Other | emberjs | ember.js | c94ccdc249ceae0f8132bf779a321bf956a92f23.json | Change the context in which {{view}} renders
Rather than binding to the view being rendered,
bind to the parent context. You can bind to the
view instead by prefixing your path with `.view`.
More information is available here:
https://gist.github.com/2494968 | packages/ember-handlebars/tests/helpers/yield_test.js | @@ -64,7 +64,7 @@ test("block should work properly even when templates are not hard-coded", functi
test("templates should yield to block, when the yield is embedded in a hierarchy of virtual views", function() {
TemplateTests.TimesView = Ember.View.extend({
- layout: Ember.Handlebars.compile('<div class="times">{{#each index}}{{yield}}{{/each}}</div>'),
+ layout: Ember.Handlebars.compile('<div class="times">{{#each view.index}}{{yield}}{{/each}}</div>'),
n: null,
index: Ember.computed(function() {
var n = Ember.get(this, 'n'), indexArray = Ember.A([]); | true |
Other | emberjs | ember.js | c94ccdc249ceae0f8132bf779a321bf956a92f23.json | Change the context in which {{view}} renders
Rather than binding to the view being rendered,
bind to the parent context. You can bind to the
view instead by prefixing your path with `.view`.
More information is available here:
https://gist.github.com/2494968 | packages/ember-handlebars/tests/views/collection_view_test.js | @@ -172,7 +172,7 @@ test("a block passed to a collection helper defaults to the content property of
});
view = Ember.View.create({
- template: Ember.Handlebars.compile('{{#collection "TemplateTests.CollectionTestView"}} <label>{{content}}</label> {{/collection}}')
+ template: Ember.Handlebars.compile('{{#collection "TemplateTests.CollectionTestView"}} <label>{{view.content}}</label> {{/collection}}')
});
Ember.run(function() {
@@ -189,7 +189,7 @@ test("a block passed to a collection helper defaults to the view", function() {
});
view = Ember.View.create({
- template: Ember.Handlebars.compile('{{#collection "TemplateTests.CollectionTestView"}} <label>{{content}}</label> {{/collection}}')
+ template: Ember.Handlebars.compile('{{#collection "TemplateTests.CollectionTestView"}} <label>{{view.content}}</label> {{/collection}}')
});
Ember.run(function() {
@@ -275,7 +275,7 @@ test("should give its item views the property specified by itemPropertyBinding",
var view = Ember.View.create({
baz: "baz",
content: Ember.A([Ember.Object.create(), Ember.Object.create(), Ember.Object.create()]),
- template: Ember.Handlebars.compile('{{#collection contentBinding="content" tagName="ul" itemViewClass="TemplateTests.itemPropertyBindingTestItemView" itemPropertyBinding="baz" preserveContext=false}}{{property}}{{/collection}}')
+ template: Ember.Handlebars.compile('{{#collection contentBinding="content" tagName="ul" itemViewClass="TemplateTests.itemPropertyBindingTestItemView" itemPropertyBinding="baz" preserveContext=false}}{{view.property}}{{/collection}}')
});
Ember.run(function() {
@@ -346,7 +346,7 @@ test("should re-render when the content object changes", function() {
});
var view = Ember.View.create({
- template: Ember.Handlebars.compile('{{#collection TemplateTests.RerenderTest}}{{content}}{{/collection}}')
+ template: Ember.Handlebars.compile('{{#collection TemplateTests.RerenderTest}}{{view.content}}{{/collection}}')
});
Ember.run(function() {
@@ -372,7 +372,7 @@ test("select tagName on collection helper automatically sets child tagName to op
});
var view = Ember.View.create({
- template: Ember.Handlebars.compile('{{#collection TemplateTests.RerenderTest tagName="select"}}{{content}}{{/collection}}')
+ template: Ember.Handlebars.compile('{{#collection TemplateTests.RerenderTest tagName="select"}}{{view.content}}{{/collection}}')
});
Ember.run(function() {
@@ -389,7 +389,7 @@ test("tagName works in the #collection helper", function() {
});
var view = Ember.View.create({
- template: Ember.Handlebars.compile('{{#collection TemplateTests.RerenderTest tagName="ol"}}{{content}}{{/collection}}')
+ template: Ember.Handlebars.compile('{{#collection TemplateTests.RerenderTest tagName="ol"}}{{view.content}}{{/collection}}')
});
Ember.run(function() { | true |
Other | emberjs | ember.js | c94ccdc249ceae0f8132bf779a321bf956a92f23.json | Change the context in which {{view}} renders
Rather than binding to the view being rendered,
bind to the parent context. You can bind to the
view instead by prefixing your path with `.view`.
More information is available here:
https://gist.github.com/2494968 | packages/ember-metal/lib/core.js | @@ -106,6 +106,41 @@ Ember.SHIM_ES5 = (Ember.ENV.SHIM_ES5 === false) ? false : Ember.EXTEND_PROTOTYPE
*/
Ember.CP_DEFAULT_CACHEABLE = !!Ember.ENV.CP_DEFAULT_CACHEABLE;
+/**
+ @static
+ @type Boolean
+ @default false
+ @constant
+
+ Determines whether views render their templates using themselves
+ as the context, or whether it is inherited from the parent. In
+ future releases, this will default to `true`. For the 1.0 release,
+ the option to have views change context by default will be removed entirely.
+
+ If you need to update your application to use the new context rules, simply
+ prefix property access with `view.`:
+
+ // Before:
+ {{#each App.photosController}}
+ Photo Title: {{title}}
+ {{#view App.InfoView contentBinding="this"}}
+ {{content.date}}
+ {{content.cameraType}}
+ {{otherViewProperty}}
+ {{/view}}
+ {{/each}}
+
+ // After:
+ {{#each App.photosController}}
+ Photo Title: {{title}}
+ {{#view App.InfoView}}
+ {{date}}
+ {{cameraType}}
+ {{view.otherViewProperty}}
+ {{/view}}
+ {{/each}}
+*/
+Ember.VIEW_PRESERVES_CONTEXT = !!Ember.ENV.VIEW_PRESERVES_CONTEXT;
/**
Empty function. Useful for some operations. | true |
Other | emberjs | ember.js | c94ccdc249ceae0f8132bf779a321bf956a92f23.json | Change the context in which {{view}} renders
Rather than binding to the view being rendered,
bind to the parent context. You can bind to the
view instead by prefixing your path with `.view`.
More information is available here:
https://gist.github.com/2494968 | packages/ember-views/lib/views/view.js | @@ -28,6 +28,9 @@ var childViewsProperty = Ember.computed(function() {
return ret;
}).property().cacheable();
+var VIEW_PRESERVES_CONTEXT = Ember.VIEW_PRESERVES_CONTEXT;
+ember_warn("The way that the {{view}} helper affects templates is about to change. Previously, templates inside child views would use the new view as the context. Soon, views will preserve their parent context when rendering their template. You can opt-in early to the new behavior by setting `ENV.VIEW_PRESERVES_CONTEXT = true`. For more information, see https://gist.github.com/2494968. You should update your templates as soon as possible; this default will change soon, and the option will be eliminated entirely before the 1.0 release.", VIEW_PRESERVES_CONTEXT);
+
/**
@static
@@ -192,11 +195,20 @@ Ember.View = Ember.Object.extend(Ember.Evented,
to be re-rendered.
*/
_templateContext: Ember.computed(function(key, value) {
+ var parentView;
+
if (arguments.length === 2) {
return value;
- } else {
- return this;
}
+
+ if (VIEW_PRESERVES_CONTEXT) {
+ parentView = get(this, '_parentView');
+ if (parentView) {
+ return get(parentView, '_templateContext');
+ }
+ }
+
+ return this;
}).cacheable(),
/** | true |
Other | emberjs | ember.js | c94ccdc249ceae0f8132bf779a321bf956a92f23.json | Change the context in which {{view}} renders
Rather than binding to the view being rendered,
bind to the parent context. You can bind to the
view instead by prefixing your path with `.view`.
More information is available here:
https://gist.github.com/2494968 | packages/ember-views/tests/views/container_view_test.js | @@ -95,8 +95,8 @@ test("views that are removed from a ContainerView should have their child views
remove: function() {
this._super();
},
- template: function(view) {
- view.appendChild(Ember.View);
+ template: function(context, options) {
+ options.data.view.appendChild(Ember.View);
}
});
| true |
Other | emberjs | ember.js | c94ccdc249ceae0f8132bf779a321bf956a92f23.json | Change the context in which {{view}} renders
Rather than binding to the view being rendered,
bind to the parent context. You can bind to the
view instead by prefixing your path with `.view`.
More information is available here:
https://gist.github.com/2494968 | tests/index.html | @@ -45,6 +45,8 @@
var cpDefaultCacheable = QUnit.urlParams.cpdefaultcacheable;
ENV['CP_DEFAULT_CACHEABLE'] = !!cpDefaultCacheable;
+
+ ENV.VIEW_PRESERVES_CONTEXT = true;
</script>
</head>
<body> | true |
Other | emberjs | ember.js | 642637c9dbad1b7b33a5c0800ca6bb55a317c6cb.json | Improve error when sending an unimplemented event
Improves the error message when sending an event
to a state manager that is the name of a child
state. | packages/ember-states/lib/state_manager.js | @@ -394,7 +394,13 @@ Ember.StateManager = Ember.State.extend(
var action = currentState[event];
- if (action) {
+ // Test to see if the action is a method that
+ // can be invoked. Don't blindly check just for
+ // existence, because it is possible the state
+ // manager has a child state of the given name,
+ // and we should still raise an exception in that
+ // case.
+ if (typeof action === 'function') {
if (log) { console.log(fmt("STATEMANAGER: Sending event '%@' to state %@.", [event, get(currentState, 'path')])); }
action.call(currentState, this, context);
} else { | false |
Other | emberjs | ember.js | b79623463e2da7155327136e487ace3612dc6c2a.json | Remove vestigial code left over from 9afcb3e | packages/ember-handlebars/lib/helpers/binding.js | @@ -338,8 +338,6 @@ EmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId,
// If value is a Boolean and true, return the dasherized property
// name.
} else if (val === true) {
- if (className) { return className; }
-
// Normalize property path to be suitable for use
// as a class name. For exaple, content.foo.barBaz
// becomes bar-baz. | true |
Other | emberjs | ember.js | b79623463e2da7155327136e487ace3612dc6c2a.json | Remove vestigial code left over from 9afcb3e | packages/ember-views/lib/views/view.js | @@ -599,9 +599,7 @@ Ember.View = Ember.Object.extend(Ember.Evented,
// If value is a Boolean and true, return the dasherized property
// name.
- } else if (val === true) {
- if (className) { return className; }
-
+ } else if (val === true) {
// Normalize property path to be suitable for use
// as a class name. For exaple, content.foo.barBaz
// becomes bar-baz. | true |
Other | emberjs | ember.js | bd6c1a3761207efda3cc2a5f3f5a39092447ff95.json | add safeHtml method to String
change to htmlSafe to be coherent with rails | packages/ember-handlebars/lib/main.js | @@ -7,6 +7,7 @@
require("ember-runtime");
require("ember-views");
require("ember-handlebars/ext");
+require("ember-handlebars/string");
require("ember-handlebars/helpers");
require("ember-handlebars/views");
require("ember-handlebars/controls"); | true |
Other | emberjs | ember.js | bd6c1a3761207efda3cc2a5f3f5a39092447ff95.json | add safeHtml method to String
change to htmlSafe to be coherent with rails | packages/ember-handlebars/lib/string.js | @@ -0,0 +1,17 @@
+
+Ember.String.htmlSafe = function(str) {
+ return new Handlebars.SafeString(str);
+};
+
+var htmlSafe = Ember.String.htmlSafe;
+
+if (Ember.EXTEND_PROTOTYPES) {
+
+ /**
+ @see Ember.String.htmlSafe
+ */
+ String.prototype.htmlSafe = function() {
+ return htmlSafe(this);
+ };
+
+} | true |
Other | emberjs | ember.js | bd6c1a3761207efda3cc2a5f3f5a39092447ff95.json | add safeHtml method to String
change to htmlSafe to be coherent with rails | packages/ember-handlebars/tests/handlebars_test.js | @@ -143,6 +143,12 @@ test("should allow values from normal JavaScript hash objects to be used", funct
equal(view.$().text(), "Señor CFC (and Fido)", "prints out values from a hash");
});
+test("htmlSafe should return an instance of Handlebars.SafeString", function() {
+ var safeString = Ember.String.htmlSafe("you need to be more <b>bold</b>");
+
+ ok(safeString instanceof Handlebars.SafeString, "should return SafeString");
+});
+
test("should escape HTML in normal mustaches", function() {
view = Ember.View.create({
template: Ember.Handlebars.compile('{{output}}'), | true |
Other | emberjs | ember.js | 28449b4129c83279c360bfb12419d31508d9255b.json | Include lib files for uploader | lib/github_uploader.rb | @@ -0,0 +1,89 @@
+require "rest-client"
+require "github_api"
+# We can stop requiring nokogiri when github_api is updated
+require "nokogiri"
+
+class GithubUploader
+
+ def initialize(login, username, repo, root=Dir.pwd)
+ @login = login
+ @username = username
+ @repo = repo
+ @root = root
+ @token = check_token
+ end
+
+ def authorized?
+ !!@token
+ end
+
+ def token_path
+ File.expand_path(".github-upload-token", @root)
+ end
+
+ def check_token
+ File.exist?(token_path) ? File.open(token_path, "rb").read : nil
+ end
+
+ def authorize
+ return if authorized?
+
+ puts "There is no file named .github-upload-token in this folder. This file holds the OAuth token needed to communicate with GitHub."
+ puts "You will be asked to enter your GitHub password so a new OAuth token will be created."
+ print "GitHub Password: "
+ system "stty -echo" # disable echoing of entered chars so password is not shown on console
+ pw = STDIN.gets.chomp
+ system "stty echo" # enable echoing of entered chars
+ puts ""
+
+ # check if the user already granted access for Ember.js Uploader by checking the available authorizations
+ response = RestClient.get "https://#{@login}:#{pw}@api.github.com/authorizations"
+ JSON.parse(response.to_str).each do |auth|
+ if auth["note"] == "Ember.js Uploader"
+ # user already granted access, so we reuse the existing token
+ @token = auth["token"]
+ end
+ end
+
+ ## we need to create a new token
+ unless @token
+ payload = {
+ :scopes => ["public_repo"],
+ :note => "Ember.js Uploader",
+ :note_url => "https://github.com/#{@username}/#{@repo}"
+ }
+ response = RestClient.post "https://#{@login}:#{pw}@api.github.com/authorizations", payload.to_json, :content_type => :json
+ @token = JSON.parse(response.to_str)["token"]
+ end
+
+ # finally save the token into .github-upload-token
+ File.open(".github-upload-token", 'w') {|f| f.write(@token)}
+ end
+
+ def upload_file(filename, description, file)
+ return false unless authorized?
+
+ gh = Github.new :user => @username, :repo => @repo, :oauth_token => @token
+
+ # remvove previous download with the same name
+ gh.repos.downloads do |download|
+ if filename == download.name
+ gh.repos.delete_download @username, @repo, download.id
+ break
+ end
+ end
+
+ # step 1
+ hash = gh.repos.create_download @username, @repo,
+ "name" => filename,
+ "size" => File.size(file),
+ "description" => description,
+ "content_type" => "application/json"
+
+ # step 2
+ gh.repos.upload hash, file
+
+ return true
+ end
+
+end | false |
Other | emberjs | ember.js | b89b23eb391aadeeae46738581cbeff5d4667770.json | Fix jshint warnings for CLI tests - Fixes #714 | tests/index.html | @@ -168,7 +168,8 @@ <h2 id="qunit-userAgent"></h2>
// (closure to preserve variable values)
(function() {
var jshintModule = moduleName;
- test(jshintModule+' should pass jshint', function() {
+ module(jshintModule);
+ test('should pass jshint', function() {
var passed = JSHINT(minispade.modules[jshintModule], JSHINTRC),
errors = jsHintReporter(jshintModule, JSHINT.errors);
ok(passed, jshintModule+" should pass jshint."+(errors ? "\n"+errors : '')); | false |
Other | emberjs | ember.js | a982beb5c4ec50932c312626f44488d0ee85abec.json | Fix issue #233 | packages/ember-handlebars/lib/views/metamorph_view.js | @@ -9,6 +9,8 @@ var DOMManager = {
remove: function(view) {
var morph = view.morph;
if (morph.isRemoved()) { return; }
+ set(view, 'element', null);
+ set(view, 'lastInsert', null);
morph.remove();
},
| true |
Other | emberjs | ember.js | a982beb5c4ec50932c312626f44488d0ee85abec.json | Fix issue #233 | packages/ember-views/lib/views/collection_view.js | @@ -266,7 +266,6 @@ Ember.CollectionView = Ember.ContainerView.extend(
addedViews.push(emptyView);
set(this, 'emptyView', emptyView);
}
-
childViews.replace(start, 0, addedViews);
},
| true |
Other | emberjs | ember.js | a982beb5c4ec50932c312626f44488d0ee85abec.json | Fix issue #233 | packages/ember-views/lib/views/states/default.js | @@ -27,6 +27,12 @@ Ember.View.states = {
// Handle events from `Ember.EventDispatcher`
handleEvent: function() {
return true; // continue event propagation
+ },
+
+ destroyElement: function(view) {
+ set(view, 'element', null);
+ set(view, 'lastInsert', null);
+ return view;
}
}
}; | true |
Other | emberjs | ember.js | a982beb5c4ec50932c312626f44488d0ee85abec.json | Fix issue #233 | packages/ember-views/lib/views/states/in_dom.js | @@ -27,6 +27,7 @@ Ember.View.states.hasElement = {
setElement: function(view, value) {
if (value === null) {
view.invalidateRecursively('element');
+
view.transitionTo('preRender');
} else {
throw "You cannot set an element to a non-null value when the element is already in the DOM.";
@@ -48,10 +49,10 @@ Ember.View.states.hasElement = {
// once the view is already in the DOM, destroying it removes it
// from the DOM, nukes its element, and puts it back into the
- // preRender state.
+ // preRender state if inDOM.
+
destroyElement: function(view) {
view._notifyWillDestroyElement();
-
view.domManager.remove(view);
return view;
},
@@ -81,7 +82,10 @@ Ember.View.states.hasElement = {
Ember.View.states.inDOM = {
parentState: Ember.View.states.hasElement,
- insertElement: function() {
+ insertElement: function(view, fn) {
+ if (view.get('lastInsert') !== fn.insertGuid){
+ return;
+ }
throw "You can't insert an element into the DOM that has already been inserted";
}
}; | true |
Other | emberjs | ember.js | a982beb5c4ec50932c312626f44488d0ee85abec.json | Fix issue #233 | packages/ember-views/lib/views/states/pre_render.js | @@ -13,6 +13,9 @@ Ember.View.states.preRender = {
// a view leaves the preRender state once its element has been
// created (createElement).
insertElement: function(view, fn) {
+ if (view.get('lastInsert') !== fn.insertGuid){
+ return;
+ }
view.createElement();
view._notifyWillInsertElement(true);
// after createElement, the view will be in the hasElement state. | true |
Other | emberjs | ember.js | a982beb5c4ec50932c312626f44488d0ee85abec.json | Fix issue #233 | packages/ember-views/lib/views/view.js | @@ -744,6 +744,7 @@ Ember.View = Ember.Object.extend(Ember.Evented,
@param {Function} fn the function that inserts the element into the DOM
*/
_insertElementLater: function(fn) {
+ set(this, 'lastInsert', fn.insertGuid = Ember.generateGuid());
Ember.run.schedule('render', this, this.invokeForState, 'insertElement', fn);
},
@@ -1527,6 +1528,7 @@ var DOMManager = {
var elem = get(view, 'element');
set(view, 'element', null);
+ set(view, 'lastInsert', null);
Ember.$(elem).remove();
}, | true |
Other | emberjs | ember.js | a982beb5c4ec50932c312626f44488d0ee85abec.json | Fix issue #233 | packages/ember-views/tests/views/collection_test.js | @@ -313,3 +313,30 @@ test("should allow declaration of itemViewClass as a string", function() {
equal(view.$('.ember-view').length, 3);
});
+
+test("should not render the emptyView if content is emptied and refilled in the same run loop", function() {
+ view = Ember.CollectionView.create({
+ tagName: 'div',
+ content: Ember.A(['NEWS GUVNAH']),
+
+ emptyView: Ember.View.create({
+ tagName: 'kbd',
+ render: function(buf) {
+ buf.push("OY SORRY GUVNAH NO NEWS TODAY EH");
+ }
+ })
+ });
+
+ Ember.run(function() {
+ view.append();
+ });
+
+ equal(view.$().find('kbd:contains("OY SORRY GUVNAH")').length, 0);
+
+ Ember.run(function() {
+ view.get('content').popObject();
+ view.get('content').pushObject(['NEWS GUVNAH']);
+ });
+ equal(view.$('div').length, 1);
+ equal(view.$().find('kbd:contains("OY SORRY GUVNAH")').length, 0);
+}); | true |
Other | emberjs | ember.js | a982beb5c4ec50932c312626f44488d0ee85abec.json | Fix issue #233 | packages/ember-views/tests/views/view/remove_test.js | @@ -95,5 +95,27 @@ test("does nothing if not in parentView", function() {
});
+test("the DOM element is gone after doing append and remove in two separate runloops", function() {
+ var view = Ember.View.create();
+ Ember.run(function() {
+ view.append();
+ });
+ Ember.run(function() {
+ view.remove();
+ });
+
+ var viewElem = Ember.$('#'+get(view, 'elementId'));
+ ok(viewElem.length === 0, "view's element doesn't exist in DOM");
+});
+test("the DOM element is gone after doing append and remove in a single runloop", function() {
+ var view = Ember.View.create();
+ Ember.run(function() {
+ view.append();
+ view.remove();
+ });
+
+ var viewElem = Ember.$('#'+get(view, 'elementId'));
+ ok(viewElem.length === 0, "view's element doesn't exist in DOM");
+});
| true |
Other | emberjs | ember.js | 0e500d5ee386ab0617a59a661c23bc2d4d1ee844.json | Correct a spelling error. | packages/ember-views/lib/views/container_view.js | @@ -177,7 +177,7 @@ var childViewsProperty = Ember.computed(function() {
## Templates and Layout
- A `template`, `templateName`, `defaultTempalte`, `layout`, `layoutName` or `defaultLayout`
+ A `template`, `templateName`, `defaultTemplate`, `layout`, `layoutName` or `defaultLayout`
property on a container view will not result in the template or layout being rendered.
The HTML contents of a `Ember.ContainerView`'s DOM representation will only be the rendered HTML
of its child views. | false |
Other | emberjs | ember.js | 7a4fafbcd565aaf429b0d83595a0395f3d906fa0.json | Fix the build | tests/index.html | @@ -120,16 +120,14 @@ <h2 id="qunit-userAgent"></h2>
el = document.getElementById('qunit-header');
el.innerHTML = 'Add package=package1,package2 in the URL to test packages';
} else {
- if (packages[1] === 'all') {
+ if (packages[0] === 'all') {
packages = [
'ember-handlebars',
'ember-metal',
'ember-runtime',
'ember-states',
'ember-views'
];
- } else {
- packages = packages[1].split(',');
}
len = packages.length; | false |
Other | emberjs | ember.js | dae7ae3a3d3b298bd66099308736de0547185112.json | Update travis to run against git jQuery | Rakefile | @@ -309,8 +309,10 @@ task :test, [:suite] => :dist do |t, args|
# testing older jQuery 1.6.4 for compatibility
:all => packages.map{|p| "package=#{p}" } +
["package=all&jquery=1.6.4&nojshint=true",
+ "package=all&jquery=git&nojshint=true",
"package=all&extendprototypes=true&nojshint=true",
"package=all&extendprototypes=true&jquery=1.6.4&nojshint=true",
+ "package=all&extendprototypes=true&jquery=git&nojshint=true",
"package=all&dist=build&nojshint=true"]
}
| false |
Other | emberjs | ember.js | 6738647e3a5077db04c5fea4cc7c588f60dc6b2c.json | fix typo StateManager object in examples | packages/ember-states/lib/state_manager.js | @@ -574,7 +574,7 @@ require('ember-states/state');
And application code
App = Ember.Application.create()
- App.states = Ember.StateManager.create({
+ App.appStates = Ember.StateManager.create({
initialState: 'aState',
aState: Ember.State.create({
anAction: function(manager, context){}
@@ -583,7 +583,7 @@ require('ember-states/state');
})
A user initiated click or touch event on "Go" will trigger the 'anAction' method of
- `App.states.aState` with `App.states` as the first argument and a
+ `App.appStates.aState` with `App.appStates` as the first argument and a
`jQuery.Event` object as the second object. The `jQuery.Event` will include a property
`view` that references the `Ember.View` object that was interacted with.
| false |
Other | emberjs | ember.js | 208e498390b852f71e5fe6623a5b8d2dd4005c13.json | Normalize keyword paths so that observers work
In the previous implementation, observers would
not get set up correctly since root/path
combinations were not resolved to take into
account Handlebars keywords until getPath was
called.
In this commit, a separate method to normalize
root/path combinations is exposed and used when
setting up observers in BindableSpans. | packages/ember-handlebars/lib/ext.js | @@ -128,6 +128,39 @@ Ember.Handlebars.compile = function(string) {
return Handlebars.template(templateSpec);
};
+/**
+ If a path starts with a reserved keyword, returns the root
+ that should be used.
+*/
+var normalizePath = Ember.Handlebars.normalizePath = function(root, path, data) {
+ var keywords = (data && data.keywords) || {},
+ keyword, isKeyword;
+
+ // Get the first segment of the path. For example, if the
+ // path is "foo.bar.baz", returns "foo".
+ keyword = path.split('.', 1)[0];
+
+ // Test to see if the first path is a keyword that has been
+ // passed along in the view's data hash. If so, we will treat
+ // that object as the new root.
+ if (keywords.hasOwnProperty(keyword)) {
+ // Look up the value in the template's data hash.
+ root = keywords[keyword];
+ isKeyword = true;
+
+ // Handle cases where the entire path is the reserved
+ // word. In that case, return the object itself.
+ if (path === keyword) {
+ path = '';
+ } else {
+ // Strip the keyword from the path and look up
+ // the remainder from the newly found root.
+ path = path.substr(keyword.length);
+ }
+ }
+
+ return { root: root, path: path, isKeyword: isKeyword };
+};
/**
Lookup both on root and on window. If the path starts with
a keyword, the corresponding object will be looked up in the
@@ -138,48 +171,19 @@ Ember.Handlebars.compile = function(string) {
@param {Object} options The template's option hash
*/
-// Regular expression used to determine if a path starts
-// with a reserved word, and if so, which reserved word it
-// is.
-var KEYWORD_REGEX = Ember.Handlebars.KEYWORD_REGEX = /^(controller|view)\.?/;
-
Ember.Handlebars.getPath = function(root, path, options) {
var data = options.data,
- value, keyword;
+ normalizedPath = normalizePath(root, path, data),
+ value;
- // Test to see if the path starts with a keyword.
- // For example, "controller.foo.bar"
- if (data && KEYWORD_REGEX.test(path)) {
+ // In cases where the path begins with a keyword, change the
+ // root to the value represented by that keyword, and ensure
+ // the path is relative to it.
+ root = normalizedPath.root;
+ path = normalizedPath.path;
- // We used a fast (non-extracting) test above
- // to reduce the performance hit for paths that
- // do not contain keywords. Now that we know that
- // we match, extract the keyword from the string.
- keyword = path.match(KEYWORD_REGEX)[1];
-
- // Look up the value in the template's data hash.
- root = data[keyword];
-
- // Make sure we don't expose virtual views to the
- // user.
- if (root.isView) {
- root = root.get('concreteView');
- }
-
- // Handle cases where the entire path is the reserved
- // word. In that case, return the object itself.
- if (path === keyword) {
- value = root;
- } else {
- // Strip the keyword from the path and look up
- // the remainder from the newly found root.
- path = path.substr(keyword.length);
- value = Ember.getPath(root, path, false);
- }
- } else {
- // TODO: Remove this `false` when the `getPath` globals support is removed
- value = Ember.getPath(root, path, false);
- }
+ // TODO: Remove this `false` when the `getPath` globals support is removed
+ value = Ember.getPath(root, path, false);
if (value === undefined && root !== window && Ember.isGlobalPath(path)) {
value = Ember.getPath(window, path); | true |
Other | emberjs | ember.js | 208e498390b852f71e5fe6623a5b8d2dd4005c13.json | Normalize keyword paths so that observers work
In the previous implementation, observers would
not get set up correctly since root/path
combinations were not resolved to take into
account Handlebars keywords until getPath was
called.
In this commit, a separate method to normalize
root/path combinations is exposed and used when
setting up observers in BindableSpans. | packages/ember-handlebars/lib/helpers/binding.js | @@ -21,7 +21,13 @@ var EmberHandlebars = Ember.Handlebars, helpers = EmberHandlebars.helpers;
fn = options.fn,
inverse = options.inverse,
view = data.view,
- ctx = this;
+ ctx = this,
+ normalized;
+
+ normalized = Ember.Handlebars.normalizePath(ctx, property, data);
+
+ ctx = normalized.root;
+ property = normalized.path;
// Set up observers for observable objects
if ('object' === typeof this) { | true |
Other | emberjs | ember.js | 208e498390b852f71e5fe6623a5b8d2dd4005c13.json | Normalize keyword paths so that observers work
In the previous implementation, observers would
not get set up correctly since root/path
combinations were not resolved to take into
account Handlebars keywords until getPath was
called.
In this commit, a separate method to normalize
root/path combinations is exposed and used when
setting up observers in BindableSpans. | packages/ember-handlebars/lib/helpers/collection.js | @@ -90,7 +90,7 @@ Ember.Handlebars.registerHelper('collection', function(path, options) {
delete hash.preserveContext;
}
- hash.itemViewClass = Ember.Handlebars.ViewHelper.viewClassFromHTMLOptions(itemViewClass, itemHash, this);
+ hash.itemViewClass = Ember.Handlebars.ViewHelper.viewClassFromHTMLOptions(itemViewClass, { data: data, hash: itemHash }, this);
return Ember.Handlebars.helpers.view.call(this, collectionClass, options);
}); | true |
Other | emberjs | ember.js | 208e498390b852f71e5fe6623a5b8d2dd4005c13.json | Normalize keyword paths so that observers work
In the previous implementation, observers would
not get set up correctly since root/path
combinations were not resolved to take into
account Handlebars keywords until getPath was
called.
In this commit, a separate method to normalize
root/path combinations is exposed and used when
setting up observers in BindableSpans. | packages/ember-handlebars/lib/helpers/view.js | @@ -17,12 +17,13 @@ var EmberHandlebars = Ember.Handlebars;
EmberHandlebars.ViewHelper = Ember.Object.create({
viewClassFromHTMLOptions: function(viewClass, options, thisContext) {
+ var hash = options.hash, data = options.data;
var extensions = {},
- classes = options['class'],
+ classes = hash['class'],
dup = false;
- if (options.id) {
- extensions.elementId = options.id;
+ if (hash.id) {
+ extensions.elementId = hash.id;
dup = true;
}
@@ -32,48 +33,49 @@ EmberHandlebars.ViewHelper = Ember.Object.create({
dup = true;
}
- if (options.classBinding) {
- extensions.classNameBindings = options.classBinding.split(' ');
+ if (hash.classBinding) {
+ extensions.classNameBindings = hash.classBinding.split(' ');
dup = true;
}
- if (options.classNameBindings) {
- extensions.classNameBindings = options.classNameBindings.split(' ');
+ if (hash.classNameBindings) {
+ extensions.classNameBindings = hash.classNameBindings.split(' ');
dup = true;
}
- if (options.attributeBindings) {
+ if (hash.attributeBindings) {
ember_assert("Setting 'attributeBindings' via Handlebars is not allowed. Please subclass Ember.View and set it there instead.");
extensions.attributeBindings = null;
dup = true;
}
if (dup) {
- options = Ember.$.extend({}, options);
- delete options.id;
- delete options['class'];
- delete options.classBinding;
+ hash = Ember.$.extend({}, hash);
+ delete hash.id;
+ delete hash['class'];
+ delete hash.classBinding;
}
// Look for bindings passed to the helper and, if they are
// local, make them relative to the current context instead of the
// view.
- var path;
+ var path, normalized;
- for (var prop in options) {
- if (!options.hasOwnProperty(prop)) { continue; }
+ for (var prop in hash) {
+ if (!hash.hasOwnProperty(prop)) { continue; }
// Test if the property ends in "Binding"
if (Ember.IS_BINDING.test(prop)) {
- path = options[prop];
+ path = hash[prop];
- if (EmberHandlebars.KEYWORD_REGEX.test(path)) {
- options[prop] = 'templateData.'+path;
+ normalized = Ember.Handlebars.normalizePath(null, path, data);
+ if (normalized.isKeyword) {
+ hash[prop] = 'templateData.keywords.'+path;
} else if (!Ember.isGlobalPath(path)) {
if (path === 'this') {
- options[prop] = 'bindingContext';
+ hash[prop] = 'bindingContext';
} else {
- options[prop] = 'bindingContext.'+path;
+ hash[prop] = 'bindingContext.'+path;
}
}
}
@@ -83,7 +85,7 @@ EmberHandlebars.ViewHelper = Ember.Object.create({
// for the bindings set up above.
extensions.bindingContext = thisContext;
- return viewClass.extend(options, extensions);
+ return viewClass.extend(hash, extensions);
},
helper: function(thisContext, path, options) {
@@ -103,7 +105,7 @@ EmberHandlebars.ViewHelper = Ember.Object.create({
ember_assert(Ember.String.fmt('You must pass a view class to the #view helper, not %@ (%@)', [path, newView]), Ember.View.detect(newView));
- newView = this.viewClassFromHTMLOptions(newView, hash, thisContext);
+ newView = this.viewClassFromHTMLOptions(newView, options, thisContext);
var currentView = data.view;
var viewOptions = {
templateData: options.data | true |
Other | emberjs | ember.js | 208e498390b852f71e5fe6623a5b8d2dd4005c13.json | Normalize keyword paths so that observers work
In the previous implementation, observers would
not get set up correctly since root/path
combinations were not resolved to take into
account Handlebars keywords until getPath was
called.
In this commit, a separate method to normalize
root/path combinations is exposed and used when
setting up observers in BindableSpans. | packages/ember-handlebars/tests/handlebars_test.js | @@ -1410,6 +1410,15 @@ test("should expose a controller keyword when present on the view", function() {
equal(view.$().text(), "barbang", "renders values from controller and parent controller");
+ var controller = get(view, 'controller');
+
+ Ember.run(function() {
+ controller.set('foo', "BAR");
+ controller.set('baz', "BLARGH");
+ });
+
+ equal(view.$().text(), "BARBLARGH", "updates the DOM when a bound value is updated");
+
view.destroy();
view = Ember.View.create({
@@ -1424,6 +1433,29 @@ test("should expose a controller keyword when present on the view", function() {
equal(view.$().text(), "aString", "renders the controller itself if no additional path is specified");
});
+test("should expose a controller keyword that can be used in conditionals", function() {
+ var templateString = "{{#view}}{{#if controller}}{{controller.foo}}{{/if}}{{/view}}";
+ view = Ember.View.create({
+ controller: Ember.Object.create({
+ foo: "bar"
+ }),
+
+ template: Ember.Handlebars.compile(templateString)
+ });
+
+ Ember.run(function() {
+ view.appendTo("#qunit-fixture");
+ });
+
+ equal(view.$().text(), "bar", "renders values from controller and parent controller");
+
+ Ember.run(function() {
+ view.set('controller', null);
+ });
+
+ equal(view.$().text(), "", "updates the DOM when the controller is changed");
+});
+
test("should expose a view keyword", function() {
var templateString = '{{#with differentContent}}{{view.foo}}{{#view baz="bang"}}{{view.baz}}{{/view}}{{/with}}';
view = Ember.View.create({ | true |
Other | emberjs | ember.js | 208e498390b852f71e5fe6623a5b8d2dd4005c13.json | Normalize keyword paths so that observers work
In the previous implementation, observers would
not get set up correctly since root/path
combinations were not resolved to take into
account Handlebars keywords until getPath was
called.
In this commit, a separate method to normalize
root/path combinations is exposed and used when
setting up observers in BindableSpans. | packages/ember-views/lib/views/view.js | @@ -121,6 +121,14 @@ Ember.View = Ember.Object.extend(Ember.Evented,
return template || get(this, 'defaultTemplate');
}).property('templateName').cacheable(),
+ /**
+ The controller managing this view. If this property is set, it will be made
+ made available for use by the template.
+
+ @type Object
+ */
+ controller: null,
+
/**
A view may contain a layout. A layout is a regular template but
supercedes the `template` property during rendering. It is the
@@ -192,14 +200,14 @@ Ember.View = Ember.Object.extend(Ember.Evented,
}).cacheable(),
/**
- If the template context changes, the view should be re-rendered to display
- the new value.
+ If a value that affects template rendering changes, the view should be
+ re-rendered to reflect the new value.
@private
*/
- templateContextDidChange: Ember.observer(function() {
+ _displayPropertyDidChange: Ember.observer(function() {
this.rerender();
- }, 'templateContext'),
+ }, 'templateContext', 'controller'),
/**
If the view is currently inserted into the DOM of a parent view, this
@@ -358,13 +366,21 @@ Ember.View = Ember.Object.extend(Ember.Evented,
if (template) {
var context = get(this, '_templateContext'),
templateData = this.get('templateData'),
- controller = this.get('controller'),
- data = { view: this, buffer: buffer, isRenderData: true };
+ controller = this.get('controller');
+
+ var data = {
+ view: this,
+ buffer: buffer,
+ isRenderData: true,
+ keywords: {
+ view: get(this, 'concreteView')
+ }
+ };
// If the view has a controller specified, make it available to the
// template. If not, pass along the parent template's controller,
// if it exists.
- data.controller = controller || (templateData && templateData.controller);
+ data.keywords.controller = controller || (templateData && templateData.keywords.controller);
// Invoke the template with the provided template context, which
// is the view by default. A hash of data is also passed that provides | true |
Other | emberjs | ember.js | 208e498390b852f71e5fe6623a5b8d2dd4005c13.json | Normalize keyword paths so that observers work
In the previous implementation, observers would
not get set up correctly since root/path
combinations were not resolved to take into
account Handlebars keywords until getPath was
called.
In this commit, a separate method to normalize
root/path combinations is exposed and used when
setting up observers in BindableSpans. | packages/ember-views/tests/views/view/template_test.js | @@ -113,7 +113,7 @@ test("should provide a controller to the template if a controller is specified o
controller: controller1,
template: function(buffer, options) {
- strictEqual(options.data.controller, controller1, "passes the controller in the data");
+ strictEqual(options.data.keywords.controller, controller1, "passes the controller in the data");
}
});
@@ -131,10 +131,10 @@ test("should provide a controller to the template if a controller is specified o
controller: controller2,
templateData: options.data,
template: function(buffer, options) {
- strictEqual(options.data.controller, controller2, "passes the child view's controller in the data");
+ strictEqual(options.data.keywords.controller, controller2, "passes the child view's controller in the data");
}
}));
- strictEqual(options.data.controller, controller1, "passes the controller in the data");
+ strictEqual(options.data.keywords.controller, controller1, "passes the controller in the data");
}
});
@@ -151,11 +151,11 @@ test("should provide a controller to the template if a controller is specified o
options.data.view.appendChild(Ember.View.create({
templateData: options.data,
template: function(buffer, options) {
- strictEqual(options.data.controller, controller1, "passes the original controller in the data");
+ strictEqual(options.data.keywords.controller, controller1, "passes the original controller in the data");
}
}));
- strictEqual(options.data.controller, controller1, "passes the controller in the data to child views");
+ strictEqual(options.data.keywords.controller, controller1, "passes the controller in the data to child views");
}
});
| true |
Other | emberjs | ember.js | 687bdcb1758f7f9a4ba8828f794f5ab1f14f0537.json | Expose view and controller keywords to templates | packages/ember-handlebars/lib/controls/button.js | @@ -18,6 +18,20 @@ Ember.Button = Ember.View.extend(Ember.TargetActionSupport, {
attributeBindings: ['type', 'disabled', 'href'],
+ /** @private
+ Overrides TargetActionSupport's targetObject computed
+ property to use Handlebars-specific path resolution.
+ */
+ targetObject: Ember.computed(function() {
+ var target = get(this, 'target'),
+ root = get(this, 'templateContext'),
+ data = get(this, 'templateData');
+
+ if (typeof target !== 'string') { return target; }
+
+ return Ember.Handlebars.getPath(root, target, { data: data });
+ }).property('target').cacheable(),
+
// Defaults to 'button' if tagName is 'input' or 'button'
type: Ember.computed(function(key, value) {
var tagName = this.get('tagName'); | true |
Other | emberjs | ember.js | 687bdcb1758f7f9a4ba8828f794f5ab1f14f0537.json | Expose view and controller keywords to templates | packages/ember-handlebars/lib/ext.js | @@ -129,14 +129,58 @@ Ember.Handlebars.compile = function(string) {
};
/**
- Lookup both on root and on window
+ Lookup both on root and on window. If the path starts with
+ a keyword, the corresponding object will be looked up in the
+ template's data hash and used to resolve the path.
@param {Object} root The object to look up the property on
@param {String} path The path to be lookedup
+ @param {Object} options The template's option hash
*/
-Ember.Handlebars.getPath = function(root, path) {
- // TODO: Remove this `false` when the `getPath` globals support is removed
- var value = Ember.getPath(root, path, false);
+
+// Regular expression used to determine if a path starts
+// with a reserved word, and if so, which reserved word it
+// is.
+var KEYWORD_REGEX = Ember.Handlebars.KEYWORD_REGEX = /^(controller|view)\.?/;
+
+Ember.Handlebars.getPath = function(root, path, options) {
+ var data = options.data,
+ value, keyword;
+
+ // Test to see if the path starts with a keyword.
+ // For example, "controller.foo.bar"
+ if (data && KEYWORD_REGEX.test(path)) {
+
+ // We used a fast (non-extracting) test above
+ // to reduce the performance hit for paths that
+ // do not contain keywords. Now that we know that
+ // we match, extract the keyword from the string.
+ keyword = path.match(KEYWORD_REGEX)[1];
+
+ // Look up the value in the template's data hash.
+ root = data[keyword];
+
+ // Make sure we don't expose virtual views to the
+ // user.
+ if (root.isView) {
+ root = root.get('concreteView');
+ }
+
+ // Handle cases where the entire path is the reserved
+ // word. In that case, return the object itself.
+ if (path === keyword) {
+ value = root;
+ } else {
+ // Strip the keyword from the path and look up
+ // the remainder from the newly found root.
+ path = path.substr(keyword.length);
+ value = Ember.getPath(root, path, false);
+ }
+ } else {
+ // TODO: Remove this `false` when the `getPath` globals support is removed
+ value = Ember.getPath(root, path, false);
+ }
+
if (value === undefined && root !== window && Ember.isGlobalPath(path)) {
value = Ember.getPath(window, path);
} | true |
Other | emberjs | ember.js | 687bdcb1758f7f9a4ba8828f794f5ab1f14f0537.json | Expose view and controller keywords to templates | packages/ember-handlebars/lib/helpers/action.js | @@ -1,6 +1,6 @@
require('ember-handlebars/ext');
-var EmberHandlebars = Ember.Handlebars, getPath = Ember.Handlebars.getPath;
+var EmberHandlebars = Ember.Handlebars, getPath = EmberHandlebars.getPath;
var ActionHelper = EmberHandlebars.ActionHelper = {
registeredActions: {}
@@ -38,7 +38,7 @@ EmberHandlebars.registerHelper('action', function(actionName, options) {
target, context;
if (view.isVirtual) { view = view.get('parentView'); }
- target = hash.target ? getPath(this, hash.target) : view;
+ target = hash.target ? getPath(this, hash.target, options) : view;
context = options.contexts[0];
var actionId = ActionHelper.registerAction(actionName, eventName, target, view, context); | true |
Other | emberjs | ember.js | 687bdcb1758f7f9a4ba8828f794f5ab1f14f0537.json | Expose view and controller keywords to templates | packages/ember-handlebars/lib/helpers/binding.js | @@ -36,7 +36,8 @@ var EmberHandlebars = Ember.Handlebars, helpers = EmberHandlebars.helpers;
inverseTemplate: inverse,
property: property,
previousContext: ctx,
- isEscaped: options.hash.escaped
+ isEscaped: options.hash.escaped,
+ templateData: options.data
});
view.appendChild(bindView);
@@ -56,7 +57,7 @@ var EmberHandlebars = Ember.Handlebars, helpers = EmberHandlebars.helpers;
} else {
// The object is not observable, so just render it out and
// be done with it.
- data.buffer.push(getPath(this, property));
+ data.buffer.push(getPath(this, property, options));
}
};
@@ -215,7 +216,7 @@ EmberHandlebars.registerHelper('bindAttr', function(options) {
// Handle classes differently, as we can bind multiple classes
var classBindings = attrs['class'];
if (classBindings !== null && classBindings !== undefined) {
- var classResults = EmberHandlebars.bindClasses(this, classBindings, view, dataId);
+ var classResults = EmberHandlebars.bindClasses(this, classBindings, view, dataId, options);
ret.push('class="' + classResults.join(' ') + '"');
delete attrs['class'];
}
@@ -229,7 +230,7 @@ EmberHandlebars.registerHelper('bindAttr', function(options) {
ember_assert(fmt("You must provide a String for a bound attribute, not %@", [property]), typeof property === 'string');
- var value = (property === 'this') ? ctx : getPath(ctx, property),
+ var value = (property === 'this') ? ctx : getPath(ctx, property, options),
type = Ember.typeOf(value);
ember_assert(fmt("Attributes must be numbers, strings or booleans, not %@", [value]), value === null || value === undefined || type === 'number' || type === 'string' || type === 'boolean');
@@ -238,7 +239,7 @@ EmberHandlebars.registerHelper('bindAttr', function(options) {
/** @private */
observer = function observer() {
- var result = getPath(ctx, property);
+ var result = getPath(ctx, property, options);
ember_assert(fmt("Attributes must be numbers, strings or booleans, not %@", [result]), result === null || result === undefined || typeof result === 'number' || typeof result === 'string' || typeof result === 'boolean');
@@ -308,7 +309,7 @@ EmberHandlebars.registerHelper('bindAttr', function(options) {
@returns {Array} An array of class names to add
*/
-EmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId) {
+EmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId, options) {
var ret = [], newClass, value, elem;
// Helper method to retrieve the property from the context and
@@ -320,7 +321,7 @@ EmberHandlebars.bindClasses = function(context, classBindings, view, bindAttrId)
property = split[0];
- var val = property !== '' ? getPath(context, property) : true;
+ var val = property !== '' ? getPath(context, property, options) : true;
// If value is a Boolean and true, return the dasherized property
// name. | true |
Other | emberjs | ember.js | 687bdcb1758f7f9a4ba8828f794f5ab1f14f0537.json | Expose view and controller keywords to templates | packages/ember-handlebars/lib/helpers/collection.js | @@ -34,7 +34,7 @@ Ember.Handlebars.registerHelper('collection', function(path, options) {
// If passed a path string, convert that into an object.
// Otherwise, just default to the standard class.
var collectionClass;
- collectionClass = path ? getPath(this, path) : Ember.CollectionView;
+ collectionClass = path ? getPath(this, path, options) : Ember.CollectionView;
ember_assert(fmt("%@ #collection: Could not find %@", data.view, path), !!collectionClass);
var hash = options.hash, itemHash = {}, match;
@@ -43,7 +43,7 @@ Ember.Handlebars.registerHelper('collection', function(path, options) {
var itemViewClass, itemViewPath = hash.itemViewClass;
var collectionPrototype = collectionClass.proto();
delete hash.itemViewClass;
- itemViewClass = itemViewPath ? getPath(collectionPrototype, itemViewPath) : collectionPrototype.itemViewClass;
+ itemViewClass = itemViewPath ? getPath(collectionPrototype, itemViewPath, options) : collectionPrototype.itemViewClass;
ember_assert(fmt("%@ #collection: Could not find %@", data.view, itemViewPath), !!itemViewClass);
// Go through options passed to the {{collection}} helper and extract options
@@ -74,7 +74,7 @@ Ember.Handlebars.registerHelper('collection', function(path, options) {
if (hash.emptyViewClass) {
emptyViewClass = Ember.View.detect(hash.emptyViewClass) ?
- hash.emptyViewClass : getPath(this, hash.emptyViewClass);
+ hash.emptyViewClass : getPath(this, hash.emptyViewClass, options);
}
hash.emptyView = emptyViewClass.extend({ | true |
Other | emberjs | ember.js | 687bdcb1758f7f9a4ba8828f794f5ab1f14f0537.json | Expose view and controller keywords to templates | packages/ember-handlebars/lib/helpers/unbound.js | @@ -21,5 +21,5 @@ var getPath = Ember.Handlebars.getPath;
*/
Ember.Handlebars.registerHelper('unbound', function(property, fn) {
var context = (fn.contexts && fn.contexts[0]) || this;
- return getPath(context, property);
+ return getPath(context, property, fn);
}); | true |
Other | emberjs | ember.js | 687bdcb1758f7f9a4ba8828f794f5ab1f14f0537.json | Expose view and controller keywords to templates | packages/ember-handlebars/lib/helpers/view.js | @@ -11,9 +11,10 @@ require("ember-handlebars");
var get = Ember.get, set = Ember.set;
var indexOf = Ember.ArrayUtils.indexOf;
var PARENT_VIEW_PATH = /^parentView\./;
+var EmberHandlebars = Ember.Handlebars;
/** @private */
-Ember.Handlebars.ViewHelper = Ember.Object.create({
+EmberHandlebars.ViewHelper = Ember.Object.create({
viewClassFromHTMLOptions: function(viewClass, options, thisContext) {
var extensions = {},
@@ -65,7 +66,10 @@ Ember.Handlebars.ViewHelper = Ember.Object.create({
// Test if the property ends in "Binding"
if (Ember.IS_BINDING.test(prop)) {
path = options[prop];
- if (!Ember.isGlobalPath(path)) {
+
+ if (EmberHandlebars.KEYWORD_REGEX.test(path)) {
+ options[prop] = 'templateData.'+path;
+ } else if (!Ember.isGlobalPath(path)) {
if (path === 'this') {
options[prop] = 'bindingContext';
} else {
@@ -91,7 +95,7 @@ Ember.Handlebars.ViewHelper = Ember.Object.create({
newView;
if ('string' === typeof path) {
- newView = Ember.Handlebars.getPath(thisContext, path);
+ newView = EmberHandlebars.getPath(thisContext, path, options);
ember_assert("Unable to find view at path '" + path + "'", !!newView);
} else {
newView = path;
@@ -101,7 +105,9 @@ Ember.Handlebars.ViewHelper = Ember.Object.create({
newView = this.viewClassFromHTMLOptions(newView, hash, thisContext);
var currentView = data.view;
- var viewOptions = {};
+ var viewOptions = {
+ templateData: options.data
+ };
if (fn) {
ember_assert("You cannot provide a template block if you also specified a templateName", !(get(viewOptions, 'templateName')) && (indexOf(newView.PrototypeMixin.keys(), 'templateName') >= 0));
@@ -118,7 +124,7 @@ Ember.Handlebars.ViewHelper = Ember.Object.create({
@param {Hash} options
@returns {String} HTML string
*/
-Ember.Handlebars.registerHelper('view', function(path, options) {
+EmberHandlebars.registerHelper('view', function(path, options) {
ember_assert("The view helper only takes a single argument", arguments.length <= 2);
// If no path is provided, treat path param as options.
@@ -127,6 +133,6 @@ Ember.Handlebars.registerHelper('view', function(path, options) {
path = "Ember.View";
}
- return Ember.Handlebars.ViewHelper.helper(this, path, options);
+ return EmberHandlebars.ViewHelper.helper(this, path, options);
});
| true |
Other | emberjs | ember.js | 687bdcb1758f7f9a4ba8828f794f5ab1f14f0537.json | Expose view and controller keywords to templates | packages/ember-handlebars/lib/views/bindable_span.js | @@ -84,14 +84,15 @@ Ember._BindableSpanView = Ember.View.extend(Ember.Metamorph,
var property = get(this, 'property'),
context = get(this, 'previousContext'),
valueNormalizer = get(this, 'valueNormalizerFunc'),
- result;
+ result, templateData;
// Use the current context as the result if no
// property is provided.
if (property === '') {
result = context;
} else {
- result = getPath(context, property);
+ templateData = get(this, 'templateData');
+ result = getPath(context, property, { data: templateData });
}
return valueNormalizer ? valueNormalizer(result) : result; | true |
Other | emberjs | ember.js | 687bdcb1758f7f9a4ba8828f794f5ab1f14f0537.json | Expose view and controller keywords to templates | packages/ember-handlebars/tests/handlebars_test.js | @@ -1393,6 +1393,77 @@ test("should work with precompiled templates", function() {
equal(view.$().text(), "updated", "the precompiled template was updated");
});
+test("should expose a controller keyword when present on the view", function() {
+ var templateString = "{{controller.foo}}{{#view}}{{controller.baz}}{{/view}}";
+ view = Ember.View.create({
+ controller: Ember.Object.create({
+ foo: "bar",
+ baz: "bang"
+ }),
+
+ template: Ember.Handlebars.compile(templateString)
+ });
+
+ Ember.run(function() {
+ view.appendTo("#qunit-fixture");
+ });
+
+ equal(view.$().text(), "barbang", "renders values from controller and parent controller");
+
+ view.destroy();
+
+ view = Ember.View.create({
+ controller: "aString",
+ template: Ember.Handlebars.compile("{{controller}}")
+ });
+
+ Ember.run(function() {
+ view.appendTo('#qunit-fixture');
+ });
+
+ equal(view.$().text(), "aString", "renders the controller itself if no additional path is specified");
+});
+
+test("should expose a view keyword", function() {
+ var templateString = '{{#with differentContent}}{{view.foo}}{{#view baz="bang"}}{{view.baz}}{{/view}}{{/with}}';
+ view = Ember.View.create({
+ differentContent: {
+ view: {
+ foo: "WRONG",
+ baz: "WRONG"
+ }
+ },
+
+ foo: "bar",
+
+ template: Ember.Handlebars.compile(templateString)
+ });
+
+ Ember.run(function() {
+ view.appendTo("#qunit-fixture");
+ });
+
+ equal(view.$().text(), "barbang", "renders values from view and child view");
+});
+
+test("Ember.Button targets should respect keywords", function() {
+ var templateString = '{{#with anObject}}{{view Ember.Button target="controller.foo"}}{{/with}}';
+ view = Ember.View.create({
+ template: Ember.Handlebars.compile(templateString),
+ anObject: {},
+ controller: {
+ foo: "bar"
+ }
+ });
+
+ Ember.run(function() {
+ view.appendTo('#qunit-fixture');
+ });
+
+ var button = view.get('childViews').objectAt(0);
+ equal(button.get('targetObject'), "bar", "resolves the target");
+});
+
module("Templates redrawing and bindings", {
setup: function(){
MyApp = Ember.Object.create({});
@@ -1516,6 +1587,31 @@ test("bindings should be relative to the current context", function() {
equal(Ember.$.trim(view.$().text()), "Name: SFMoMA Price: $20", "should print baz twice");
});
+test("bindings should respect keywords", function() {
+ view = Ember.View.create({
+ museumOpen: true,
+
+ controller: {
+ museumDetails: Ember.Object.create({
+ name: "SFMoMA",
+ price: 20
+ })
+ },
+
+ museumView: Ember.View.extend({
+ template: Ember.Handlebars.compile('Name: {{name}} Price: ${{dollars}}')
+ }),
+
+ template: Ember.Handlebars.compile('{{#if museumOpen}}{{view museumView nameBinding="controller.museumDetails.name" dollarsBinding="controller.museumDetails.price"}}{{/if}}')
+ });
+
+ Ember.run(function() {
+ view.appendTo('#qunit-fixture');
+ });
+
+ equal(Ember.$.trim(view.$().text()), "Name: SFMoMA Price: $20", "should print baz twice");
+});
+
test("bindings can be 'this', in which case they *are* the current context", function() {
view = Ember.View.create({
museumOpen: true, | true |
Other | emberjs | ember.js | 8cf25fff49dd6405aa1df2453397554540205149.json | update jquery references
add jquery note to Rakefile | Rakefile | @@ -304,6 +304,7 @@ task :test, [:suite] => :dist do |t, args|
suites = {
:default => ["package=all"],
+ # testing older jQuery 1.6.4 for compatibility
:all => ["package=all",
"package=all&jquery=1.6.4&nojshint=true",
"package=all&extendprototypes=true&nojshint=true", | true |
Other | emberjs | ember.js | 8cf25fff49dd6405aa1df2453397554540205149.json | update jquery references
add jquery note to Rakefile | benchmarks/external/backbone.html | @@ -2,7 +2,7 @@
<html>
<head>
- <script src="../../tests/jquery-1.7.1.js"></script>
+ <script src="../../tests/jquery-1.7.2.js"></script>
<style>
p { | true |
Other | emberjs | ember.js | 8cf25fff49dd6405aa1df2453397554540205149.json | update jquery references
add jquery note to Rakefile | benchmarks/index.html | @@ -2,7 +2,7 @@
<html>
<head>
- <script src="../tests/jquery-1.7.1.js"></script>
+ <script src="../tests/jquery-1.7.2.js"></script>
<script src="benchmark.js"></script>
<script src="runner.js"></script>
</head> | true |
Other | emberjs | ember.js | 8cf25fff49dd6405aa1df2453397554540205149.json | update jquery references
add jquery note to Rakefile | benchmarks/runner.js | @@ -13,7 +13,7 @@ function makeiframe(emberPath, suitePath, profile, callback) {
iframe.name = name;
write("<title>" + name + "</title>");
- write("<script src='../tests/jquery-1.7.1.js'></script>");
+ write("<script src='../tests/jquery-1.7.2.js'></script>");
write("<script src='" + emberPath + "'></script>");
write("<script src='benchmark.js'></script>");
write("<script src='iframe_runner.js'></script>"); | true |
Other | emberjs | ember.js | 8cf25fff49dd6405aa1df2453397554540205149.json | update jquery references
add jquery note to Rakefile | benchmarks/setup.markdown | @@ -3,7 +3,7 @@ Files:
* `index.html`: bootstrap file for testing
* `ember-before.js`: the Ember file that represents the "before" in the test
* `../dist/ember.min.js`: the Ember file that represents the "after" in the test
-* `../tests/jquery-1.7.1.js`: the latest version of jQuery
+* `../tests/jquery-1.7.2.js`: the latest version of jQuery
* `benchmark.js`: the benchmark JS runner
* `nano.jar`: the nanosecond timer
* `runner.js`: the bootstrap for the runner | true |
Other | emberjs | ember.js | 8cf25fff49dd6405aa1df2453397554540205149.json | update jquery references
add jquery note to Rakefile | benchmarks/simple.html | @@ -2,7 +2,7 @@
<html>
<head>
- <script src="../tests/jquery-1.7.1.js"></script>
+ <script src="../tests/jquery-1.7.2.js"></script>
<script src="ember.js"></script>
</head>
<body> | true |
Other | emberjs | ember.js | 8cf25fff49dd6405aa1df2453397554540205149.json | update jquery references
add jquery note to Rakefile | tests/index.html | @@ -60,7 +60,7 @@ <h2 id="qunit-userAgent"></h2>
<script>
// Load custom version of jQuery if possible
var jQueryMatch = location.search.match(/jquery=([^&]+)/),
- jQueryVersion = jQueryMatch ? jQueryMatch[1] : "1.7.1";
+ jQueryVersion = jQueryMatch ? jQueryMatch[1] : "1.7.2";
if (jQueryVersion !== 'none') {
document.write(unescape('%3Cscript src="http://ajax.googleapis.com/ajax/libs/jquery/'+jQueryVersion+'/jquery.js"%3E%3C/script%3E'));
}
@@ -71,7 +71,7 @@ <h2 id="qunit-userAgent"></h2>
// Fallback to default jQuery
if (jQueryVersion !== 'none' && !window.jQuery) {
if (console && console.warn) { console.warn("Unable to load jQuery "+jQueryVersion+". Using default."); }
- document.write(unescape('%3Cscript src="jquery-1.7.1.js"%3E%3C/script%3E'));
+ document.write(unescape('%3Cscript src="jquery-1.7.2.js"%3E%3C/script%3E'));
}
// Close the script tag to make sure document.write happens
</script> | true |
Other | emberjs | ember.js | 98a1c9fd05bbcfdf7c8b50377ce7c76e7ae9b480.json | update jquery code | tests/jquery-1.7.1.js | @@ -1,5 +1,5 @@
/*!
- * jQuery JavaScript Library v1.7.1
+ * jQuery JavaScript Library v1.7.2
* http://jquery.com/
*
* Copyright 2011, John Resig
@@ -11,7 +11,7 @@
* Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
*
- * Date: Mon Nov 21 21:11:03 2011 -0500
+ * Date: Wed Mar 21 12:46:34 2012 -0700
*/
(function( window, undefined ) {
@@ -210,7 +210,7 @@ jQuery.fn = jQuery.prototype = {
selector: "",
// The current version of jQuery being used
- jquery: "1.7.1",
+ jquery: "1.7.2",
// The default length of a jQuery object is 0
length: 0,
@@ -497,9 +497,8 @@ jQuery.extend({
return jQuery.type(obj) === "array";
},
- // A crude way of determining if an object is a window
isWindow: function( obj ) {
- return obj && typeof obj === "object" && "setInterval" in obj;
+ return obj != null && obj == obj.window;
},
isNumeric: function( obj ) {
@@ -579,6 +578,9 @@ jQuery.extend({
// Cross-browser xml parsing
parseXML: function( data ) {
+ if ( typeof data !== "string" || !data ) {
+ return null;
+ }
var xml, tmp;
try {
if ( window.DOMParser ) { // Standard
@@ -822,31 +824,55 @@ jQuery.extend({
// Mutifunctional method to get and set values to a collection
// The value/s can optionally be executed if it's a function
- access: function( elems, key, value, exec, fn, pass ) {
- var length = elems.length;
+ access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
+ var exec,
+ bulk = key == null,
+ i = 0,
+ length = elems.length;
- // Setting many attributes
- if ( typeof key === "object" ) {
- for ( var k in key ) {
- jQuery.access( elems, k, key[k], exec, fn, value );
+ // Sets many values
+ if ( key && typeof key === "object" ) {
+ for ( i in key ) {
+ jQuery.access( elems, fn, i, key[i], 1, emptyGet, value );
}
- return elems;
- }
+ chainable = 1;
- // Setting one attribute
- if ( value !== undefined ) {
+ // Sets one value
+ } else if ( value !== undefined ) {
// Optionally, function values get executed if exec is true
- exec = !pass && exec && jQuery.isFunction(value);
+ exec = pass === undefined && jQuery.isFunction( value );
+
+ if ( bulk ) {
+ // Bulk operations only iterate when executing function values
+ if ( exec ) {
+ exec = fn;
+ fn = function( elem, key, value ) {
+ return exec.call( jQuery( elem ), value );
+ };
+
+ // Otherwise they run against the entire set
+ } else {
+ fn.call( elems, value );
+ fn = null;
+ }
+ }
- for ( var i = 0; i < length; i++ ) {
- fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ if ( fn ) {
+ for (; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
}
- return elems;
+ chainable = 1;
}
- // Getting an attribute
- return length ? fn( elems[0], key ) : undefined;
+ return chainable ?
+ elems :
+
+ // Gets
+ bulk ?
+ fn.call( elems ) :
+ length ? fn( elems[0], key ) : emptyGet;
},
now: function() {
@@ -1005,6 +1031,8 @@ jQuery.Callbacks = function( flags ) {
stack = [],
// Last fire value (for non-forgettable lists)
memory,
+ // Flag to know if list was already fired
+ fired,
// Flag to know if list is currently firing
firing,
// First callback to fire (used internally by add and fireWith)
@@ -1038,6 +1066,7 @@ jQuery.Callbacks = function( flags ) {
fire = function( context, args ) {
args = args || [];
memory = !flags.memory || [ context, args ];
+ fired = true;
firing = true;
firingIndex = firingStart || 0;
firingStart = 0;
@@ -1173,7 +1202,7 @@ jQuery.Callbacks = function( flags ) {
},
// To know if the callbacks have already been called at least once
fired: function() {
- return !!memory;
+ return !!fired;
}
};
@@ -1336,7 +1365,6 @@ jQuery.support = (function() {
select,
opt,
input,
- marginDiv,
fragment,
tds,
events,
@@ -1419,9 +1447,13 @@ jQuery.support = (function() {
noCloneEvent: true,
inlineBlockNeedsLayout: false,
shrinkWrapBlocks: false,
- reliableMarginRight: true
+ reliableMarginRight: true,
+ pixelMargin: true
};
+ // jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead
+ jQuery.boxModel = support.boxModel = (document.compatMode === "CSS1Compat");
+
// Make sure checked status is properly cloned
input.checked = true;
support.noCloneChecked = input.cloneNode( true ).checked;
@@ -1456,6 +1488,10 @@ jQuery.support = (function() {
support.radioValue = input.value === "t";
input.setAttribute("checked", "checked");
+
+ // #11217 - WebKit loses check when the name is after the checked attribute
+ input.setAttribute( "name", "t" );
+
div.appendChild( input );
fragment = document.createDocumentFragment();
fragment.appendChild( div.lastChild );
@@ -1470,31 +1506,14 @@ jQuery.support = (function() {
fragment.removeChild( input );
fragment.appendChild( div );
- div.innerHTML = "";
-
- // Check if div with explicit width and no margin-right incorrectly
- // gets computed margin-right based on width of container. For more
- // info see bug #3333
- // Fails in WebKit before Feb 2011 nightlies
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
- if ( window.getComputedStyle ) {
- marginDiv = document.createElement( "div" );
- marginDiv.style.width = "0";
- marginDiv.style.marginRight = "0";
- div.style.width = "2px";
- div.appendChild( marginDiv );
- support.reliableMarginRight =
- ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
- }
-
// Technique from Juriy Zaytsev
// http://perfectionkills.com/detecting-event-support-without-browser-sniffing/
// We only care about the case where non-standard event systems
// are used, namely in IE. Short-circuiting here helps us to
// avoid an eval call (in setAttribute) which can cause CSP
// to go haywire. See: https://developer.mozilla.org/en/Security/CSP
if ( div.attachEvent ) {
- for( i in {
+ for ( i in {
submit: 1,
change: 1,
focusin: 1
@@ -1512,12 +1531,13 @@ jQuery.support = (function() {
fragment.removeChild( div );
// Null elements to avoid leaks in IE
- fragment = select = opt = marginDiv = div = input = null;
+ fragment = select = opt = div = input = null;
// Run tests that need a body at doc ready
jQuery(function() {
var container, outer, inner, table, td, offsetSupport,
- conMarginTop, ptlm, vb, style, html,
+ marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight,
+ paddingMarginBorderVisibility, paddingMarginBorder,
body = document.getElementsByTagName("body")[0];
if ( !body ) {
@@ -1526,15 +1546,16 @@ jQuery.support = (function() {
}
conMarginTop = 1;
- ptlm = "position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";
- vb = "visibility:hidden;border:0;";
- style = "style='" + ptlm + "border:5px solid #000;padding:0;'";
- html = "<div " + style + "><div></div></div>" +
- "<table " + style + " cellpadding='0' cellspacing='0'>" +
+ paddingMarginBorder = "padding:0;margin:0;border:";
+ positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;";
+ paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;";
+ style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;";
+ html = "<div " + style + "display:block;'><div style='" + paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" +
+ "<table " + style + "' cellpadding='0' cellspacing='0'>" +
"<tr><td></td></tr></table>";
container = document.createElement("div");
- container.style.cssText = vb + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
+ container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px";
body.insertBefore( container, body.firstChild );
// Construct the test element
@@ -1548,7 +1569,7 @@ jQuery.support = (function() {
// display:none (it is still safe to use offsets if a parent element is
// hidden; don safety goggles and see bug #4512 for more information).
// (only IE 8 fails this test)
- div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
+ div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "0;display:none'></td><td>t</td></tr></table>";
tds = div.getElementsByTagName( "td" );
isSupported = ( tds[ 0 ].offsetHeight === 0 );
@@ -1559,28 +1580,44 @@ jQuery.support = (function() {
// (IE <= 8 fail this test)
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
- // Figure out if the W3C box model works as expected
- div.innerHTML = "";
- div.style.width = div.style.paddingLeft = "1px";
- jQuery.boxModel = support.boxModel = div.offsetWidth === 2;
+ // Check if div with explicit width and no margin-right incorrectly
+ // gets computed margin-right based on width of container. For more
+ // info see bug #3333
+ // Fails in WebKit before Feb 2011 nightlies
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ if ( window.getComputedStyle ) {
+ div.innerHTML = "";
+ marginDiv = document.createElement( "div" );
+ marginDiv.style.width = "0";
+ marginDiv.style.marginRight = "0";
+ div.style.width = "2px";
+ div.appendChild( marginDiv );
+ support.reliableMarginRight =
+ ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
+ }
if ( typeof div.style.zoom !== "undefined" ) {
// Check if natively block-level elements act like inline-block
// elements when setting their display to 'inline' and giving
// them layout
// (IE < 8 does this)
+ div.innerHTML = "";
+ div.style.width = div.style.padding = "1px";
+ div.style.border = 0;
+ div.style.overflow = "hidden";
div.style.display = "inline";
div.style.zoom = 1;
- support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
+ support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
// Check if elements with layout shrink-wrap their children
// (IE 6 does this)
- div.style.display = "";
- div.innerHTML = "<div style='width:4px;'></div>";
- support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
+ div.style.display = "block";
+ div.style.overflow = "visible";
+ div.innerHTML = "<div style='width:5px;'></div>";
+ support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
}
- div.style.cssText = ptlm + vb;
+ div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility;
div.innerHTML = html;
outer = div.firstChild;
@@ -1605,8 +1642,17 @@ jQuery.support = (function() {
offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 );
offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop );
+ if ( window.getComputedStyle ) {
+ div.style.marginTop = "1%";
+ support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%";
+ }
+
+ if ( typeof container.style.zoom !== "undefined" ) {
+ container.style.zoom = 1;
+ }
+
body.removeChild( container );
- div = container = null;
+ marginDiv = div = container = null;
jQuery.extend( support, offsetSupport );
});
@@ -1863,62 +1909,70 @@ jQuery.extend({
jQuery.fn.extend({
data: function( key, value ) {
- var parts, attr, name,
+ var parts, part, attr, name, l,
+ elem = this[0],
+ i = 0,
data = null;
- if ( typeof key === "undefined" ) {
+ // Gets all values
+ if ( key === undefined ) {
if ( this.length ) {
- data = jQuery.data( this[0] );
+ data = jQuery.data( elem );
- if ( this[0].nodeType === 1 && !jQuery._data( this[0], "parsedAttrs" ) ) {
- attr = this[0].attributes;
- for ( var i = 0, l = attr.length; i < l; i++ ) {
+ if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
+ attr = elem.attributes;
+ for ( l = attr.length; i < l; i++ ) {
name = attr[i].name;
if ( name.indexOf( "data-" ) === 0 ) {
name = jQuery.camelCase( name.substring(5) );
- dataAttr( this[0], name, data[ name ] );
+ dataAttr( elem, name, data[ name ] );
}
}
- jQuery._data( this[0], "parsedAttrs", true );
+ jQuery._data( elem, "parsedAttrs", true );
}
}
return data;
+ }
- } else if ( typeof key === "object" ) {
+ // Sets multiple values
+ if ( typeof key === "object" ) {
return this.each(function() {
jQuery.data( this, key );
});
}
- parts = key.split(".");
+ parts = key.split( ".", 2 );
parts[1] = parts[1] ? "." + parts[1] : "";
+ part = parts[1] + "!";
- if ( value === undefined ) {
- data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+ return jQuery.access( this, function( value ) {
- // Try to fetch any internally stored data first
- if ( data === undefined && this.length ) {
- data = jQuery.data( this[0], key );
- data = dataAttr( this[0], key, data );
- }
+ if ( value === undefined ) {
+ data = this.triggerHandler( "getData" + part, [ parts[0] ] );
- return data === undefined && parts[1] ?
- this.data( parts[0] ) :
- data;
+ // Try to fetch any internally stored data first
+ if ( data === undefined && elem ) {
+ data = jQuery.data( elem, key );
+ data = dataAttr( elem, key, data );
+ }
- } else {
- return this.each(function() {
- var self = jQuery( this ),
- args = [ parts[0], value ];
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+ }
- self.triggerHandler( "setData" + parts[1] + "!", args );
+ parts[1] = value;
+ this.each(function() {
+ var self = jQuery( this );
+
+ self.triggerHandler( "setData" + part, parts );
jQuery.data( this, key, value );
- self.triggerHandler( "changeData" + parts[1] + "!", args );
+ self.triggerHandler( "changeData" + part, parts );
});
- }
+ }, null, value, arguments.length > 1, null, false );
},
removeData: function( key ) {
@@ -1942,7 +1996,7 @@ function dataAttr( elem, key, data ) {
data = data === "true" ? true :
data === "false" ? false :
data === "null" ? null :
- jQuery.isNumeric( data ) ? parseFloat( data ) :
+ jQuery.isNumeric( data ) ? +data :
rbrace.test( data ) ? jQuery.parseJSON( data ) :
data;
} catch( e ) {}
@@ -2077,21 +2131,27 @@ jQuery.extend({
jQuery.fn.extend({
queue: function( type, data ) {
+ var setter = 2;
+
if ( typeof type !== "string" ) {
data = type;
type = "fx";
+ setter--;
}
- if ( data === undefined ) {
+ if ( arguments.length < setter ) {
return jQuery.queue( this[0], type );
}
- return this.each(function() {
- var queue = jQuery.queue( this, type, data );
- if ( type === "fx" && queue[0] !== "inprogress" ) {
- jQuery.dequeue( this, type );
- }
- });
+ return data === undefined ?
+ this :
+ this.each(function() {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
},
dequeue: function( type ) {
return this.each(function() {
@@ -2145,7 +2205,7 @@ jQuery.fn.extend({
}
}
resolve();
- return defer.promise();
+ return defer.promise( object );
}
});
@@ -2164,7 +2224,7 @@ var rclass = /[\n\t\r]/g,
jQuery.fn.extend({
attr: function( name, value ) {
- return jQuery.access( this, name, value, true, jQuery.attr );
+ return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 );
},
removeAttr: function( name ) {
@@ -2174,7 +2234,7 @@ jQuery.fn.extend({
},
prop: function( name, value ) {
- return jQuery.access( this, name, value, true, jQuery.prop );
+ return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 );
},
removeProp: function( name ) {
@@ -2314,7 +2374,7 @@ jQuery.fn.extend({
if ( !arguments.length ) {
if ( elem ) {
- hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
+ hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
return ret;
@@ -2358,7 +2418,7 @@ jQuery.fn.extend({
});
}
- hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
+ hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
// If set returns undefined, fall back to normal setting
if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
@@ -2504,7 +2564,7 @@ jQuery.extend({
},
removeAttr: function( elem, value ) {
- var propName, attrNames, name, l,
+ var propName, attrNames, name, l, isBool,
i = 0;
if ( value && elem.nodeType === 1 ) {
@@ -2516,13 +2576,17 @@ jQuery.extend({
if ( name ) {
propName = jQuery.propFix[ name ] || name;
+ isBool = rboolean.test( name );
// See #9699 for explanation of this approach (setting first, then removal)
- jQuery.attr( elem, name, "" );
+ // Do not do this for boolean attributes (see #10870)
+ if ( !isBool ) {
+ jQuery.attr( elem, name, "" );
+ }
elem.removeAttribute( getSetAttribute ? name : propName );
// Set corresponding property to false for boolean attributes
- if ( rboolean.test( name ) && propName in elem ) {
+ if ( isBool && propName in elem ) {
elem[ propName ] = false;
}
}
@@ -2676,7 +2740,8 @@ if ( !getSetAttribute ) {
fixSpecified = {
name: true,
- id: true
+ id: true,
+ coords: true
};
// Use this for any attribute in IE6/7
@@ -2806,7 +2871,7 @@ jQuery.each([ "radio", "checkbox" ], function() {
var rformElems = /^(?:textarea|input|select)$/i,
rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
- rhoverHack = /\bhover(\.\S+)?\b/,
+ rhoverHack = /(?:^|\s)hover(\.\S+)?\b/,
rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|contextmenu)|click/,
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
@@ -2854,6 +2919,7 @@ jQuery.event = {
if ( handler.handler ) {
handleObjIn = handler;
handler = handleObjIn.handler;
+ selector = handleObjIn.selector;
}
// Make sure that the handler has a unique ID, used to find/remove it later
@@ -2905,7 +2971,7 @@ jQuery.event = {
handler: handler,
guid: handler.guid,
selector: selector,
- quick: quickParse( selector ),
+ quick: selector && quickParse( selector ),
namespace: namespaces.join(".")
}, handleObjIn );
@@ -3194,41 +3260,51 @@ jQuery.event = {
delegateCount = handlers.delegateCount,
args = [].slice.call( arguments, 0 ),
run_all = !event.exclusive && !event.namespace,
+ special = jQuery.event.special[ event.type ] || {},
handlerQueue = [],
i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related;
// Use the fix-ed jQuery.Event rather than the (read-only) native event
args[0] = event;
event.delegateTarget = this;
+ // Call the preDispatch hook for the mapped type, and let it bail if desired
+ if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
+ return;
+ }
+
// Determine handlers that should run if there are delegated events
- // Avoid disabled elements in IE (#6911) and non-left-click bubbling in Firefox (#3861)
- if ( delegateCount && !event.target.disabled && !(event.button && event.type === "click") ) {
+ // Avoid non-left-click bubbling in Firefox (#3861)
+ if ( delegateCount && !(event.button && event.type === "click") ) {
// Pregenerate a single jQuery object for reuse with .is()
jqcur = jQuery(this);
jqcur.context = this.ownerDocument || this;
for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
- selMatch = {};
- matches = [];
- jqcur[0] = cur;
- for ( i = 0; i < delegateCount; i++ ) {
- handleObj = handlers[ i ];
- sel = handleObj.selector;
-
- if ( selMatch[ sel ] === undefined ) {
- selMatch[ sel ] = (
- handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )
- );
+
+ // Don't process events on disabled elements (#6911, #8165)
+ if ( cur.disabled !== true ) {
+ selMatch = {};
+ matches = [];
+ jqcur[0] = cur;
+ for ( i = 0; i < delegateCount; i++ ) {
+ handleObj = handlers[ i ];
+ sel = handleObj.selector;
+
+ if ( selMatch[ sel ] === undefined ) {
+ selMatch[ sel ] = (
+ handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel )
+ );
+ }
+ if ( selMatch[ sel ] ) {
+ matches.push( handleObj );
+ }
}
- if ( selMatch[ sel ] ) {
- matches.push( handleObj );
+ if ( matches.length ) {
+ handlerQueue.push({ elem: cur, matches: matches });
}
}
- if ( matches.length ) {
- handlerQueue.push({ elem: cur, matches: matches });
- }
}
}
@@ -3266,6 +3342,11 @@ jQuery.event = {
}
}
+ // Call the postDispatch hook for the mapped type
+ if ( special.postDispatch ) {
+ special.postDispatch.call( this, event );
+ }
+
return event.result;
},
@@ -3557,16 +3638,23 @@ if ( !jQuery.support.submitBubbles ) {
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
if ( form && !form._submit_attached ) {
jQuery.event.add( form, "submit._submit", function( event ) {
- // If form was submitted by the user, bubble the event up the tree
- if ( this.parentNode && !event.isTrigger ) {
- jQuery.event.simulate( "submit", this.parentNode, event, true );
- }
+ event._submit_bubble = true;
});
form._submit_attached = true;
}
});
// return undefined since we don't need an event listener
},
+
+ postDispatch: function( event ) {
+ // If form was submitted by the user, bubble the event up the tree
+ if ( event._submit_bubble ) {
+ delete event._submit_bubble;
+ if ( this.parentNode && !event.isTrigger ) {
+ jQuery.event.simulate( "submit", this.parentNode, event, true );
+ }
+ }
+ },
teardown: function() {
// Only need this for delegated form submit events
@@ -3671,9 +3759,9 @@ jQuery.fn.extend({
// Types can be a map of types/handlers
if ( typeof types === "object" ) {
// ( types-Object, selector, data )
- if ( typeof selector !== "string" ) {
+ if ( typeof selector !== "string" ) { // && selector != null
// ( types-Object, data )
- data = selector;
+ data = data || selector;
selector = undefined;
}
for ( type in types ) {
@@ -3719,14 +3807,14 @@ jQuery.fn.extend({
});
},
one: function( types, selector, data, fn ) {
- return this.on.call( this, types, selector, data, fn, 1 );
+ return this.on( types, selector, data, fn, 1 );
},
off: function( types, selector, fn ) {
if ( types && types.preventDefault && types.handleObj ) {
// ( event ) dispatched jQuery.Event
var handleObj = types.handleObj;
jQuery( types.delegateTarget ).off(
- handleObj.namespace? handleObj.type + "." + handleObj.namespace : handleObj.type,
+ handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
handleObj.selector,
handleObj.handler
);
@@ -3885,7 +3973,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
return [];
}
-
+
if ( !selector || typeof selector !== "string" ) {
return results;
}
@@ -3895,17 +3983,17 @@ var Sizzle = function( selector, context, results, seed ) {
contextXML = Sizzle.isXML( context ),
parts = [],
soFar = selector;
-
+
// Reset the position of the chunker regexp (start from head)
do {
chunker.exec( "" );
m = chunker.exec( soFar );
if ( m ) {
soFar = m[3];
-
+
parts.push( m[1] );
-
+
if ( m[2] ) {
extra = m[3];
break;
@@ -3929,7 +4017,7 @@ var Sizzle = function( selector, context, results, seed ) {
if ( Expr.relative[ selector ] ) {
selector += parts.shift();
}
-
+
set = posProcess( selector, set, seed );
}
}
@@ -4057,7 +4145,7 @@ Sizzle.find = function( expr, context, isXML ) {
for ( i = 0, len = Expr.order.length; i < len; i++ ) {
type = Expr.order[i];
-
+
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
left = match[1];
match.splice( 1, 1 );
@@ -4189,7 +4277,7 @@ var getText = Sizzle.getText = function( elem ) {
ret = "";
if ( nodeType ) {
- if ( nodeType === 1 || nodeType === 9 ) {
+ if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
// Use textContent || innerText for elements
if ( typeof elem.textContent === 'string' ) {
return elem.textContent;
@@ -4429,7 +4517,7 @@ var Expr = Sizzle.selectors = {
ATTR: function( match, curLoop, inplace, result, not, isXML ) {
var name = match[1] = match[1].replace( rBackslash, "" );
-
+
if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name];
}
@@ -4463,7 +4551,7 @@ var Expr = Sizzle.selectors = {
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
return true;
}
-
+
return match;
},
@@ -4473,7 +4561,7 @@ var Expr = Sizzle.selectors = {
return match;
}
},
-
+
filters: {
enabled: function( elem ) {
return elem.disabled === false && elem.type !== "hidden";
@@ -4486,14 +4574,14 @@ var Expr = Sizzle.selectors = {
checked: function( elem ) {
return elem.checked === true;
},
-
+
selected: function( elem ) {
// Accessing this property makes selected-by-default
// options in Safari work properly
if ( elem.parentNode ) {
elem.parentNode.selectedIndex;
}
-
+
return elem.selected === true;
},
@@ -4515,7 +4603,7 @@ var Expr = Sizzle.selectors = {
text: function( elem ) {
var attr = elem.getAttribute( "type" ), type = elem.type;
- // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
+ // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
},
@@ -4633,22 +4721,23 @@ var Expr = Sizzle.selectors = {
switch ( type ) {
case "only":
case "first":
- while ( (node = node.previousSibling) ) {
- if ( node.nodeType === 1 ) {
- return false;
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
}
}
- if ( type === "first" ) {
- return true;
+ if ( type === "first" ) {
+ return true;
}
node = elem;
+ /* falls through */
case "last":
- while ( (node = node.nextSibling) ) {
- if ( node.nodeType === 1 ) {
- return false;
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
}
}
@@ -4661,22 +4750,22 @@ var Expr = Sizzle.selectors = {
if ( first === 1 && last === 0 ) {
return true;
}
-
+
doneName = match[0];
parent = elem.parentNode;
-
+
if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) {
count = 0;
-
+
for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) {
node.nodeIndex = ++count;
}
- }
+ }
parent[ expando ] = doneName;
}
-
+
diff = elem.nodeIndex - last;
if ( first === 0 ) {
@@ -4695,7 +4784,7 @@ var Expr = Sizzle.selectors = {
TAG: function( elem, match ) {
return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match;
},
-
+
CLASS: function( elem, match ) {
return (" " + (elem.className || elem.getAttribute("class")) + " ")
.indexOf( match ) > -1;
@@ -4757,6 +4846,9 @@ for ( var type in Expr.match ) {
Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
}
+// Expose origPOS
+// "global" as in regardless of relation to brackets/parens
+Expr.match.globalPOS = origPOS;
var makeArray = function( array, results ) {
array = Array.prototype.slice.call( array, 0 );
@@ -4765,7 +4857,7 @@ var makeArray = function( array, results ) {
results.push.apply( results, array );
return results;
}
-
+
return array;
};
@@ -4997,7 +5089,7 @@ if ( document.querySelectorAll ) {
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return;
}
-
+
Sizzle = function( query, context, extra, seed ) {
context = context || document;
@@ -5006,24 +5098,24 @@ if ( document.querySelectorAll ) {
if ( !seed && !Sizzle.isXML(context) ) {
// See if we find a selector to speed up
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
-
+
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
// Speed-up: Sizzle("TAG")
if ( match[1] ) {
return makeArray( context.getElementsByTagName( query ), extra );
-
+
// Speed-up: Sizzle(".CLASS")
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
return makeArray( context.getElementsByClassName( match[2] ), extra );
}
}
-
+
if ( context.nodeType === 9 ) {
// Speed-up: Sizzle("body")
// The body element only exists once, optimize finding it
if ( query === "body" && context.body ) {
return makeArray( [ context.body ], extra );
-
+
// Speed-up: Sizzle("#ID")
} else if ( match && match[3] ) {
var elem = context.getElementById( match[3] );
@@ -5036,12 +5128,12 @@ if ( document.querySelectorAll ) {
if ( elem.id === match[3] ) {
return makeArray( [ elem ], extra );
}
-
+
} else {
return makeArray( [], extra );
}
}
-
+
try {
return makeArray( context.querySelectorAll(query), extra );
} catch(qsaError) {}
@@ -5079,7 +5171,7 @@ if ( document.querySelectorAll ) {
}
}
}
-
+
return oldSizzle(query, context, extra, seed);
};
@@ -5106,7 +5198,7 @@ if ( document.querySelectorAll ) {
// This should fail with an exception
// Gecko does not error, returns false instead
matches.call( document.documentElement, "[test!='']:sizzle" );
-
+
} catch( pseudoError ) {
pseudoWorks = true;
}
@@ -5116,7 +5208,7 @@ if ( document.querySelectorAll ) {
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
if ( !Sizzle.isXML( node ) ) {
- try {
+ try {
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
var ret = matches.call( node, expr );
@@ -5153,7 +5245,7 @@ if ( document.querySelectorAll ) {
if ( div.getElementsByClassName("e").length === 1 ) {
return;
}
-
+
Expr.order.splice(1, 0, "CLASS");
Expr.find.CLASS = function( match, context, isXML ) {
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
@@ -5204,7 +5296,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
if ( elem ) {
var match = false;
-
+
elem = elem[dir];
while ( elem ) {
@@ -5257,7 +5349,7 @@ if ( document.documentElement.contains ) {
Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist
- // (such as loading iframes in IE - #4833)
+ // (such as loading iframes in IE - #4833)
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
return documentElement ? documentElement.nodeName !== "HTML" : false;
@@ -5307,7 +5399,7 @@ var runtil = /Until$/,
rmultiselector = /,/,
isSimple = /^.[^:#\[\.,]*$/,
slice = Array.prototype.slice,
- POS = jQuery.expr.match.POS,
+ POS = jQuery.expr.match.globalPOS,
// methods guaranteed to produce a unique set when starting from a unique set
guaranteedUnique = {
children: true,
@@ -5374,19 +5466,19 @@ jQuery.fn.extend({
},
is: function( selector ) {
- return !!selector && (
+ return !!selector && (
typeof selector === "string" ?
// If this is a positional selector, check membership in the returned set
// so $("p:first").is("p:last") won't return true for a doc with two "p".
- POS.test( selector ) ?
+ POS.test( selector ) ?
jQuery( selector, this.context ).index( this[0] ) >= 0 :
jQuery.filter( selector, this ).length > 0 :
this.filter( selector ).length > 0 );
},
closest: function( selectors, context ) {
var ret = [], i, l, cur = this[0];
-
+
// Array (deprecated as of jQuery 1.7)
if ( jQuery.isArray( selectors ) ) {
var level = 1;
@@ -5505,7 +5597,7 @@ jQuery.each({
return jQuery.dir( elem, "previousSibling", until );
},
siblings: function( elem ) {
- return jQuery.sibling( elem.parentNode.firstChild, elem );
+ return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
},
children: function( elem ) {
return jQuery.sibling( elem.firstChild );
@@ -5639,7 +5731,7 @@ function createSafeFragment( document ) {
return safeFrag;
}
-var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|" +
+var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
"header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rleadingWhitespace = /^\s+/,
@@ -5649,7 +5741,7 @@ var nodeNames = "abbr|article|aside|audio|canvas|datalist|details|figcaption|fig
rhtml = /<|&#?\w+;/,
rnoInnerhtml = /<(?:script|style)/i,
rnocache = /<(?:script|object|embed|option|style)/i,
- rnoshimcache = new RegExp("<(?:" + nodeNames + ")", "i"),
+ rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
// checked="checked" or checked
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
rscriptType = /\/(java|ecma)script/i,
@@ -5676,20 +5768,12 @@ if ( !jQuery.support.htmlSerialize ) {
}
jQuery.fn.extend({
- text: function( text ) {
- if ( jQuery.isFunction(text) ) {
- return this.each(function(i) {
- var self = jQuery( this );
-
- self.text( text.call(this, i, self.text()) );
- });
- }
-
- if ( typeof text !== "object" && text !== undefined ) {
- return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
- }
-
- return jQuery.text( this );
+ text: function( value ) {
+ return jQuery.access( this, function( value ) {
+ return value === undefined ?
+ jQuery.text( this ) :
+ this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
+ }, null, value, arguments.length );
},
wrapAll: function( html ) {
@@ -5841,44 +5925,44 @@ jQuery.fn.extend({
},
html: function( value ) {
- if ( value === undefined ) {
- return this[0] && this[0].nodeType === 1 ?
- this[0].innerHTML.replace(rinlinejQuery, "") :
- null;
+ return jQuery.access( this, function( value ) {
+ var elem = this[0] || {},
+ i = 0,
+ l = this.length;
- // See if we can take a shortcut and just use innerHTML
- } else if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
- (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
- !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
+ if ( value === undefined ) {
+ return elem.nodeType === 1 ?
+ elem.innerHTML.replace( rinlinejQuery, "" ) :
+ null;
+ }
- value = value.replace(rxhtmlTag, "<$1></$2>");
- try {
- for ( var i = 0, l = this.length; i < l; i++ ) {
- // Remove element nodes and prevent memory leaks
- if ( this[i].nodeType === 1 ) {
- jQuery.cleanData( this[i].getElementsByTagName("*") );
- this[i].innerHTML = value;
- }
- }
+ if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
+ ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
+ !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
- // If using innerHTML throws an exception, use the fallback method
- } catch(e) {
- this.empty().append( value );
- }
+ value = value.replace( rxhtmlTag, "<$1></$2>" );
- } else if ( jQuery.isFunction( value ) ) {
- this.each(function(i){
- var self = jQuery( this );
+ try {
+ for (; i < l; i++ ) {
+ // Remove element nodes and prevent memory leaks
+ elem = this[i] || {};
+ if ( elem.nodeType === 1 ) {
+ jQuery.cleanData( elem.getElementsByTagName( "*" ) );
+ elem.innerHTML = value;
+ }
+ }
- self.html( value.call(this, i, self.html()) );
- });
+ elem = 0;
- } else {
- this.empty().append( value );
- }
+ // If using innerHTML throws an exception, use the fallback method
+ } catch(e) {}
+ }
- return this;
+ if ( elem ) {
+ this.empty().append( value );
+ }
+ }, null, value, arguments.length );
},
replaceWith: function( value ) {
@@ -5981,7 +6065,23 @@ jQuery.fn.extend({
}
if ( scripts.length ) {
- jQuery.each( scripts, evalScript );
+ jQuery.each( scripts, function( i, elem ) {
+ if ( elem.src ) {
+ jQuery.ajax({
+ type: "GET",
+ global: false,
+ url: elem.src,
+ async: false,
+ dataType: "script"
+ });
+ } else {
+ jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
+ }
+
+ if ( elem.parentNode ) {
+ elem.parentNode.removeChild( elem );
+ }
+ });
}
}
@@ -6013,7 +6113,7 @@ function cloneCopyEvent( src, dest ) {
for ( type in events ) {
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
- jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
+ jQuery.event.add( dest, type, events[ type ][ i ] );
}
}
}
@@ -6075,11 +6175,20 @@ function cloneFixAttributes( src, dest ) {
// cloning other types of input fields
} else if ( nodeName === "input" || nodeName === "textarea" ) {
dest.defaultValue = src.defaultValue;
+
+ // IE blanks contents when cloning scripts
+ } else if ( nodeName === "script" && dest.text !== src.text ) {
+ dest.text = src.text;
}
// Event data gets referenced instead of copied if the expando
// gets copied too
dest.removeAttribute( jQuery.expando );
+
+ // Clear flags for bubbling special change/submit events, they must
+ // be reattached when the newly cloned events are first activated
+ dest.removeAttribute( "_submit_attached" );
+ dest.removeAttribute( "_change_attached" );
}
jQuery.buildFragment = function( args, nodes, scripts ) {
@@ -6204,7 +6313,7 @@ jQuery.extend({
destElements,
i,
// IE<=8 does not properly clone detached, unknown element nodes
- clone = jQuery.support.html5Clone || !rnoshimcache.test( "<" + elem.nodeName ) ?
+ clone = jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ?
elem.cloneNode( true ) :
shimCloneNode( elem );
@@ -6254,7 +6363,8 @@ jQuery.extend({
},
clean: function( elems, context, fragment, scripts ) {
- var checkScriptType;
+ var checkScriptType, script, j,
+ ret = [];
context = context || document;
@@ -6263,8 +6373,6 @@ jQuery.extend({
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
}
- var ret = [], j;
-
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
if ( typeof elem === "number" ) {
elem += "";
@@ -6286,7 +6394,9 @@ jQuery.extend({
var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(),
wrap = wrapMap[ tag ] || wrapMap._default,
depth = wrap[0],
- div = context.createElement("div");
+ div = context.createElement("div"),
+ safeChildNodes = safeFragment.childNodes,
+ remove;
// Append wrapper element to unknown element safe doc fragment
if ( context === document ) {
@@ -6331,6 +6441,21 @@ jQuery.extend({
}
elem = div.childNodes;
+
+ // Clear elements from DocumentFragment (safeFragment or otherwise)
+ // to avoid hoarding elements. Fixes #11356
+ if ( div ) {
+ div.parentNode.removeChild( div );
+
+ // Guard against -1 index exceptions in FF3.6
+ if ( safeChildNodes.length > 0 ) {
+ remove = safeChildNodes[ safeChildNodes.length - 1 ];
+
+ if ( remove && remove.parentNode ) {
+ remove.parentNode.removeChild( remove );
+ }
+ }
+ }
}
}
@@ -6359,16 +6484,17 @@ jQuery.extend({
return !elem.type || rscriptType.test( elem.type );
};
for ( i = 0; ret[i]; i++ ) {
- if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
- scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
+ script = ret[i];
+ if ( scripts && jQuery.nodeName( script, "script" ) && (!script.type || rscriptType.test( script.type )) ) {
+ scripts.push( script.parentNode ? script.parentNode.removeChild( script ) : script );
} else {
- if ( ret[i].nodeType === 1 ) {
- var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
+ if ( script.nodeType === 1 ) {
+ var jsTags = jQuery.grep( script.getElementsByTagName( "script" ), checkScriptType );
ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
}
- fragment.appendChild( ret[i] );
+ fragment.appendChild( script );
}
}
}
@@ -6422,52 +6548,34 @@ jQuery.extend({
}
});
-function evalScript( i, elem ) {
- if ( elem.src ) {
- jQuery.ajax({
- url: elem.src,
- async: false,
- dataType: "script"
- });
- } else {
- jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
- }
-
- if ( elem.parentNode ) {
- elem.parentNode.removeChild( elem );
- }
-}
-
var ralpha = /alpha\([^)]*\)/i,
ropacity = /opacity=([^)]*)/,
// fixed for IE9, see #8346
rupper = /([A-Z]|^ms)/g,
- rnumpx = /^-?\d+(?:px)?$/i,
- rnum = /^-?\d/,
+ rnum = /^[\-+]?(?:\d*\.)?\d+$/i,
+ rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i,
rrelNum = /^([\-+])=([\-+.\de]+)/,
+ rmargin = /^margin/,
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
- cssWidth = [ "Left", "Right" ],
- cssHeight = [ "Top", "Bottom" ],
+
+ // order is important!
+ cssExpand = [ "Top", "Right", "Bottom", "Left" ],
+
curCSS,
getComputedStyle,
currentStyle;
jQuery.fn.css = function( name, value ) {
- // Setting 'undefined' is a no-op
- if ( arguments.length === 2 && value === undefined ) {
- return this;
- }
-
- return jQuery.access( this, name, value, true, function( elem, name, value ) {
+ return jQuery.access( this, function( elem, name, value ) {
return value !== undefined ?
jQuery.style( elem, name, value ) :
jQuery.css( elem, name );
- });
+ }, name, value, arguments.length > 1 );
};
jQuery.extend({
@@ -6478,7 +6586,7 @@ jQuery.extend({
get: function( elem, computed ) {
if ( computed ) {
// We should always get a number back from opacity
- var ret = curCSS( elem, "opacity", "opacity" );
+ var ret = curCSS( elem, "opacity" );
return ret === "" ? "1" : ret;
} else {
@@ -6586,137 +6694,55 @@ jQuery.extend({
// A method for quickly swapping in/out CSS properties to get correct calculations
swap: function( elem, options, callback ) {
- var old = {};
+ var old = {},
+ ret, name;
// Remember the old values, and insert the new ones
- for ( var name in options ) {
+ for ( name in options ) {
old[ name ] = elem.style[ name ];
elem.style[ name ] = options[ name ];
}
- callback.call( elem );
+ ret = callback.call( elem );
// Revert the old values
for ( name in options ) {
elem.style[ name ] = old[ name ];
}
+
+ return ret;
}
});
-// DEPRECATED, Use jQuery.css() instead
+// DEPRECATED in 1.3, Use jQuery.css() instead
jQuery.curCSS = jQuery.css;
-jQuery.each(["height", "width"], function( i, name ) {
- jQuery.cssHooks[ name ] = {
- get: function( elem, computed, extra ) {
- var val;
-
- if ( computed ) {
- if ( elem.offsetWidth !== 0 ) {
- return getWH( elem, name, extra );
- } else {
- jQuery.swap( elem, cssShow, function() {
- val = getWH( elem, name, extra );
- });
- }
-
- return val;
- }
- },
-
- set: function( elem, value ) {
- if ( rnumpx.test( value ) ) {
- // ignore negative width and height values #1599
- value = parseFloat( value );
-
- if ( value >= 0 ) {
- return value + "px";
- }
-
- } else {
- return value;
- }
- }
- };
-});
-
-if ( !jQuery.support.opacity ) {
- jQuery.cssHooks.opacity = {
- get: function( elem, computed ) {
- // IE uses filters for opacity
- return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
- ( parseFloat( RegExp.$1 ) / 100 ) + "" :
- computed ? "1" : "";
- },
-
- set: function( elem, value ) {
- var style = elem.style,
- currentStyle = elem.currentStyle,
- opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
- filter = currentStyle && currentStyle.filter || style.filter || "";
-
- // IE has trouble with opacity if it does not have layout
- // Force it by setting the zoom level
- style.zoom = 1;
-
- // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
- if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
-
- // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
- // if "filter:" is present at all, clearType is disabled, we want to avoid this
- // style.removeAttribute is IE Only, but so apparently is this code path...
- style.removeAttribute( "filter" );
-
- // if there there is no filter style applied in a css rule, we are done
- if ( currentStyle && !currentStyle.filter ) {
- return;
- }
- }
-
- // otherwise, set new filter values
- style.filter = ralpha.test( filter ) ?
- filter.replace( ralpha, opacity ) :
- filter + " " + opacity;
- }
- };
-}
-
-jQuery(function() {
- // This hook cannot be added until DOM ready because the support test
- // for it is not run until after DOM ready
- if ( !jQuery.support.reliableMarginRight ) {
- jQuery.cssHooks.marginRight = {
- get: function( elem, computed ) {
- // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
- // Work around by temporarily setting element display to inline-block
- var ret;
- jQuery.swap( elem, { "display": "inline-block" }, function() {
- if ( computed ) {
- ret = curCSS( elem, "margin-right", "marginRight" );
- } else {
- ret = elem.style.marginRight;
- }
- });
- return ret;
- }
- };
- }
-});
-
if ( document.defaultView && document.defaultView.getComputedStyle ) {
getComputedStyle = function( elem, name ) {
- var ret, defaultView, computedStyle;
+ var ret, defaultView, computedStyle, width,
+ style = elem.style;
name = name.replace( rupper, "-$1" ).toLowerCase();
if ( (defaultView = elem.ownerDocument.defaultView) &&
(computedStyle = defaultView.getComputedStyle( elem, null )) ) {
+
ret = computedStyle.getPropertyValue( name );
if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
ret = jQuery.style( elem, name );
}
}
+ // A tribute to the "awesome hack by Dean Edwards"
+ // WebKit uses "computed value (percentage if specified)" instead of "used value" for margins
+ // which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
+ if ( !jQuery.support.pixelMargin && computedStyle && rmargin.test( name ) && rnumnonpx.test( ret ) ) {
+ width = style.width;
+ style.width = ret;
+ ret = computedStyle.width;
+ style.width = width;
+ }
+
return ret;
};
}
@@ -6729,7 +6755,7 @@ if ( document.documentElement.currentStyle ) {
// Avoid setting ret to empty string here
// so we don't default to auto
- if ( ret === null && style && (uncomputed = style[ name ]) ) {
+ if ( ret == null && style && (uncomputed = style[ name ]) ) {
ret = uncomputed;
}
@@ -6738,7 +6764,7 @@ if ( document.documentElement.currentStyle ) {
// If we're not dealing with a regular pixel number
// but a number that has a weird ending, we need to convert it to pixels
- if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
+ if ( rnumnonpx.test( ret ) ) {
// Remember the original values
left = style.left;
@@ -6748,7 +6774,7 @@ if ( document.documentElement.currentStyle ) {
if ( rsLeft ) {
elem.runtimeStyle.left = elem.currentStyle.left;
}
- style.left = name === "fontSize" ? "1em" : ( ret || 0 );
+ style.left = name === "fontSize" ? "1em" : ret;
ret = style.pixelLeft + "px";
// Revert the changed values
@@ -6764,24 +6790,23 @@ if ( document.documentElement.currentStyle ) {
curCSS = getComputedStyle || currentStyle;
-function getWH( elem, name, extra ) {
+function getWidthOrHeight( elem, name, extra ) {
// Start with offset property
var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
- which = name === "width" ? cssWidth : cssHeight,
- i = 0,
- len = which.length;
+ i = name === "width" ? 1 : 0,
+ len = 4;
if ( val > 0 ) {
if ( extra !== "border" ) {
- for ( ; i < len; i++ ) {
+ for ( ; i < len; i += 2 ) {
if ( !extra ) {
- val -= parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0;
+ val -= parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
}
if ( extra === "margin" ) {
- val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0;
+ val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0;
} else {
- val -= parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0;
+ val -= parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
}
}
}
@@ -6790,29 +6815,118 @@ function getWH( elem, name, extra ) {
}
// Fall back to computed then uncomputed css if necessary
- val = curCSS( elem, name, name );
+ val = curCSS( elem, name );
if ( val < 0 || val == null ) {
- val = elem.style[ name ] || 0;
+ val = elem.style[ name ];
}
+
+ // Computed unit is not pixels. Stop here and return.
+ if ( rnumnonpx.test(val) ) {
+ return val;
+ }
+
// Normalize "", auto, and prepare for extra
val = parseFloat( val ) || 0;
// Add padding, border, margin
if ( extra ) {
- for ( ; i < len; i++ ) {
- val += parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0;
+ for ( ; i < len; i += 2 ) {
+ val += parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0;
if ( extra !== "padding" ) {
- val += parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0;
+ val += parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0;
}
if ( extra === "margin" ) {
- val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0;
+ val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ]) ) || 0;
}
}
}
return val + "px";
}
+jQuery.each([ "height", "width" ], function( i, name ) {
+ jQuery.cssHooks[ name ] = {
+ get: function( elem, computed, extra ) {
+ if ( computed ) {
+ if ( elem.offsetWidth !== 0 ) {
+ return getWidthOrHeight( elem, name, extra );
+ } else {
+ return jQuery.swap( elem, cssShow, function() {
+ return getWidthOrHeight( elem, name, extra );
+ });
+ }
+ }
+ },
+
+ set: function( elem, value ) {
+ return rnum.test( value ) ?
+ value + "px" :
+ value;
+ }
+ };
+});
+
+if ( !jQuery.support.opacity ) {
+ jQuery.cssHooks.opacity = {
+ get: function( elem, computed ) {
+ // IE uses filters for opacity
+ return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
+ ( parseFloat( RegExp.$1 ) / 100 ) + "" :
+ computed ? "1" : "";
+ },
+
+ set: function( elem, value ) {
+ var style = elem.style,
+ currentStyle = elem.currentStyle,
+ opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
+ filter = currentStyle && currentStyle.filter || style.filter || "";
+
+ // IE has trouble with opacity if it does not have layout
+ // Force it by setting the zoom level
+ style.zoom = 1;
+
+ // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
+ if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
+
+ // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
+ // if "filter:" is present at all, clearType is disabled, we want to avoid this
+ // style.removeAttribute is IE Only, but so apparently is this code path...
+ style.removeAttribute( "filter" );
+
+ // if there there is no filter style applied in a css rule, we are done
+ if ( currentStyle && !currentStyle.filter ) {
+ return;
+ }
+ }
+
+ // otherwise, set new filter values
+ style.filter = ralpha.test( filter ) ?
+ filter.replace( ralpha, opacity ) :
+ filter + " " + opacity;
+ }
+ };
+}
+
+jQuery(function() {
+ // This hook cannot be added until DOM ready because the support test
+ // for it is not run until after DOM ready
+ if ( !jQuery.support.reliableMarginRight ) {
+ jQuery.cssHooks.marginRight = {
+ get: function( elem, computed ) {
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ // Work around by temporarily setting element display to inline-block
+ return jQuery.swap( elem, { "display": "inline-block" }, function() {
+ if ( computed ) {
+ return curCSS( elem, "margin-right" );
+ } else {
+ return elem.style.marginRight;
+ }
+ });
+ }
+ };
+ }
+});
+
if ( jQuery.expr && jQuery.expr.filters ) {
jQuery.expr.filters.hidden = function( elem ) {
var width = elem.offsetWidth,
@@ -6826,6 +6940,31 @@ if ( jQuery.expr && jQuery.expr.filters ) {
};
}
+// These hooks are used by animate to expand properties
+jQuery.each({
+ margin: "",
+ padding: "",
+ border: "Width"
+}, function( prefix, suffix ) {
+
+ jQuery.cssHooks[ prefix + suffix ] = {
+ expand: function( value ) {
+ var i,
+
+ // assumes a single number if not a string
+ parts = typeof value === "string" ? value.split(" ") : [ value ],
+ expanded = {};
+
+ for ( i = 0; i < 4; i++ ) {
+ expanded[ prefix + cssExpand[ i ] + suffix ] =
+ parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
+ }
+
+ return expanded;
+ }
+ };
+});
+
@@ -7144,7 +7283,7 @@ jQuery.extend({
isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
global: true,
type: "GET",
- contentType: "application/x-www-form-urlencoded",
+ contentType: "application/x-www-form-urlencoded; charset=UTF-8",
processData: true,
async: true,
/*
@@ -7470,7 +7609,7 @@ jQuery.extend({
// Apply prefilters
inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
- // If request was aborted inside a prefiler, stop there
+ // If request was aborted inside a prefilter, stop there
if ( state === 2 ) {
return false;
}
@@ -7643,11 +7782,11 @@ function buildParams( prefix, obj, traditional, add ) {
// a server error. Possible fixes are to modify rack's
// deserialization algorithm or to provide an option or flag
// to force array serialization to be shallow.
- buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
+ buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
}
});
- } else if ( !traditional && obj != null && typeof obj === "object" ) {
+ } else if ( !traditional && jQuery.type( obj ) === "object" ) {
// Serialize object item.
for ( var name in obj ) {
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
@@ -7843,8 +7982,7 @@ jQuery.ajaxSetup({
// Detect, normalize options and install callbacks for jsonp requests
jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
- var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
- ( typeof s.data === "string" );
+ var inspectData = ( typeof s.data === "string" ) && /^application\/x\-www\-form\-urlencoded/.test( s.contentType );
if ( s.dataTypes[ 0 ] === "jsonp" ||
s.jsonp !== false && ( jsre.test( s.url ) ||
@@ -8145,7 +8283,13 @@ if ( jQuery.support.ajax ) {
if ( xml && xml.documentElement /* #4958 */ ) {
responses.xml = xml;
}
- responses.text = xhr.responseText;
+
+ // When requesting binary data, IE6-9 will throw an exception
+ // on any attempt to access responseText (#11426)
+ try {
+ responses.text = xhr.responseText;
+ } catch( _ ) {
+ }
// Firefox throws an exception when accessing
// statusText for faulty cross-domain requests
@@ -8253,7 +8397,8 @@ jQuery.fn.extend({
// Set elements which have been overridden with display: none
// in a stylesheet to whatever the default browser style is
// for such an element
- if ( display === "" && jQuery.css(elem, "display") === "none" ) {
+ if ( (display === "" && jQuery.css(elem, "display") === "none") ||
+ !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
}
}
@@ -8357,24 +8502,37 @@ jQuery.fn.extend({
var opt = jQuery.extend( {}, optall ),
isElement = this.nodeType === 1,
hidden = isElement && jQuery(this).is(":hidden"),
- name, val, p, e,
+ name, val, p, e, hooks, replace,
parts, start, end, unit,
method;
// will store per property easing and be used to determine when an animation is complete
opt.animatedProperties = {};
+ // first pass over propertys to expand / normalize
for ( p in prop ) {
-
- // property name normalization
name = jQuery.camelCase( p );
if ( p !== name ) {
prop[ name ] = prop[ p ];
delete prop[ p ];
}
- val = prop[ name ];
+ if ( ( hooks = jQuery.cssHooks[ name ] ) && "expand" in hooks ) {
+ replace = hooks.expand( prop[ name ] );
+ delete prop[ name ];
+ // not quite $.extend, this wont overwrite keys already present.
+ // also - reusing 'p' from above because we have the correct "name"
+ for ( p in replace ) {
+ if ( ! ( p in prop ) ) {
+ prop[ p ] = replace[ p ];
+ }
+ }
+ }
+ }
+
+ for ( name in prop ) {
+ val = prop[ name ];
// easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
if ( jQuery.isArray( val ) ) {
opt.animatedProperties[ name ] = val[ 1 ];
@@ -8601,11 +8759,11 @@ jQuery.extend({
},
easing: {
- linear: function( p, n, firstNum, diff ) {
- return firstNum + diff * p;
+ linear: function( p ) {
+ return p;
},
- swing: function( p, n, firstNum, diff ) {
- return ( ( -Math.cos( p*Math.PI ) / 2 ) + 0.5 ) * diff + firstNum;
+ swing: function( p ) {
+ return ( -Math.cos( p*Math.PI ) / 2 ) + 0.5;
}
},
@@ -8663,8 +8821,12 @@ jQuery.fx.prototype = {
t.queue = this.options.queue;
t.elem = this.elem;
t.saveState = function() {
- if ( self.options.hide && jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) {
- jQuery._data( self.elem, "fxshow" + self.prop, self.start );
+ if ( jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) {
+ if ( self.options.hide ) {
+ jQuery._data( self.elem, "fxshow" + self.prop, self.start );
+ } else if ( self.options.show ) {
+ jQuery._data( self.elem, "fxshow" + self.prop, self.end );
+ }
}
};
@@ -8831,12 +8993,14 @@ jQuery.extend( jQuery.fx, {
}
});
-// Adds width/height step functions
-// Do not set anything below 0
-jQuery.each([ "width", "height" ], function( i, prop ) {
- jQuery.fx.step[ prop ] = function( fx ) {
- jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
- };
+// Ensure props that can't be negative don't go there on undershoot easing
+jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) {
+ // exclude marginTop, marginLeft, marginBottom and marginRight from this list
+ if ( prop.indexOf( "margin" ) ) {
+ jQuery.fx.step[ prop ] = function( fx ) {
+ jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit );
+ };
+ }
});
if ( jQuery.expr && jQuery.expr.filters ) {
@@ -8873,7 +9037,7 @@ function defaultDisplay( nodeName ) {
// document to it; WebKit & Firefox won't allow reusing the iframe document.
if ( !iframeDoc || !iframe.createElement ) {
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
- iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
+ iframeDoc.write( ( jQuery.support.boxModel ? "<!doctype html>" : "" ) + "<html><body>" );
iframeDoc.close();
}
@@ -8895,41 +9059,23 @@ function defaultDisplay( nodeName ) {
-var rtable = /^t(?:able|d|h)$/i,
+var getOffset,
+ rtable = /^t(?:able|d|h)$/i,
rroot = /^(?:body|html)$/i;
if ( "getBoundingClientRect" in document.documentElement ) {
- jQuery.fn.offset = function( options ) {
- var elem = this[0], box;
-
- if ( options ) {
- return this.each(function( i ) {
- jQuery.offset.setOffset( this, options, i );
- });
- }
-
- if ( !elem || !elem.ownerDocument ) {
- return null;
- }
-
- if ( elem === elem.ownerDocument.body ) {
- return jQuery.offset.bodyOffset( elem );
- }
-
+ getOffset = function( elem, doc, docElem, box ) {
try {
box = elem.getBoundingClientRect();
} catch(e) {}
- var doc = elem.ownerDocument,
- docElem = doc.documentElement;
-
// Make sure we're not dealing with a disconnected DOM node
if ( !box || !jQuery.contains( docElem, elem ) ) {
return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
}
var body = doc.body,
- win = getWindow(doc),
+ win = getWindow( doc ),
clientTop = docElem.clientTop || body.clientTop || 0,
clientLeft = docElem.clientLeft || body.clientLeft || 0,
scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
@@ -8941,28 +9087,10 @@ if ( "getBoundingClientRect" in document.documentElement ) {
};
} else {
- jQuery.fn.offset = function( options ) {
- var elem = this[0];
-
- if ( options ) {
- return this.each(function( i ) {
- jQuery.offset.setOffset( this, options, i );
- });
- }
-
- if ( !elem || !elem.ownerDocument ) {
- return null;
- }
-
- if ( elem === elem.ownerDocument.body ) {
- return jQuery.offset.bodyOffset( elem );
- }
-
+ getOffset = function( elem, doc, docElem ) {
var computedStyle,
offsetParent = elem.offsetParent,
prevOffsetParent = elem,
- doc = elem.ownerDocument,
- docElem = doc.documentElement,
body = doc.body,
defaultView = doc.defaultView,
prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
@@ -9013,6 +9141,29 @@ if ( "getBoundingClientRect" in document.documentElement ) {
};
}
+jQuery.fn.offset = function( options ) {
+ if ( arguments.length ) {
+ return options === undefined ?
+ this :
+ this.each(function( i ) {
+ jQuery.offset.setOffset( this, options, i );
+ });
+ }
+
+ var elem = this[0],
+ doc = elem && elem.ownerDocument;
+
+ if ( !doc ) {
+ return null;
+ }
+
+ if ( elem === doc.body ) {
+ return jQuery.offset.bodyOffset( elem );
+ }
+
+ return getOffset( elem, doc, doc.documentElement );
+};
+
jQuery.offset = {
bodyOffset: function( body ) {
@@ -9118,42 +9269,30 @@ jQuery.fn.extend({
// Create scrollLeft and scrollTop methods
-jQuery.each( ["Left", "Top"], function( i, name ) {
- var method = "scroll" + name;
+jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
+ var top = /Y/.test( prop );
jQuery.fn[ method ] = function( val ) {
- var elem, win;
+ return jQuery.access( this, function( elem, method, val ) {
+ var win = getWindow( elem );
- if ( val === undefined ) {
- elem = this[ 0 ];
-
- if ( !elem ) {
- return null;
+ if ( val === undefined ) {
+ return win ? (prop in win) ? win[ prop ] :
+ jQuery.support.boxModel && win.document.documentElement[ method ] ||
+ win.document.body[ method ] :
+ elem[ method ];
}
- win = getWindow( elem );
-
- // Return the scroll offset
- return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
- jQuery.support.boxModel && win.document.documentElement[ method ] ||
- win.document.body[ method ] :
- elem[ method ];
- }
-
- // Set the scroll offset
- return this.each(function() {
- win = getWindow( this );
-
if ( win ) {
win.scrollTo(
- !i ? val : jQuery( win ).scrollLeft(),
- i ? val : jQuery( win ).scrollTop()
+ !top ? val : jQuery( win ).scrollLeft(),
+ top ? val : jQuery( win ).scrollTop()
);
} else {
- this[ method ] = val;
+ elem[ method ] = val;
}
- });
+ }, method, val, arguments.length, null );
};
});
@@ -9169,9 +9308,10 @@ function getWindow( elem ) {
// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
-jQuery.each([ "Height", "Width" ], function( i, name ) {
-
- var type = name.toLowerCase();
+jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
+ var clientProp = "client" + name,
+ scrollProp = "scroll" + name,
+ offsetProp = "offset" + name;
// innerHeight and innerWidth
jQuery.fn[ "inner" + name ] = function() {
@@ -9193,50 +9333,48 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
null;
};
- jQuery.fn[ type ] = function( size ) {
- // Get window width or height
- var elem = this[0];
- if ( !elem ) {
- return size == null ? null : this;
- }
+ jQuery.fn[ type ] = function( value ) {
+ return jQuery.access( this, function( elem, type, value ) {
+ var doc, docElemProp, orig, ret;
- if ( jQuery.isFunction( size ) ) {
- return this.each(function( i ) {
- var self = jQuery( this );
- self[ type ]( size.call( this, i, self[ type ]() ) );
- });
- }
+ if ( jQuery.isWindow( elem ) ) {
+ // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
+ doc = elem.document;
+ docElemProp = doc.documentElement[ clientProp ];
+ return jQuery.support.boxModel && docElemProp ||
+ doc.body && doc.body[ clientProp ] || docElemProp;
+ }
- if ( jQuery.isWindow( elem ) ) {
- // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
- // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
- var docElemProp = elem.document.documentElement[ "client" + name ],
- body = elem.document.body;
- return elem.document.compatMode === "CSS1Compat" && docElemProp ||
- body && body[ "client" + name ] || docElemProp;
-
- // Get document width or height
- } else if ( elem.nodeType === 9 ) {
- // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
- return Math.max(
- elem.documentElement["client" + name],
- elem.body["scroll" + name], elem.documentElement["scroll" + name],
- elem.body["offset" + name], elem.documentElement["offset" + name]
- );
+ // Get document width or height
+ if ( elem.nodeType === 9 ) {
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ doc = elem.documentElement;
- // Get or set width or height on the element
- } else if ( size === undefined ) {
- var orig = jQuery.css( elem, type ),
- ret = parseFloat( orig );
+ // when a window > document, IE6 reports a offset[Width/Height] > client[Width/Height]
+ // so we can't use max, as it'll choose the incorrect offset[Width/Height]
+ // instead we use the correct client[Width/Height]
+ // support:IE6
+ if ( doc[ clientProp ] >= doc[ scrollProp ] ) {
+ return doc[ clientProp ];
+ }
+
+ return Math.max(
+ elem.body[ scrollProp ], doc[ scrollProp ],
+ elem.body[ offsetProp ], doc[ offsetProp ]
+ );
+ }
- return jQuery.isNumeric( ret ) ? ret : orig;
+ // Get width or height on the element
+ if ( value === undefined ) {
+ orig = jQuery.css( elem, type );
+ ret = parseFloat( orig );
+ return jQuery.isNumeric( ret ) ? ret : orig;
+ }
- // Set the width or height on the element (default to pixels if value is unitless)
- } else {
- return this.css( type, typeof size === "string" ? size : size + "px" );
- }
+ // Set the width or height on the element
+ jQuery( elem ).css( type, value );
+ }, type, value, arguments.length, null );
};
-
});
| false |
Other | emberjs | ember.js | dfd95de1d35958b1b742aa0cbae39e5babd08789.json | Fix failing Handlebars test that relies on states
A previous commit introduced a test that tests
the integration between Handlebars and Ember's
state manager. Unfortunately, ember-handlebars
does not have a dependency on ember-states, so the
test only passes when all of the tests are run
at once. (This is the reason the failure was
not caught by Travis.)
This fix adds ember-states as a dependency.
Ideally, we could create a new testing-only
package that includes both handlebars and states
as a dependency and contains just the integration
test. | packages/ember-handlebars/package.json | @@ -9,6 +9,7 @@
"spade": "~> 1.0.0",
"handlebars": "~> 1.0.0.beta.3",
"ember-views": "0.9.5",
+ "ember-states" : "0.9.5",
"metamorph": "~> 1.0.0"
},
| true |
Other | emberjs | ember.js | dfd95de1d35958b1b742aa0cbae39e5babd08789.json | Fix failing Handlebars test that relies on states
A previous commit introduced a test that tests
the integration between Handlebars and Ember's
state manager. Unfortunately, ember-handlebars
does not have a dependency on ember-states, so the
test only passes when all of the tests are run
at once. (This is the reason the failure was
not caught by Travis.)
This fix adds ember-states as a dependency.
Ideally, we could create a new testing-only
package that includes both handlebars and states
as a dependency and contains just the integration
test. | packages/ember-handlebars/tests/helpers/action_test.js | @@ -244,6 +244,7 @@ test("should allow bubbling of events from action helper to original parent even
});
test("should be compatible with sending events to a state manager", function() {
+ require("ember-states");
var eventWasCalled = false,
eventObjectSent,
manager = Ember.StateManager.create({ | true |
Other | emberjs | ember.js | ee1f84b9b5d0c40d21ecd7ecc38549a8e1e0789d.json | Add compiled tests to gitignore | .gitignore | @@ -31,3 +31,4 @@ tmp
tmp*.gem
tmp.bpm
tmp.spade
+tests/source | false |
Other | emberjs | ember.js | 5cbb34a841ed22c495761e6a924f36a7051ee7bc.json | Action helper: reuse local "hash" variable | packages/ember-handlebars/lib/helpers/action.js | @@ -32,12 +32,12 @@ ActionHelper.registerAction = function(actionName, eventName, target, view, cont
EmberHandlebars.registerHelper('action', function(actionName, options) {
var hash = options.hash || {},
- eventName = options.hash.on || "click",
+ eventName = hash.on || "click",
view = options.data.view,
target, context;
if (view.isVirtual) { view = view.get('parentView'); }
- target = options.hash.target ? getPath(this, options.hash.target) : view;
+ target = hash.target ? getPath(this, hash.target) : view;
context = options.contexts[0];
var actionId = ActionHelper.registerAction(actionName, eventName, target, view, context); | false |
Other | emberjs | ember.js | 158195a4d5a427ae414e9fde4bc6c72b8f944748.json | Support the old format of Ember.Binding.transform | packages/ember-metal/lib/binding.js | @@ -617,6 +617,10 @@ mixinProperties(Binding,
@see Ember.Binding.prototype.transform
*/
transform: function(from, func) {
+ if (!func) {
+ func = from;
+ from = null;
+ }
var C = this, binding = new C(null, from);
return binding.transform(func);
}, | false |
Other | emberjs | ember.js | 48c37b040feaed97351a7a771a807d29cd9efb9f.json | add Ember.Binding#notNull to mixin | packages/ember-metal/lib/binding.js | @@ -629,6 +629,15 @@ mixinProperties(Binding,
return binding.notEmpty(placeholder);
},
+ /**
+ @see Ember.Binding.prototype.notNull
+ */
+ notNull: function(from, placeholder) {
+ var C = this, binding = new C(null, from);
+ return binding.notNull(placeholder);
+ },
+
+
/**
@see Ember.Binding.prototype.bool
*/ | false |
Other | emberjs | ember.js | a81d638f5ab5c4d174d2f05b239f09476f59395b.json | add Ember.Binding#isNull to mixin | packages/ember-metal/lib/binding.js | @@ -645,6 +645,14 @@ mixinProperties(Binding,
return binding.not();
},
+ /**
+ @see Ember.Binding.prototype.isNull
+ */
+ isNull: function(from) {
+ var C = this, binding = new C(null, from);
+ return binding.isNull();
+ },
+
/**
Adds a transform that forwards the logical 'AND' of values at 'pathA' and
'pathB' whenever either source changes. Note that the transform acts | false |
Other | emberjs | ember.js | c5b0fa82be67515bc5342d577bab154636af6e91.json | Add introspection for cached values
Adds the ability to query an object for the cached
value of a computed property. This is useful for
instances where you want to retrieve the value of
a lazily computed property if it exists, but do
not want to accidentally trigger its creation if
it has not been used yet. | packages/ember-metal/lib/computed.js | @@ -342,3 +342,22 @@ Ember.computed = function(func) {
return cp;
};
+
+/**
+ Returns the cached value for a property, if one exists.
+ This can be useful for peeking at the value of a computed
+ property that is generated lazily, without accidentally causing
+ it to be created.
+
+ @param {Object} obj the object whose property you want to check
+ @param {String} key the name of the property whose cached value you want
+ to return
+
+*/
+Ember.cacheFor = function(obj, key) {
+ var cache = meta(obj, false).cache;
+
+ if (cache && cache[key]) {
+ return cache[key];
+ }
+}; | true |
Other | emberjs | ember.js | c5b0fa82be67515bc5342d577bab154636af6e91.json | Add introspection for cached values
Adds the ability to query an object for the cached
value of a computed property. This is useful for
instances where you want to retrieve the value of
a lazily computed property if it exists, but do
not want to accidentally trigger its creation if
it has not been used yet. | packages/ember-metal/tests/computed_test.js | @@ -230,6 +230,14 @@ testBoth('inherited property should not pick up cache', function(get, set) {
equal(get(objB, 'foo'), 'bar 2', 'objB third get');
});
+testBoth('cacheFor should return the cached value', function(get, set) {
+ equal(Ember.cacheFor(obj, 'foo'), undefined, "should not yet be a cached value");
+
+ get(obj, 'foo');
+
+ equal(Ember.cacheFor(obj, 'foo'), "bar 1", "should retrieve cached value");
+});
+
// ..........................................................
// DEPENDENT KEYS
// | true |
Other | emberjs | ember.js | c5b0fa82be67515bc5342d577bab154636af6e91.json | Add introspection for cached values
Adds the ability to query an object for the cached
value of a computed property. This is useful for
instances where you want to retrieve the value of
a lazily computed property if it exists, but do
not want to accidentally trigger its creation if
it has not been used yet. | packages/ember-runtime/lib/mixins/observable.js | @@ -468,11 +468,23 @@ Ember.Observable = Ember.Mixin.create(/** @scope Ember.Observable.prototype */ {
return get(this, keyName);
},
+ /**
+ Returns the cached value of a computed property, if it exists.
+ This allows you to inspect the value of a computed property
+ without accidentally invoking it if it is intended to be
+ generated lazily.
+
+ @param {String} keyName
+ @returns {Object} The cached value of the computed property, if any
+ */
+ cacheFor: function(keyName) {
+ return Ember.cacheFor(this, keyName);
+ },
+
/** @private - intended for debugging purposes */
observersForKey: function(keyName) {
return Ember.observersFor(this, keyName);
}
-
});
| true |
Other | emberjs | ember.js | c5b0fa82be67515bc5342d577bab154636af6e91.json | Add introspection for cached values
Adds the ability to query an object for the cached
value of a computed property. This is useful for
instances where you want to retrieve the value of
a lazily computed property if it exists, but do
not want to accidentally trigger its creation if
it has not been used yet. | packages/ember-runtime/tests/mixins/observable_test.js | @@ -61,3 +61,21 @@ testBoth('calling setProperties completes safely despite exceptions', function(g
equal(firstNameChangedCount, 1, 'firstName should have fired once');
});
+
+testBoth("should be able to retrieve cached values of computed properties without invoking the computed property", function(get) {
+ var obj = Ember.Object.create({
+ foo: Ember.computed(function() {
+ return "foo";
+ }).cacheable(),
+
+ bar: "bar"
+ });
+
+ equal(obj.cacheFor('foo'), undefined, "should return undefined if no value has been cached");
+ get(obj, 'foo');
+
+ equal(get(obj, 'foo'), "foo", "precond - should cache the value");
+ equal(obj.cacheFor('foo'), "foo", "should return the cached value after it is invoked");
+
+ equal(obj.cacheFor('bar'), undefined, "returns undefined if the value is not a computed property");
+}); | true |
Other | emberjs | ember.js | f71943d63365319a3fce0b24d17e6d96a937987c.json | add test for #591 | packages/ember-runtime/tests/system/object/subclasses_test.js | @@ -23,3 +23,34 @@ test('defining sub-sub class should only go to parent', function() {
ok(Sub.subclasses.contains(SubSub), 'Sub contains SubSub');
});
+// TEST lazy prototype and Em.rewatch(prototype)
+test('chains should copy forward to subclasses when prototype created', function () {
+ var ObjectWithChains, objWithChains, SubWithChains, SubSub, subSub;
+ Ember.run(function () {
+ ObjectWithChains = Ember.Object.extend({
+ obj: {
+ a: 'a',
+ hi: 'hi'
+ },
+ aBinding: 'obj.a' // add chain
+ });
+ // realize prototype
+ objWithChains = ObjectWithChains.create();
+ // should not copy chains from parent yet
+ SubWithChains = ObjectWithChains.extend({
+ hiBinding: 'obj.hi', // add chain
+ hello: Ember.computed(function() {
+ return this.getPath('obj.hi') + ' world';
+ }).property('hi'), // observe chain
+ greetingBinding: 'hello'
+ });
+ SubSub = SubWithChains.extend();
+ // should realize prototypes and copy forward chains
+ subSub = SubSub.create();
+ });
+ equal(subSub.get('greeting'), 'hi world');
+ Ember.run(function () {
+ objWithChains.setPath('obj.hi', 'hello');
+ });
+ equal(subSub.get('greeting'), 'hello world');
+}); | false |
Other | emberjs | ember.js | 437cc6ed9356e51742faa557020a6b82f79e5329.json | remove duplicate call to `this._super()` | packages/ember-views/lib/system/application.js | @@ -82,8 +82,6 @@ Ember.Application = Ember.Namespace.extend(
self.didBecomeReady();
});
}
-
- this._super();
},
/** @private */ | false |
Other | emberjs | ember.js | 60a01c11c0b879dacee73c26402469e1d97e2e3e.json | Fix inconsistent slice usage | packages/ember-metal/lib/computed.js | @@ -302,8 +302,8 @@ Ember.computed = function(func) {
var args;
if (arguments.length > 1) {
- args = [].slice.call(arguments, 0, -1);
- func = [].slice.call(arguments, -1)[0];
+ args = a_slice.call(arguments, 0, -1);
+ func = a_slice.call(arguments, -1)[0];
}
var cp = new ComputedProperty(func); | false |
Other | emberjs | ember.js | 64aaa567ef710b9de029c7222a857538011d136c.json | Update simple bench | benchmarks/simple.html | @@ -3,11 +3,11 @@
<html>
<head>
<script src="../tests/jquery-1.7.1.js"></script>
- <script src="../dist/ember.prod.js"></script>
+ <script src="ember.js"></script>
</head>
<body>
<script type="text/x-handlebars">
- <ul>{{#each App.wat}}<li>{{id}}</li>{{/each}}</ul>
+ <ul>{{#each App.wat}}<li>{{id}}: {{dateIn}}: {{tag}}: {{speed}}: {{length}}</li>{{/each}}</ul>
</script>
<script>
@@ -17,7 +17,7 @@
newContent = function() {
var newContent = [], i;
- for (i = 0; i < 1000; i++) {
+ for (i = 0; i < 50; i++) {
newContent[newContent.length] = {
id: Math.round(Math.random() * 1000),
dateIn: new Date(),
@@ -33,13 +33,16 @@
App.set('wat', newContent());
});
- setTimeout(function() {
- console.profile('wat');
- Ember.run(function() {
- App.set('wat', newContent());
- });
- console.profileEnd('wat');
- }, 1000);
+ setInterval(function() {
+ App.set('wat', newContent());
+ }, 1);
+ //setTimeout(function() {
+ // console.profile('wat');
+ // Ember.run(function() {
+ // App.set('wat', newContent());
+ // });
+ // console.profileEnd('wat');
+ //}, 1000);
</script>
</body>
</html> | false |
Other | emberjs | ember.js | 471ba8f3e21c16703d8e126bff3202d9c2b8b94b.json | Add a few benchmarks | benchmarks/simple.html | @@ -0,0 +1,46 @@
+<!doctype html>
+
+<html>
+ <head>
+ <script src="../tests/jquery-1.7.1.js"></script>
+ <script src="../dist/ember.prod.js"></script>
+ </head>
+ <body>
+ <script type="text/x-handlebars">
+ <ul>{{#each App.wat}}<li>{{id}}</li>{{/each}}</ul>
+ </script>
+
+ <script>
+ Ember.run(function() {
+ App = Ember.Application.create();
+
+ newContent = function() {
+ var newContent = [], i;
+
+ for (i = 0; i < 1000; i++) {
+ newContent[newContent.length] = {
+ id: Math.round(Math.random() * 1000),
+ dateIn: new Date(),
+ tag: "TAG-0" + i,
+ speed: Math.random() * 100,
+ length: Math.random() * 1000
+ };
+ }
+
+ return newContent;
+ };
+
+ App.set('wat', newContent());
+ });
+
+ setTimeout(function() {
+ console.profile('wat');
+ Ember.run(function() {
+ App.set('wat', newContent());
+ });
+ console.profileEnd('wat');
+ }, 1000);
+ </script>
+ </body>
+</html>
+ | true |
Other | emberjs | ember.js | 471ba8f3e21c16703d8e126bff3202d9c2b8b94b.json | Add a few benchmarks | benchmarks/suites/views/destroy_view.js | @@ -0,0 +1,22 @@
+/*globals App:true Ember before after bench*/
+
+var view;
+
+before(function() {
+ Ember.run(function() {
+ view = Ember.ContainerView.create({
+ childViews: [ 'one', 'two', 'three' ],
+
+ one: Ember.View,
+ two: Ember.View,
+ three: Ember.View
+ }).append();
+ });
+});
+
+bench("creating a new view", function() {
+ Ember.run(function() {
+ view.destroy();
+ });
+});
+ | true |
Other | emberjs | ember.js | b888b681a86d0575f37db1f225c51255a996fa5d.json | Fix benchmark runner | benchmarks/iframe_runner.js | @@ -74,13 +74,13 @@ BenchWarmer.prototype = {
var count = parseInt(this.profile, 10);
setTimeout(function() {
- self.setup();
+ if (self.setup) { self.setup(); }
console.profile(self.emberPath + ": " + self.name);
for (var i=0; i<count; i++) {
self.fn();
}
console.profileEnd(self.emberPath + ": " + self.name);
- self.teardown();
+ if (self.teardown) { self.teardown(); }
if (self.next) { self.next.run(); }
}, 1);
} else { | false |
Other | emberjs | ember.js | c3401b77840119f9014bd347756da32a801973ea.json | Remove unnecessary observability from _childViews | packages/ember-metal/lib/array.js | @@ -86,6 +86,11 @@ Ember.ArrayUtils = {
indexOf: function(obj) {
var args = Array.prototype.slice.call(arguments, 1);
return obj.indexOf ? obj.indexOf.apply(obj, args) : arrayIndexOf.apply(obj, args);
+ },
+
+ removeObject: function(array, item) {
+ var index = this.indexOf(array, item);
+ if (index !== -1) { array.splice(index, 1); }
}
};
| true |
Other | emberjs | ember.js | c3401b77840119f9014bd347756da32a801973ea.json | Remove unnecessary observability from _childViews | packages/ember-views/lib/views/container_view.js | @@ -37,6 +37,9 @@ Ember.ContainerView = Ember.View.extend({
_childViews[idx] = view;
}, this);
+ // Make the _childViews array observable
+ Ember.A(_childViews);
+
// Sets up an array observer on the child views array. This
// observer will detect when child views are added or removed
// and update the DOM to reflect the mutation. | true |
Other | emberjs | ember.js | c3401b77840119f9014bd347756da32a801973ea.json | Remove unnecessary observability from _childViews | packages/ember-views/lib/views/states/in_buffer.js | @@ -39,11 +39,11 @@ Ember.View.states.inBuffer = {
var buffer = view.buffer;
childView = this.createChildView(childView, options);
- get(view, '_childViews').pushObject(childView);
+ get(view, '_childViews').push(childView);
childView.renderToBuffer(buffer);
- // update `childViews`
+ view.propertyDidChange('childViews');
return childView;
}, | true |
Other | emberjs | ember.js | c3401b77840119f9014bd347756da32a801973ea.json | Remove unnecessary observability from _childViews | packages/ember-views/lib/views/view.js | @@ -26,7 +26,7 @@ var childViewsProperty = Ember.computed(function() {
});
return ret;
-}).property('_childViews.@each').cacheable();
+}).property().cacheable();
/**
@static
@@ -214,7 +214,7 @@ Ember.View = Ember.Object.extend(Ember.Evented,
*/
childViews: childViewsProperty,
- _childViews: Ember.A(),
+ _childViews: [],
/**
Return the nearest ancestor that is an instance of the provided
@@ -1157,7 +1157,7 @@ Ember.View = Ember.Object.extend(Ember.Evented,
// Ember.RootResponder to dispatch incoming events.
Ember.View.views[get(this, 'elementId')] = this;
- var childViews = Ember.A(get(this, '_childViews').slice());
+ var childViews = get(this, '_childViews').slice();
// setup child views. be sure to clone the child views array first
set(this, '_childViews', childViews);
@@ -1198,9 +1198,9 @@ Ember.View = Ember.Object.extend(Ember.Evented,
// remove view from childViews array.
var childViews = get(this, '_childViews');
- childViews.removeObject(view);
+ Ember.ArrayUtils.removeObject(childViews, view);
- // update `childViews`
+ this.propertyDidChange('childViews');
return this;
}, | true |
Other | emberjs | ember.js | c3401b77840119f9014bd347756da32a801973ea.json | Remove unnecessary observability from _childViews | packages/ember-views/tests/views/container_view_test.js | @@ -96,8 +96,7 @@ test("views that are removed from a ContainerView should have their child views
this._super();
},
template: function(view) {
- var childViews = get(view, '_childViews');
- childViews.pushObject(view.createChildView(Ember.View, {}));
+ view.appendChild(Ember.View);
}
});
| true |
Other | emberjs | ember.js | 1520369d998c4cdeea95e2fe74b92fd6bc9c41c9.json | Improve perf of object model affecting View
Previously, it was possible for large classes
to adversely impact the performance of instance
creation of subclasses.
This specifically affected classes whose
subclasses were instantiated before they were.
In short, all of the parent class' properties
were copied onto each instance of the subclass,
instead of applying them to the superclass'
prototype chain and remembering that they were
already applied.
Major props to @ebryn and @kselden for sitting
through an insane debugging session figuring
this out! | packages/ember-handlebars/lib/helpers/collection.js | @@ -41,7 +41,7 @@ Ember.Handlebars.registerHelper('collection', function(path, options) {
// Extract item view class if provided else default to the standard class
var itemViewClass, itemViewPath = hash.itemViewClass;
- var collectionPrototype = get(collectionClass, 'proto');
+ var collectionPrototype = collectionClass.proto();
delete hash.itemViewClass;
itemViewClass = itemViewPath ? getPath(collectionPrototype, itemViewPath) : collectionPrototype.itemViewClass;
ember_assert(fmt("%@ #collection: Could not find %@", data.view, itemViewPath), !!itemViewClass); | true |
Other | emberjs | ember.js | 1520369d998c4cdeea95e2fe74b92fd6bc9c41c9.json | Improve perf of object model affecting View
Previously, it was possible for large classes
to adversely impact the performance of instance
creation of subclasses.
This specifically affected classes whose
subclasses were instantiated before they were.
In short, all of the parent class' properties
were copied onto each instance of the subclass,
instead of applying them to the superclass'
prototype chain and remembering that they were
already applied.
Major props to @ebryn and @kselden for sitting
through an insane debugging session figuring
this out! | packages/ember-runtime/lib/system/core_object.js | @@ -25,10 +25,10 @@ function makeCtor() {
// method a lot faster. This is glue code so we want it to be as fast as
// possible.
- var isPrepared = false, initMixins, init = false, hasChains = false;
+ var wasApplied = false, initMixins, init = false, hasChains = false;
var Class = function() {
- if (!isPrepared) { get(Class, 'proto'); } // prepare prototype...
+ if (!wasApplied) { Class.proto(); } // prepare prototype...
if (initMixins) {
this.reopen.apply(this, initMixins);
initMixins = null;
@@ -49,20 +49,27 @@ function makeCtor() {
};
Class.toString = classToString;
- Class._prototypeMixinDidChange = function() {
- ember_assert("Reopening already instantiated classes is not supported. We plan to support this in the future.", isPrepared === false);
- isPrepared = false;
+ Class.willReopen = function() {
+ if (wasApplied) {
+ Class.PrototypeMixin = Ember.Mixin.create(Class.PrototypeMixin);
+ }
+
+ wasApplied = false;
};
Class._initMixins = function(args) { initMixins = args; };
- Ember.defineProperty(Class, 'proto', Ember.computed(function() {
- if (!isPrepared) {
- isPrepared = true;
+ Class.proto = function() {
+ var superclass = Class.superclass;
+ if (superclass) { superclass.proto(); }
+
+ if (!wasApplied) {
+ wasApplied = true;
Class.PrototypeMixin.applyPartial(Class.prototype);
hasChains = !!meta(Class.prototype, false).chains; // avoid rewatch
}
+
return this.prototype;
- }));
+ };
return Class;
@@ -170,9 +177,9 @@ var ClassMixin = Ember.Mixin.create({
},
reopen: function() {
+ this.willReopen();
var PrototypeMixin = this.PrototypeMixin;
PrototypeMixin.reopen.apply(PrototypeMixin, arguments);
- this._prototypeMixinDidChange();
return this;
},
@@ -193,7 +200,7 @@ var ClassMixin = Ember.Mixin.create({
},
detectInstance: function(obj) {
- return this.PrototypeMixin.detect(obj);
+ return obj instanceof this;
},
/**
@@ -217,7 +224,7 @@ var ClassMixin = Ember.Mixin.create({
This will return the original hash that was passed to `meta()`.
*/
metaForProperty: function(key) {
- var desc = meta(get(this, 'proto'), false).descs[key];
+ var desc = meta(this.proto(), false).descs[key];
ember_assert("metaForProperty() could not find a computed property with key '"+key+"'.", !!desc && desc instanceof Ember.ComputedProperty);
return desc._meta || {};
@@ -228,7 +235,7 @@ var ClassMixin = Ember.Mixin.create({
and any associated metadata (see `metaForProperty`) to the callback.
*/
eachComputedProperty: function(callback, binding) {
- var proto = get(this, 'proto'),
+ var proto = this.proto(),
descs = meta(proto).descs,
empty = {},
property; | true |
Other | emberjs | ember.js | b6726ebf176c2ff923360bf233fabd9aa1f936bd.json | Exclude initial proto from benchmark
Thanks @ebryn and @kselden | benchmarks/suites/views/template_view.js | @@ -9,6 +9,8 @@ before(function() {
App.View = Ember.View.extend({
template: Ember.Handlebars.compile("{{view}}")
});
+
+ App.View.create().destroy();
});
after(function() { | false |
Other | emberjs | ember.js | 520a3bd36555316ed84db5172e48f771973a683c.json | Improve benchmark runner output | benchmarks/iframe_runner.js | @@ -69,12 +69,20 @@ BenchWarmer.prototype = {
run: function() {
if (this.profile) {
- console.profile(this.emberPath + ": " + this.name);
- for (var i=0; i<1000; i++) {
- this.fn();
- }
- console.profileEnd(this.emberPath + ": " + this.name);
- if (this.next) { this.next.run(); }
+ var self = this;
+
+ var count = parseInt(this.profile, 10);
+
+ setTimeout(function() {
+ self.setup();
+ console.profile(self.emberPath + ": " + self.name);
+ for (var i=0; i<count; i++) {
+ self.fn();
+ }
+ console.profileEnd(self.emberPath + ": " + self.name);
+ self.teardown();
+ if (self.next) { self.next.run(); }
+ }, 1);
} else {
this.benchmark.run();
} | true |
Other | emberjs | ember.js | 520a3bd36555316ed84db5172e48f771973a683c.json | Improve benchmark runner output | benchmarks/runner.js | @@ -9,6 +9,10 @@ function makeiframe(emberPath, suitePath, profile, callback) {
var iframe = jQuery("<iframe>").appendTo("body")[0];
var write = function(str) { iframe.contentDocument.write(str); };
+ var name = emberPath + ": " + suitePath;
+ iframe.name = name;
+
+ write("<title>" + name + "</title>");
write("<script src='../tests/jquery-1.7.1.js'></script>");
write("<script src='" + emberPath + "'></script>");
write("<script src='benchmark.js'></script>");
@@ -18,7 +22,7 @@ function makeiframe(emberPath, suitePath, profile, callback) {
var bench, before;
var logger = function(string) {
- jQuery("[data-ember-path='" + emberPath + "']").html(string);
+ jQuery("[data-ember-path='" + emberPath + "']").html(emberPath + ": " + string);
};
setTimeout(function() {
@@ -31,7 +35,7 @@ function makeiframe(emberPath, suitePath, profile, callback) {
callback(bench);
}
});
- }, 1000);
+ }, 2000);
}
jQuery(function() { | true |
Other | emberjs | ember.js | 9a4c350826898375aec71d638e537f3aae9ca3c0.json | Remove extra get call | packages/ember-handlebars/lib/helpers/collection.js | @@ -62,7 +62,7 @@ Ember.Handlebars.registerHelper('collection', function(path, options) {
}
}
- var tagName = hash.tagName || get(collectionClass, 'proto').tagName;
+ var tagName = hash.tagName || collectionPrototype.tagName;
if (fn) {
itemHash.template = fn; | false |
Other | emberjs | ember.js | e84fde145cbd6feae68d0b12fb164cf44fec42a7.json | Remove references to inactive guides. - Fixes #571. | README.md | @@ -92,8 +92,6 @@ For new users, we recommend downloading the [Ember.js Starter Kit](https://githu
We also recommend that you check out the [annotated Todos example](http://annotated-todos.strobeapp.com/), which shows you the best practices for architecting an MVC-based web application. You can also [browse or fork the code on Github](https://github.com/emberjs/todos).
-[Guides are available](http://guides.sproutcore20.com/) for Ember.js. If you find an error, please [fork the guides on GitHub](https://github.com/sproutcore/sproutguides/tree/v2.0) and submit a pull request. (Note that Ember.js guides are on the `v2.0` branch.)
-
# Building Ember.js
NOTE: Due to the rename, these instructions may be in flux | false |
Other | emberjs | ember.js | 93193d68ea496e67d00831fd93017a71686c4ba0.json | Run jshint with tests now | .travis.yml | @@ -3,5 +3,4 @@ rvm:
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- - "npm install -g jshint"
-script: "rake test[all] && rake jshint"
+script: "rake test[all]" | true |
Other | emberjs | ember.js | 93193d68ea496e67d00831fd93017a71686c4ba0.json | Run jshint with tests now | Assetfile | @@ -23,6 +23,16 @@ class EmberLicenseFilter < Rake::Pipeline::Filter
end
end
+class JSHintRC < Rake::Pipeline::Filter
+ def generate_output(inputs, output)
+ inputs.each do |input|
+ file = File.read(input.fullpath)
+ jshintrc = File.read(".jshintrc")
+ output.write "var JSHINTRC = #{jshintrc};\n\n#{file}"
+ end
+ end
+end
+
distros = {
:runtime => %w(ember-metal ember-runtime),
:full => %w(handlebars ember-metal ember-runtime ember-views ember-states metamorph ember-handlebars)
@@ -44,6 +54,10 @@ input "packages" do
concat "ember-tests.js"
end
+
+ match "ember-tests.js" do
+ filter JSHintRC
+ end
end
input "packages" do | true |
Other | emberjs | ember.js | 93193d68ea496e67d00831fd93017a71686c4ba0.json | Run jshint with tests now | Rakefile | @@ -288,21 +288,6 @@ namespace :docs do
end
end
-desc "Run jshint"
-task :jshint do
- unless system("which jshint > /dev/null 2>&1")
- abort "Please install jshint. `npm install -g jshint`"
- end
-
- if system("jshint packages/ember*")
- puts "The JavaScript is clean".green
- else
- puts "The JavaScript is dirty".red
- exit(1)
- end
-end
-
-
desc "Run tests with phantomjs"
task :test, [:suite] => :dist do |t, args|
unless system("which phantomjs > /dev/null 2>&1")
@@ -311,7 +296,11 @@ task :test, [:suite] => :dist do |t, args|
suites = {
:default => ["package=all"],
- :all => ["package=all", "package=all&jquery=1.6.4", "package=all&extendprototypes=true", "package=all&extendprototypes=true&jquery=1.6.4"]
+ :all => ["package=all",
+ "package=all&jquery=1.6.4&nojshint=true",
+ "package=all&extendprototypes=true&nojshint=true",
+ "package=all&extendprototypes=true&jquery=1.6.4&nojshint=true",
+ "package=all&dist=build"]
}
suite = args[:suite] || :default | true |
Other | emberjs | ember.js | 93193d68ea496e67d00831fd93017a71686c4ba0.json | Run jshint with tests now | tests/index.html | @@ -5,6 +5,39 @@
<title>QUnit Test Suite</title>
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="qunit/qunit.js"></script>
+ <script type="text/javascript" src="jshint.js"></script>
+ <script type="text/javascript" src="minispade.js"></script>
+
+ <script type="text/javascript">
+ // Handle JSHint
+ QUnit.config.urlConfig.push('nojshint');
+
+ var noJsHint = location.search.match(/nojshint=([^&]+)/);
+ jsHint = !(noJsHint && decodeURIComponent(noJsHint[1]));
+
+ var jsHintReporter = function (file, errors) {
+ var len = errors.length,
+ str = '',
+ error;
+
+ errors.forEach(function (error) {
+ str += file + ': line ' + error.line + ', col ' +
+ error.character + ', ' + error.reason + '\n';
+ });
+
+ if (str) {
+ return str + "\n" + len + ' error' + ((len === 1) ? '' : 's');
+ }
+ }
+
+
+ // Handle extending prototypes
+ QUnit.config.urlConfig.push('extendprototypes');
+
+ window.ENV = window.ENV || {};
+ var extendPrototypes = location.search.match(/extendprototypes=([^&]+)/);
+ ENV['EXTEND_PROTOTYPES'] = !!(extendPrototypes && decodeURIComponent(extendPrototypes[1]));
+ </script>
</head>
<body>
<h1 id="qunit-header">QUnit Test Suite</h1>
@@ -30,30 +63,30 @@ <h2 id="qunit-userAgent"></h2>
if (console && console.warn) { console.warn("Unable to load jQuery "+jQueryVersion+". Using default."); }
document.write(unescape('%3Cscript src="jquery-1.7.1.js"%3E%3C/script%3E'));
}
+ // Close the script tag to make sure document.write happens
</script>
- <script type="text/javascript">
- // Handle extending prototypes
- QUnit.config.urlConfig.push('extendprototypes');
-
- window.ENV = window.ENV || {};
- var extendPrototypes = location.search.match(/extendprototypes=([^&]+)/);
- ENV['EXTEND_PROTOTYPES'] = !!(extendPrototypes && decodeURIComponent(extendPrototypes[1]));
- </script>
-
- <script type="text/javascript" src="minispade.js"></script>
-
<script>
// Load ember distribution from query vars
var distMatch = location.search.match(/dist=([^&]+)/),
- dist = distMatch && distMatch[1],
- emberPath = "../dist/ember"+(dist ? '-' + dist : '')+".js";
- document.write(unescape('%3Cscript src="'+emberPath+'"%3E%3C/script%3E'));
+ dist = (distMatch && distMatch[1]) || 'spade';
+
+ var distros = {
+ spade: 'ember-spade.js',
+ build: 'ember.js',
+ runtime: 'ember-runtime.js'
+ };
+
+ var emberFile = distros[dist];
+ if (!emberFile) { throw 'Unknown dist'; }
+
+ document.write(unescape('%3Cscript src="../dist/'+emberFile+'"%3E%3C/script%3E'));
+ // Close the script tag to make sure document.write happens
</script>
<script type="text/javascript" src="ember-tests.js"></script>
- <script>
+ <script type="text/javascript">
// hack qunit to not suck for Ember objects
var originalTypeof = QUnit.jsDump.typeOf;
@@ -111,8 +144,23 @@ <h2 id="qunit-userAgent"></h2>
if (!minispade.modules.hasOwnProperty(moduleName)) { continue; }
match = moduleName.match(re);
- if (match && match[1] === '~tests') {
- minispade.require(moduleName);
+ if (match) {
+ if (match[1] === '~tests') {
+ // Only require the actual tests since we already required the module
+ minispade.require(moduleName);
+ }
+
+ if (jsHint) {
+ // JSHint all modules in this package, tests and code
+ // (closure to preserve variable values)
+ (function() {
+ var jshintModule = moduleName;
+ test(jshintModule+' should pass jshint', function() {
+ var result = JSHINT(minispade.modules[jshintModule], JSHINTRC);
+ ok(result, jshintModule+" should pass jshint.\n" + jsHintReporter(jshintModule, JSHINT.errors));
+ });
+ })();
+ }
}
}
} | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.