Dbrant has uploaded a new change for review.
https://gerrit.wikimedia.org/r/246837
Change subject: Hygiene: remove unnecessary cruft from JavaScript bridge.
......................................................................
Hygiene: remove unnecessary cruft from JavaScript bridge.
- Removed API 10-specific file.
- Removed test-specific functions from the main Bundle.
Change-Id: I5213841eb4e26117cb0099434a86f3ac2cd4c383
---
M app/src/main/assets/bundle-test.js
M app/src/main/assets/bundle.js
M app/src/main/assets/preview.js
M www/Gruntfile.js
D www/lib/js/classList.js
5 files changed, 8 insertions(+), 332 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia
refs/changes/37/246837/1
diff --git a/app/src/main/assets/bundle-test.js
b/app/src/main/assets/bundle-test.js
index 01a24cf..aa6a977 100644
--- a/app/src/main/assets/bundle-test.js
+++ b/app/src/main/assets/bundle-test.js
@@ -143,92 +143,15 @@
module.exports = new Transformer();
},{}],5:[function(require,module,exports){
-/**
- * MIT LICENSCE
- * From: https://github.com/remy/polyfills
- * FIXME: Don't copy paste libraries, use a dep management system.
- */
-(function () {
-
-if (typeof window.Element === "undefined" || "classList" in
document.documentElement) return;
-
-var prototype = Array.prototype,
- push = prototype.push,
- splice = prototype.splice,
- join = prototype.join;
-
-function DOMTokenList(el) {
- this.el = el;
- // The className needs to be trimmed and split on whitespace
- // to retrieve a list of classes.
- var classes = el.className.replace(/^\s+|\s+$/g,'').split(/\s+/);
- for (var i = 0; i < classes.length; i++) {
- push.call(this, classes[i]);
- }
-};
-
-DOMTokenList.prototype = {
- add: function(token) {
- if(this.contains(token)) return;
- push.call(this, token);
- this.el.className = this.toString();
- },
- contains: function(token) {
- return this.el.className.indexOf(token) != -1;
- },
- item: function(index) {
- return this[index] || null;
- },
- remove: function(token) {
- if (!this.contains(token)) return;
- for (var i = 0; i < this.length; i++) {
- if (this[i] == token) break;
- }
- splice.call(this, i, 1);
- this.el.className = this.toString();
- },
- toString: function() {
- return join.call(this, ' ');
- },
- toggle: function(token) {
- if (!this.contains(token)) {
- this.add(token);
- } else {
- this.remove(token);
- }
-
- return this.contains(token);
- }
-};
-
-window.DOMTokenList = DOMTokenList;
-
-function defineElementGetter (obj, prop, getter) {
- if (Object.defineProperty) {
- Object.defineProperty(obj, prop,{
- get : getter
- });
- } else {
- obj.__defineGetter__(prop, getter);
- }
-}
-
-defineElementGetter(Element.prototype, 'classList', function () {
- return new DOMTokenList(this);
-});
-
-})();
-
-},{}],6:[function(require,module,exports){
var bridge = require("../js/bridge");
bridge.registerListener( "injectScript", function( payload ) {
require(payload.src);
});
-},{"../js/bridge":1}],7:[function(require,module,exports){
+},{"../js/bridge":1}],6:[function(require,module,exports){
var bridge = require("../js/bridge");
console.log("Something!");
bridge.registerListener( "ping", function( payload ) {
bridge.sendMessage( "pong", payload );
});
-},{"../js/bridge":1}]},{},[2,3,1,6,7,5])
\ No newline at end of file
+},{"../js/bridge":1}]},{},[2,3,1,5,6])
\ No newline at end of file
diff --git a/app/src/main/assets/bundle.js b/app/src/main/assets/bundle.js
index d587347..e5be35b 100644
--- a/app/src/main/assets/bundle.js
+++ b/app/src/main/assets/bundle.js
@@ -1343,93 +1343,4 @@
firstAncestorWithMultipleChildren: firstAncestorWithMultipleChildren
};
-},{}],25:[function(require,module,exports){
-/**
- * MIT LICENSCE
- * From: https://github.com/remy/polyfills
- * FIXME: Don't copy paste libraries, use a dep management system.
- */
-(function () {
-
-if (typeof window.Element === "undefined" || "classList" in
document.documentElement) return;
-
-var prototype = Array.prototype,
- push = prototype.push,
- splice = prototype.splice,
- join = prototype.join;
-
-function DOMTokenList(el) {
- this.el = el;
- // The className needs to be trimmed and split on whitespace
- // to retrieve a list of classes.
- var classes = el.className.replace(/^\s+|\s+$/g,'').split(/\s+/);
- for (var i = 0; i < classes.length; i++) {
- push.call(this, classes[i]);
- }
-};
-
-DOMTokenList.prototype = {
- add: function(token) {
- if(this.contains(token)) return;
- push.call(this, token);
- this.el.className = this.toString();
- },
- contains: function(token) {
- return this.el.className.indexOf(token) != -1;
- },
- item: function(index) {
- return this[index] || null;
- },
- remove: function(token) {
- if (!this.contains(token)) return;
- for (var i = 0; i < this.length; i++) {
- if (this[i] == token) break;
- }
- splice.call(this, i, 1);
- this.el.className = this.toString();
- },
- toString: function() {
- return join.call(this, ' ');
- },
- toggle: function(token) {
- if (!this.contains(token)) {
- this.add(token);
- } else {
- this.remove(token);
- }
-
- return this.contains(token);
- }
-};
-
-window.DOMTokenList = DOMTokenList;
-
-function defineElementGetter (obj, prop, getter) {
- if (Object.defineProperty) {
- Object.defineProperty(obj, prop,{
- get : getter
- });
- } else {
- obj.__defineGetter__(prop, getter);
- }
-}
-
-defineElementGetter(Element.prototype, 'classList', function () {
- return new DOMTokenList(this);
-});
-
-})();
-
-},{}],26:[function(require,module,exports){
-var bridge = require("../js/bridge");
-bridge.registerListener( "injectScript", function( payload ) {
- require(payload.src);
-});
-},{"../js/bridge":2}],27:[function(require,module,exports){
-var bridge = require("../js/bridge");
-console.log("Something!");
-bridge.registerListener( "ping", function( payload ) {
- bridge.sendMessage( "pong", payload );
-});
-
-},{"../js/bridge":2}]},{},[2,7,24,12,13,14,15,16,17,18,19,20,21,22,23,1,3,4,5,6,8,9,10,11,25,26,27])
\ No newline at end of file
+},{}]},{},[2,7,24,12,13,14,15,16,17,18,19,20,21,22,23,1,3,4,5,6,8,9,10,11])
\ No newline at end of file
diff --git a/app/src/main/assets/preview.js b/app/src/main/assets/preview.js
index 7df3c2a..b03ed43 100644
--- a/app/src/main/assets/preview.js
+++ b/app/src/main/assets/preview.js
@@ -384,81 +384,4 @@
firstAncestorWithMultipleChildren: firstAncestorWithMultipleChildren
};
-},{}],8:[function(require,module,exports){
-/**
- * MIT LICENSCE
- * From: https://github.com/remy/polyfills
- * FIXME: Don't copy paste libraries, use a dep management system.
- */
-(function () {
-
-if (typeof window.Element === "undefined" || "classList" in
document.documentElement) return;
-
-var prototype = Array.prototype,
- push = prototype.push,
- splice = prototype.splice,
- join = prototype.join;
-
-function DOMTokenList(el) {
- this.el = el;
- // The className needs to be trimmed and split on whitespace
- // to retrieve a list of classes.
- var classes = el.className.replace(/^\s+|\s+$/g,'').split(/\s+/);
- for (var i = 0; i < classes.length; i++) {
- push.call(this, classes[i]);
- }
-};
-
-DOMTokenList.prototype = {
- add: function(token) {
- if(this.contains(token)) return;
- push.call(this, token);
- this.el.className = this.toString();
- },
- contains: function(token) {
- return this.el.className.indexOf(token) != -1;
- },
- item: function(index) {
- return this[index] || null;
- },
- remove: function(token) {
- if (!this.contains(token)) return;
- for (var i = 0; i < this.length; i++) {
- if (this[i] == token) break;
- }
- splice.call(this, i, 1);
- this.el.className = this.toString();
- },
- toString: function() {
- return join.call(this, ' ');
- },
- toggle: function(token) {
- if (!this.contains(token)) {
- this.add(token);
- } else {
- this.remove(token);
- }
-
- return this.contains(token);
- }
-};
-
-window.DOMTokenList = DOMTokenList;
-
-function defineElementGetter (obj, prop, getter) {
- if (Object.defineProperty) {
- Object.defineProperty(obj, prop,{
- get : getter
- });
- } else {
- obj.__defineGetter__(prop, getter);
- }
-}
-
-defineElementGetter(Element.prototype, 'classList', function () {
- return new DOMTokenList(this);
-});
-
-})();
-
-},{}]},{},[3,2,4,1,5,6,8])
\ No newline at end of file
+},{}]},{},[3,2,4,1,5,6])
\ No newline at end of file
diff --git a/www/Gruntfile.js b/www/Gruntfile.js
index 1274928..efe1321 100644
--- a/www/Gruntfile.js
+++ b/www/Gruntfile.js
@@ -14,16 +14,11 @@
"js/preview.js",
"js/rtlsupport.js",
"js/sections.js",
- "lib/js/classList.js",
"tests/*.js"
];
var allHTMLFiles = [
"index.html",
"tests/index.html"
- ];
- // FIXME: Unconditionally included polyfills. Should be included only for
Android 2.3
- var oldDroidPolyfills = [
- "lib/js/classList.js"
];
var distFolder = "../app/src/main/assets/";
@@ -52,15 +47,14 @@
"js/preview.js",
"js/rtlsupport.js",
"js/sections.js",
- "lib/js/classList.js",
- "tests/*.js"
- ].concat( oldDroidPolyfills ),
+ "lib/js/classList.js"
+ ],
"bundle-test.js": [
"js/loader.js",
"js/main.js",
"js/bridge.js",
"tests/*.js"
- ].concat( oldDroidPolyfills ),
+ ],
"preview.js": [
"js/loader.js",
"js/bridge.js",
@@ -69,7 +63,7 @@
"js/preview.js",
"js/rtlsupport.js",
"js/util.js"
- ].concat( oldDroidPolyfills )
+ ]
}
}
},
diff --git a/www/lib/js/classList.js b/www/lib/js/classList.js
deleted file mode 100644
index d41e033..0000000
--- a/www/lib/js/classList.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * MIT LICENSCE
- * From: https://github.com/remy/polyfills
- * FIXME: Don't copy paste libraries, use a dep management system.
- */
-(function () {
-
-if (typeof window.Element === "undefined" || "classList" in
document.documentElement) return;
-
-var prototype = Array.prototype,
- push = prototype.push,
- splice = prototype.splice,
- join = prototype.join;
-
-function DOMTokenList(el) {
- this.el = el;
- // The className needs to be trimmed and split on whitespace
- // to retrieve a list of classes.
- var classes = el.className.replace(/^\s+|\s+$/g,'').split(/\s+/);
- for (var i = 0; i < classes.length; i++) {
- push.call(this, classes[i]);
- }
-};
-
-DOMTokenList.prototype = {
- add: function(token) {
- if(this.contains(token)) return;
- push.call(this, token);
- this.el.className = this.toString();
- },
- contains: function(token) {
- return this.el.className.indexOf(token) != -1;
- },
- item: function(index) {
- return this[index] || null;
- },
- remove: function(token) {
- if (!this.contains(token)) return;
- for (var i = 0; i < this.length; i++) {
- if (this[i] == token) break;
- }
- splice.call(this, i, 1);
- this.el.className = this.toString();
- },
- toString: function() {
- return join.call(this, ' ');
- },
- toggle: function(token) {
- if (!this.contains(token)) {
- this.add(token);
- } else {
- this.remove(token);
- }
-
- return this.contains(token);
- }
-};
-
-window.DOMTokenList = DOMTokenList;
-
-function defineElementGetter (obj, prop, getter) {
- if (Object.defineProperty) {
- Object.defineProperty(obj, prop,{
- get : getter
- });
- } else {
- obj.__defineGetter__(prop, getter);
- }
-}
-
-defineElementGetter(Element.prototype, 'classList', function () {
- return new DOMTokenList(this);
-});
-
-})();
--
To view, visit https://gerrit.wikimedia.org/r/246837
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5213841eb4e26117cb0099434a86f3ac2cd4c383
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits