Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

refactor(bootstrap): Remove support for old bootstrap mechanisms #8147

Closed
wants to merge 1 commit into from

Conversation

lgalfaso
Copy link
Contributor

Remove support for bootstrap detection using the element id or the element class. E.g.

<div id="ng-app">...</div>
<div class="ng-app: module">...</div>

Removes reference to bootstrap using IE7

BREAKING CHANGE:

If using any of the mechanisms specified above, then migrate by
specifying the attribute ng-app to the root element. E.g.

<div ng-app="module"

@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#8147)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

Sorry, something went wrong.

@lgalfaso lgalfaso added cla: yes and removed cla: no labels Jul 11, 2014
forEach(element.querySelectorAll('.' + name + '\\:'), append);
forEach(element.querySelectorAll('[' + name + ']'), append);
}
forEach(element.querySelectorAll('[' + name.replace(':', '\\:') + ']'), append);
Copy link
Contributor

Choose a reason for hiding this comment

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

now that things are much simpler how about we just use querySelector instead and create a single query containing all possible attributes. That way we'll find the first appElement in one query. We can then iterate over the list of names to get the module name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree

@IgorMinar
Copy link
Contributor

nice cleanup! I suggested more refactorings...

@lgalfaso lgalfaso self-assigned this Jul 13, 2014
@IgorMinar
Copy link
Contributor

Please also mention in the commit message that class based bootstrap no longer works.

@caitp
Copy link
Contributor

caitp commented Jul 13, 2014

how much does it really gain us to remove these, from app startup time? It's not very much code being thrown away, so it's not clear to me that it's necessarily worth breaking legacy apps even further by doing this.

don't take this as a strong objection or anything, I don't care all that much, but at this point it's like breaking things for no real reason --- what do we get out of it?

});
elements.push.apply(elements, element.querySelectorAll(query));

forEach(elements, function(element) {
Copy link
Contributor

Choose a reason for hiding this comment

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

how about we get rid of this and the other nested forEach and move the module name lookup logic into the forEach above?

That would mean that instead of building up the query, we'll actually use querySelector to find the first matching element (we don't need querySelectorAll since we bootstrap only the first one). This way everything is much simple and more efficient for the ng-app use case and we still support the other attribute names.

We should also reorder the the names array to list ng-app followed by data-ng-app as the first two names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@IgorMinar will update the PR, note that we will still need 2 forEach (even when these will not be nested) as we need to give priority to element over what we find using querySelector. This is, if element has the attribute data-ng-app and within the document there is another element with the attribute ng-app then we need to bootstrap element

@IgorMinar
Copy link
Contributor

@caitp with the other suggestions I made in #8147 (comment) we are making the code smaller, faster and easier to understand, while dropping support for obscure use-cases that as far as I know nobody uses. If someone really cares about these use-cases (e.g. the class based bootstrap), I'm sure that we'll hear about it.

You know better than others that I'm very conservative about breaking changes, but if we can make our code significantly cleaner by dropping support for features that nobody uses (or nobody even knows about) then we should do it.

@IgorMinar
Copy link
Contributor

@lgalfaso also this commit should be categorized as refactor and not chore.

Remove support for bootstrap detection using:

* The element id
* The element class.

E.g.

```
<div id="ng-app">...</div>
<div class="ng-app: module">...</div>
```

Removes reference to how to bootstrap using IE7

BREAKING CHANGE:

If using any of the mechanisms specified above, then migrate by
specifying the attribute `ng-app` to the root element. E.g.

```
<div ng-app="module">...</div>
```
@lgalfaso lgalfaso changed the title chore(bootstrap): Remove support for old bootstrap mechnanisms refactor(bootstrap): Remove support for old bootstrap mechnanisms Jul 13, 2014
@btford btford changed the title refactor(bootstrap): Remove support for old bootstrap mechnanisms refactor(bootstrap): Remove support for old bootstrap mechanisms Jul 14, 2014
@IgorMinar IgorMinar assigned IgorMinar and unassigned lgalfaso Jul 14, 2014
@lgalfaso lgalfaso closed this in 666a383 Jul 16, 2014
ckknight pushed a commit to ckknight/angular.js that referenced this pull request Jul 16, 2014
Remove support for bootstrap detection using:

* The element id
* The element class.

E.g.

```
<div id="ng-app">...</div>
<div class="ng-app: module">...</div>
```

Removes reference to how to bootstrap using IE7

BREAKING CHANGE:

If using any of the mechanisms specified above, then migrate by
specifying the attribute `ng-app` to the root element. E.g.

```
<div ng-app="module">...</div>
```

Closes angular#8147
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants