← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/misc-js-tidying into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/misc-js-tidying into lp:launchpad.

Commit message:
Fix various JS and CSS browser warnings.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/misc-js-tidying/+merge/327790

YUI causes enough warnings of its own that we probably can't get the browser console entirely clean as long as we're using it, but this at least cleans up some easily-avoidable noise.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/misc-js-tidying into lp:launchpad.
=== modified file 'lib/lp/app/javascript/client.js'
--- lib/lp/app/javascript/client.js	2015-10-22 00:15:41 +0000
+++ lib/lp/app/javascript/client.js	2017-07-20 13:50:08 +0000
@@ -370,6 +370,7 @@
                 // original_uri alone. Otherwise make the uri the object
                 // coming back.
                 if (Y.Lang.isValue(representation) &&
+                    Y.Object.owns(representation, 'self_link') &&
                     Y.Lang.isValue(representation.self_link) &&
                     method !== module.PATCH) {
                     uri = representation.self_link;
@@ -677,7 +678,8 @@
     module.Launchpad = function(config) {
         /* A client that makes HTTP requests to Launchpad's web service. */
         this.io_provider = module.get_configured_io_provider(config);
-        this.sync = (config ? config.sync : false);
+        this.sync = (
+            (config && Y.Object.owns(config, 'sync')) ? config.sync : false);
     };
 
     module.Launchpad.prototype = {

=== modified file 'lib/lp/app/javascript/effects/effects.js'
--- lib/lp/app/javascript/effects/effects.js	2013-03-20 03:41:40 +0000
+++ lib/lp/app/javascript/effects/effects.js	2017-07-20 13:50:08 +0000
@@ -48,7 +48,7 @@
 namespace.reversible_slide_out = function(node, user_cfg) {
     var cfg = Y.merge(namespace.slide_effect_defaults, user_cfg);
 
-    if (!Y.Lang.isValue(cfg.node)) {
+    if (!Y.Object.owns(cfg, 'node') || !Y.Lang.isValue(cfg.node)) {
         cfg.node = node;
     }
 

=== modified file 'lib/lp/app/javascript/expander.js'
--- lib/lp/app/javascript/expander.js	2015-02-19 03:23:11 +0000
+++ lib/lp/app/javascript/expander.js	2017-07-20 13:50:08 +0000
@@ -159,7 +159,8 @@
     }
     this.loaded = !Y.Lang.isValue(this.config.loader);
 
-    if (Y.Lang.isValue(this.config.animate_node)) {
+    if (Y.Object.owns(config, 'animate_node') &&
+            Y.Lang.isValue(this.config.animate_node)) {
         this._animate_node = Y.one(this.config.animate_node);
     } else {
         this._animate_node = this.content_node;

=== modified file 'lib/lp/app/javascript/longpoll.js'
--- lib/lp/app/javascript/longpoll.js	2013-06-06 06:17:27 +0000
+++ lib/lp/app/javascript/longpoll.js	2017-07-20 13:50:08 +0000
@@ -203,7 +203,8 @@
 };
 
 namespace.setupLongPollManager = function() {
-    if (Y.Lang.isValue(LP.cache.longpoll)) {
+    if (Y.Object.owns(LP.cache, 'longpoll') &&
+            Y.Lang.isValue(LP.cache.longpoll)) {
         var key = LP.cache.longpoll.key;
         var uri = LP.cache.longpoll.uri;
         var longpollmanager = namespace.getLongPollManager();

=== modified file 'lib/lp/app/javascript/overlay/assets/skins/sam/pretty-overlay-skin.css'
--- lib/lp/app/javascript/overlay/assets/skins/sam/pretty-overlay-skin.css	2012-06-29 23:48:16 +0000
+++ lib/lp/app/javascript/overlay/assets/skins/sam/pretty-overlay-skin.css	2017-07-20 13:50:08 +0000
@@ -14,7 +14,7 @@
 .yui3-pretty-overlay #yui3-pretty-overlay-modal {
     margin: 7px 0px;
     padding: 0;
-    font: normal normal 12px/normal;
+    font-size: 12px;
     color: #484848;
     background: #fff;
 }
@@ -22,7 +22,7 @@
 .yui3-pretty-overlay .close {
     margin: 0;
     padding: 0 5px;
-    font: normal normal 10px/normal;
+    font-size: 10px;
     color: #484848;
     background: #fff;
 }
@@ -44,7 +44,7 @@
 
 .yui3-pretty-overlay #yui3-pretty-overlay-modal h1,
 .yui3-pretty-overlay #yui3-pretty-overlay-modal h2 {
-    font: normal normal 18px/normal;
+    font-size: 18px;
     color: #000;
     text-indent: 15px;
     margin: 0;
@@ -53,13 +53,14 @@
 
 .yui3-pretty-overlay #yui3-pretty-overlay-modal h2 {
     height: 30px;
-    font: normal normal 18px;
+    font-size: 18px;
     color: #000;
 }
 
 .yui3-pretty-overlay #yui3-pretty-overlay-modal .steps h2 {
     height: 30px;
-    font: normal normal 14px/30px;
+    font-size: 14px;
+    line-height: 30px;
     color: #666;
 }
 

=== modified file 'lib/lp/app/javascript/picker/person_picker.js'
--- lib/lp/app/javascript/picker/person_picker.js	2012-08-27 20:13:49 +0000
+++ lib/lp/app/javascript/picker/person_picker.js	2017-07-20 13:50:08 +0000
@@ -33,6 +33,8 @@
                 ctns.TEAM_CREATED, function(e) {
                     this.fire('save', e.details[0]);
                 }, this);
+        } else {
+            this.new_team_widget = null;
         }
     },
 

=== modified file 'lib/lp/app/javascript/picker/picker.js'
--- lib/lp/app/javascript/picker/picker.js	2013-04-09 05:05:39 +0000
+++ lib/lp/app/javascript/picker/picker.js	2017-07-20 13:50:08 +0000
@@ -154,7 +154,8 @@
 
         if (!Y.Lang.isUndefined(cfg)) {
             // The picker's associated field.
-            if (Y.Lang.isValue(cfg.associated_field_id)) {
+            if (Y.Object.owns(cfg, 'associated_field_id') &&
+                    Y.Lang.isValue(cfg.associated_field_id)) {
                 this.plug(TextFieldPickerPlugin,
                             {input_element:
                                 '[id="'+cfg.associated_field_id+'"]'});
@@ -732,7 +733,7 @@
         body.addClass('yui3-widget-bd');
 
         this.setStdModContent(
-            Y.WidgetStdMod.BODY, body, Y.WidgetStdMod.APPEND);
+            Y.WidgetStdMod.BODY, body, Y.WidgetStdMod.REPLACE);
     },
 
     /**

=== modified file 'lib/lp/app/javascript/picker/picker_patcher.js'
--- lib/lp/app/javascript/picker/picker_patcher.js	2016-09-12 19:41:46 +0000
+++ lib/lp/app/javascript/picker/picker_patcher.js	2017-07-20 13:50:08 +0000
@@ -503,7 +503,8 @@
         user_has_searched = false;
     });
 
-    if (Y.Lang.isValue(config.extra_no_results_message)) {
+    if (Y.Object.owns(config, 'extra_no_results_message') &&
+            Y.Lang.isValue(config.extra_no_results_message)) {
         picker.before('resultsChange', function (e) {
             var new_results = e.details[0].newVal;
             if (new_results.length === 0) {

=== modified file 'lib/lp/app/javascript/subscribers/subscribers_list.js'
--- lib/lp/app/javascript/subscribers/subscribers_list.js	2012-06-26 00:15:11 +0000
+++ lib/lp/app/javascript/subscribers/subscribers_list.js	2017-07-20 13:50:08 +0000
@@ -74,8 +74,9 @@
     }
     var config_var;
     for (config_var in CONFIG_DEFAULTS) {
-        if (CONFIG_DEFAULTS.hasOwnProperty(config_var)) {
-            if (Y.Lang.isString(config[config_var])) {
+        if (Y.Object.owns(CONFIG_DEFAULTS, config_var)) {
+            if (Y.Object.owns(config, config_var) &&
+                    Y.Lang.isString(config[config_var])) {
                 this[config_var] = config[config_var];
             } else {
                 this[config_var] = CONFIG_DEFAULTS[config_var];
@@ -110,15 +111,18 @@
     };
 
     // Allow tests to override lp_client.
-    if (Y.Lang.isValue(config.lp_client)) {
+    if (Y.Object.owns(config, 'lp_client') &&
+            Y.Lang.isValue(config.lp_client)) {
         this.lp_client = config.lp_client;
     } else {
         this.lp_client = new Y.lp.client.Launchpad();
     }
 
     // Check for CSS class for the link to subscribe someone me.
-    if (Y.Lang.isString(config.subscribe_me_link)) {
-        if (!Y.Lang.isString(config.subscribe_me_level)) {
+    if (Y.Object.owns(config, 'subscribe_me_link') &&
+            Y.Lang.isString(config.subscribe_me_link)) {
+        if (!Y.Object.owns(config, 'subscribe_me_level') ||
+                !Y.Lang.isString(config.subscribe_me_level)) {
             Y.error("No config.subscribe_me_level specified.");
         }
         this.subscribe_me_link = config.subscribe_me_link;
@@ -137,7 +141,8 @@
     // Should the current user be shown in the subscribers list if they are in
     // the subscriber results or use the Subscribe Me link.
     this.display_me_in_list = false;
-    if (Y.Lang.isBoolean(config.display_me_in_list)) {
+    if (Y.Object.owns(config, 'display_me_in_list') &&
+            Y.Lang.isBoolean(config.display_me_in_list)) {
         this.display_me_in_list = config.display_me_in_list;
     }
 
@@ -145,8 +150,10 @@
     this._loadSubscribers();
 
     // Check for CSS class for the link to subscribe someone else.
-    if (Y.Lang.isString(config.subscribe_someone_else_link)) {
-        if (!Y.Lang.isString(config.subscribe_someone_else_level)) {
+    if (Y.Object.owns(config, 'subscribe_someone_else_link') &&
+            Y.Lang.isString(config.subscribe_someone_else_link)) {
+        if (!Y.Object.owns(config, 'subscribe_someone_else_level') ||
+                !Y.Lang.isString(config.subscribe_someone_else_level)) {
             Y.error("No config.subscribe_someone_else_level specified.");
         }
         this.subscribe_someone_else_link = config.subscribe_someone_else_link;
@@ -260,7 +267,8 @@
         // We may need to set up the subscribe me link.
         // This has to be done after subscribers have been loaded so that we
         // know if the current user is currently subscribed.
-        if (Y.Lang.isString(loader.subscribe_me_link)) {
+        if (Y.Object.owns(loader, 'subscribe_me_link') &&
+                Y.Lang.isString(loader.subscribe_me_link)) {
             loader._setupSubscribeMe();
         }
         loader.subscribers_list.stopActivity();
@@ -315,7 +323,8 @@
             }
             // If we have just unsubscribed ourselves, we need to update the
             // "subscribe me" link.
-            if (is_me && Y.Lang.isString(loader.subscribe_me_link)) {
+            if (is_me && Y.Object.owns(loader, 'subscribe_me_link') &&
+                    Y.Lang.isString(loader.subscribe_me_link)) {
                 loader._updateSubscribeMeLink(false);
             }
         }
@@ -495,7 +504,8 @@
         }
         // If we have just subscribed ourselves, we need to update the
         // "unsubscribe me" link and wire up the unsubscribe function.
-        if (is_me && loader.subscribe_me_link) {
+        if (is_me && Y.Object.owns(loader, 'subscribe_me_link') &&
+                loader.subscribe_me_link) {
             loader._unsubscribe_me = function() {
                 unsubscribe_callback(
                     loader.subscribers_list, subscriber);
@@ -627,7 +637,7 @@
     if (activity_node === null) {
         activity_node = Y.Node.create('<div />')
             .addClass(CSS_CLASSES.activity);
-        progress_icon = Y.Node.create('<img />')
+        var progress_icon = Y.Node.create('<img />')
             .set('src', '/@@/spinner');
         activity_node.appendChild(progress_icon);
         activity_node.appendChild(
@@ -932,7 +942,8 @@
     } else {
         subscriber_text.addClass('person');
     }
-    if (Y.Lang.isString(subscriber.display_subscribed_by)) {
+    if (Y.Object.owns(subscriber, 'display_subscribed_by') &&
+            Y.Lang.isString(subscriber.display_subscribed_by)) {
         subscriber_link.set('title', subscriber.display_subscribed_by);
     }
     subscriber_link.appendChild(subscriber_text);

=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
--- lib/lp/app/templates/base-layout-macros.pt	2017-04-14 10:03:39 +0000
+++ lib/lp/app/templates/base-layout-macros.pt	2017-07-20 13:50:08 +0000
@@ -102,7 +102,7 @@
       // we need this to create a single YUI instance all events and code
       // talks across. All instances of YUI().use should be based off of
       // LPJS instead.
-      LPJS = new YUI();
+      var LPJS = new YUI();
   </script>
 
 </metal:load-javascript>

=== modified file 'lib/lp/bugs/javascript/bug_picker.js'
--- lib/lp/bugs/javascript/bug_picker.js	2015-10-22 00:13:43 +0000
+++ lib/lp/bugs/javascript/bug_picker.js	2017-07-20 13:50:08 +0000
@@ -17,6 +17,8 @@
 namespace.BugPicker = Y.Base.create(
         "bugPickerWidget", Y.lp.ui.picker.Picker, [], {
     initializer: function(cfg) {
+        this.bug_details_node = null;
+        this.save_button = null;
         this.io_provider = Y.lp.client.get_configured_io_provider(cfg);
         var that = this;
         this.after('search', function(e) {

=== modified file 'lib/lp/bugs/javascript/bug_subscription_portlet.js'
--- lib/lp/bugs/javascript/bug_subscription_portlet.js	2014-01-30 15:04:06 +0000
+++ lib/lp/bugs/javascript/bug_subscription_portlet.js	2017-07-20 13:50:08 +0000
@@ -262,7 +262,7 @@
     // send across, it returns a link node with the click handler properly
     // set.
     var make_action = function(text, css_class, method_name, parameters) {
-        result = make_link(text, css_class)
+        var result = make_link(text, css_class)
             .addClass('js-action');
         result.on('click', function (e) {
             e.halt();

=== modified file 'lib/lp/bugs/templates/official-bug-target-manage-tags.pt'
--- lib/lp/bugs/templates/official-bug-target-manage-tags.pt	2012-04-26 14:01:51 +0000
+++ lib/lp/bugs/templates/official-bug-target-manage-tags.pt	2017-07-20 13:50:08 +0000
@@ -7,13 +7,6 @@
   i18n:domain="launchpad"
 >
   <body>
-  <metal:block fill-slot="head_epilogue">
-    <link rel="stylesheet" type="text/css"
-      tal:attributes="href string:${icingroot}/lazr/build/overlay/assets/pretty-overlay-core.css" />
-    <link rel="stylesheet" type="text/css"
-          tal:attributes="href string:${icingroot}/lazr/build/overlay/assets/skins/sam/pretty-overlay-skin.css" />
-  </metal:block>
-
   <div metal:fill-slot="main">
     <div class="yui-g">
       <div class="yui-u first">


Follow ups