Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: third_party/jstemplate/jstemplate.js

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/jstemplate/jsevalcontext.js ('k') | third_party/libpng/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 * element in the array, with the array element being the context 545 * element in the array, with the array element being the context
546 * object. If the array is empty, or the value is undefined, then the 546 * object. If the array is empty, or the value is undefined, then the
547 * current template node is dropped. If the value is not an array, 547 * current template node is dropped. If the value is not an array,
548 * then it is just made the context object. 548 * then it is just made the context object.
549 * 549 *
550 * @param {JsEvalContext} context The current evaluation context. 550 * @param {JsEvalContext} context The current evaluation context.
551 * 551 *
552 * @param {Element} template The currently processed node of the template. 552 * @param {Element} template The currently processed node of the template.
553 * 553 *
554 * @param {Function} select The javascript expression to evaluate. 554 * @param {Function} select The javascript expression to evaluate.
555 *
556 * @notypecheck FIXME(hmitchell): See OCL6434950. instance and value need
557 * type checks.
555 */ 558 */
556 JstProcessor.prototype.jstSelect_ = function(context, template, select) { 559 JstProcessor.prototype.jstSelect_ = function(context, template, select) {
557 var me = this; 560 var me = this;
558 561
559 var value = context.jsexec(select, template); 562 var value = context.jsexec(select, template);
560 563
561 // Enable reprocessing: if this template is reprocessed, then only 564 // Enable reprocessing: if this template is reprocessed, then only
562 // fill the section instance here. Otherwise do the cardinal 565 // fill the section instance here. Otherwise do the cardinal
563 // processing of a new template. 566 // processing of a new template.
564 var instance = domGetAttribute(template, ATT_instance); 567 var instance = domGetAttribute(template, ATT_instance);
(...skipping 11 matching lines...) Expand all
576 // The expression value instanceof Array is occasionally false for 579 // The expression value instanceof Array is occasionally false for
577 // arrays, seen in Firefox. Thus we recognize an array as an object 580 // arrays, seen in Firefox. Thus we recognize an array as an object
578 // which is not null that has a length property. Notice that this 581 // which is not null that has a length property. Notice that this
579 // also matches input data with a length property, so this property 582 // also matches input data with a length property, so this property
580 // name should be avoided in input data. 583 // name should be avoided in input data.
581 var multiple = isArray(value); 584 var multiple = isArray(value);
582 var count = multiple ? jsLength(value) : 1; 585 var count = multiple ? jsLength(value) : 1;
583 var multipleEmpty = (multiple && count == 0); 586 var multipleEmpty = (multiple && count == 0);
584 587
585 if (multiple) { 588 if (multiple) {
586 value = /** @type Array */(value);
587 if (multipleEmpty) { 589 if (multipleEmpty) {
588 // For an empty array, keep the first template instance and mark 590 // For an empty array, keep the first template instance and mark
589 // it last. Remove all other template instances. 591 // it last. Remove all other template instances.
590 if (!instance) { 592 if (!instance) {
591 domSetAttribute(template, ATT_instance, STRING_asteriskzero); 593 domSetAttribute(template, ATT_instance, STRING_asteriskzero);
592 displayNone(template); 594 displayNone(template);
593 } else { 595 } else {
594 domRemoveNode(template); 596 domRemoveNode(template);
595 } 597 }
596 598
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 931
930 /** 932 /**
931 * Sets the jsinstance attribute on a node according to its context. 933 * Sets the jsinstance attribute on a node according to its context.
932 * 934 *
933 * @param {Element} template The template DOM node to set the instance 935 * @param {Element} template The template DOM node to set the instance
934 * attribute on. 936 * attribute on.
935 * 937 *
936 * @param {Array} values The current input context, the array of 938 * @param {Array} values The current input context, the array of
937 * values of which the template node will render one instance. 939 * values of which the template node will render one instance.
938 * 940 *
939 * @param {number|string} index The index of this template node in values. 941 * @param {number} index The index of this template node in values.
940 */ 942 */
941 function jstSetInstance(template, values, index) { 943 function jstSetInstance(template, values, index) {
942 if (index == jsLength(values) - 1) { 944 if (index == jsLength(values) - 1) {
943 domSetAttribute(template, ATT_instance, CHAR_asterisk + index); 945 domSetAttribute(template, ATT_instance, CHAR_asterisk + index);
944 } else { 946 } else {
945 domSetAttribute(template, ATT_instance, STRING_empty + index); 947 domSetAttribute(template, ATT_instance, STRING_empty + index);
946 } 948 }
947 } 949 }
948 950
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 };
OLDNEW
« no previous file with comments | « third_party/jstemplate/jsevalcontext.js ('k') | third_party/libpng/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698