Skip to content

Commit

Permalink
ForEach Erweiterung
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogeyx committed Sep 13, 2017
1 parent 1ffd866 commit 37f2398
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 2 deletions.
Binary file modified SimpleValidationSrc/.vs/SimpleValidationSrc/v15/.suo
Binary file not shown.
9 changes: 9 additions & 0 deletions SimpleValidationSrc/Typescript/validation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SimpleValidationSrc/Typescript/validation.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions SimpleValidationSrc/Typescript/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
var sel = (selector: string) => document.querySelector(selector) as HTMLElement;
var selAll = (selector: string) => document.querySelectorAll(selector) as NodeListOf<HTMLElement>;

// Eine ForEach Erweiterung für alle Enumerables
function forEach(callback: (index: number, value: Object) => void, scope?) {
let _this: Array<any> = this ? this : scope;
for (var i = 0; i < _this.length; i++) {
callback.call(scope, i, _this[i]); // passes back stuff we need
}
};

// Direkte ForEach Erweiterung für NodeList
interface NodeList {
forEach(callback: (index: number, value: Node) => void, scope?): void;
}
interface NodeListOf<TNode extends Node> {
forEach(callback: (index: number, value: TNode) => void, scope?): void;
}
(<any>NodeList.prototype).forEach = forEach;

/// Das Validierungs-Plugin
class Validation {
constructor() {
Expand Down
9 changes: 9 additions & 0 deletions dist/simpleValidation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 37f2398

Please sign in to comment.