OLD | NEW |
---|---|
1 // Copyright 2006 Google Inc. | 1 // Copyright 2006 Google Inc. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
816 | 816 |
817 /** | 817 /** |
818 * Helps to implement the transclude attribute, and is the initial | 818 * Helps to implement the transclude attribute, and is the initial |
819 * call to get hold of a template from its ID. | 819 * call to get hold of a template from its ID. |
820 * | 820 * |
821 * If the ID is not present in the DOM, and opt_loadHtmlFn is specified, this | 821 * If the ID is not present in the DOM, and opt_loadHtmlFn is specified, this |
822 * function will call that function and add the result to the DOM, before | 822 * function will call that function and add the result to the DOM, before |
823 * returning the template. | 823 * returning the template. |
824 * | 824 * |
825 * @param {string} name The ID of the HTML element used as template. | 825 * @param {string} name The ID of the HTML element used as template. |
826 * @param {Function} opt_loadHtmlFn A function which, when called, will return | 826 * @param {Function=} opt_loadHtmlFn A function which, when called, will return |
827 * HTML that contains an element whose ID is 'name'. | 827 * HTML that contains an element whose ID is 'name'. |
828 * | 828 * |
829 * @return {Element|null} The DOM node of the template. (Only element nodes | 829 * @return {Element|null} The DOM node of the template. (Only element nodes |
830 * can be found by ID, hence it's a Element.) | 830 * can be found by ID, hence it's a Element.) |
831 */ | 831 */ |
832 function jstGetTemplate(name, opt_loadHtmlFn) { | 832 function jstGetTemplate(name, opt_loadHtmlFn) { |
833 var doc = document; | 833 var doc = document; |
834 var section; | 834 var section; |
835 if (opt_loadHtmlFn) { | 835 if (opt_loadHtmlFn) { |
836 section = jstLoadTemplateIfNotPresent(doc, name, opt_loadHtmlFn); | 836 section = jstLoadTemplateIfNotPresent(doc, name, opt_loadHtmlFn); |
(...skipping 16 matching lines...) Expand all Loading... | |
853 * | 853 * |
854 * @param {string} name The ID of the HTML element used as template. | 854 * @param {string} name The ID of the HTML element used as template. |
855 * @param {Function} opt_loadHtmlFn A function which, when called, will return | 855 * @param {Function} opt_loadHtmlFn A function which, when called, will return |
856 * HTML that contains an element whose ID is 'name'. | 856 * HTML that contains an element whose ID is 'name'. |
857 * | 857 * |
858 * @return {Element} The DOM node of the template. (Only element nodes | 858 * @return {Element} The DOM node of the template. (Only element nodes |
859 * can be found by ID, hence it's a Element.) | 859 * can be found by ID, hence it's a Element.) |
860 */ | 860 */ |
861 function jstGetTemplateOrDie(name, opt_loadHtmlFn) { | 861 function jstGetTemplateOrDie(name, opt_loadHtmlFn) { |
862 var x = jstGetTemplate(name, opt_loadHtmlFn); | 862 var x = jstGetTemplate(name, opt_loadHtmlFn); |
863 check(x !== null); | 863 if (x === null) { |
864 throw new Error('jstGetTemplate() returned null'); | |
865 } | |
864 return /** @type Element */(x); | 866 return /** @type Element */(x); |
Dan Beam
2014/09/26 02:23:09
shouldn't this be @type {Element} ?
Vitaly Pavlenko
2014/09/26 18:31:39
It works anyways, but that's a good nit. Done.
| |
865 } | 867 } |
866 | 868 |
867 | 869 |
868 /** | 870 /** |
869 * If an element with id 'name' is not present in the document, call loadHtmlFn | 871 * If an element with id 'name' is not present in the document, call loadHtmlFn |
870 * and insert the result into the DOM. | 872 * and insert the result into the DOM. |
871 * | 873 * |
872 * @param {Document} doc | 874 * @param {Document} doc |
873 * @param {string} name | 875 * @param {string} name |
874 * @param {Function} loadHtmlFn A function that returns HTML to be inserted | 876 * @param {Function} loadHtmlFn A function that returns HTML to be inserted |
875 * into the DOM. | 877 * into the DOM. |
876 * @param {string} opt_target The id of a DOM object under which to attach the | 878 * @param {string=} opt_target The id of a DOM object under which to attach the |
877 * HTML once it's inserted. An object with this id is created if it does not | 879 * HTML once it's inserted. An object with this id is created if it does not |
878 * exist. | 880 * exist. |
879 * @return {Element} The node whose id is 'name' | 881 * @return {Element} The node whose id is 'name' |
880 */ | 882 */ |
881 function jstLoadTemplateIfNotPresent(doc, name, loadHtmlFn, opt_target) { | 883 function jstLoadTemplateIfNotPresent(doc, name, loadHtmlFn, opt_target) { |
882 var section = domGetElementById(doc, name); | 884 var section = domGetElementById(doc, name); |
883 if (section) { | 885 if (section) { |
884 return section; | 886 return section; |
885 } | 887 } |
886 // Load any necessary HTML and try again. | 888 // Load any necessary HTML and try again. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
949 | 951 |
950 /** | 952 /** |
951 * Log the current state. | 953 * Log the current state. |
952 * @param {string} caller An identifier for the caller of .log_. | 954 * @param {string} caller An identifier for the caller of .log_. |
953 * @param {Element} template The template node being processed. | 955 * @param {Element} template The template node being processed. |
954 * @param {Object} jstAttributeValues The jst attributes of the template node. | 956 * @param {Object} jstAttributeValues The jst attributes of the template node. |
955 */ | 957 */ |
956 JstProcessor.prototype.logState_ = function( | 958 JstProcessor.prototype.logState_ = function( |
957 caller, template, jstAttributeValues) { | 959 caller, template, jstAttributeValues) { |
958 }; | 960 }; |
959 | |
960 | |
961 /** | |
962 * Retrieve the processing logs. | |
963 * @return {Array.<string>} The processing logs. | |
964 */ | |
965 JstProcessor.prototype.getLogs = function() { | |
966 return this.logs_; | |
967 }; | |
OLD | NEW |