svg2-tools: Make <edit:with> disambiguate bare names to an attribute ...

details:   https://svgwg.org/hg/svg2-tools/rev/82c4907ef7c3
branches:  
changeset: 85:82c4907ef7c3
user:      Cameron McCormack <cam@mcc.id.au>
date:      Thu Apr 10 18:15:56 2014 +1000
description:
Make <edit:with> disambiguate bare names to an attribute on the element.

diffstat:

 publish/definitions.js |  8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diffs (28 lines):

diff --git a/publish/definitions.js b/publish/definitions.js
--- a/publish/definitions.js
+++ b/publish/definitions.js
@@ -268,16 +268,24 @@ function getElementContext(definitions, 
 }
 
 Definitions.prototype.formatNameLink = function(name, context, omitQuotes) {
   var elementName = getElementContext(this, context);
   var element = this.elements[name];
   var attribute = elementName && this.elements[elementName].attributes[name] || this.commonAttributes[name];
   var property = this.properties[name];
 
+  if (elementName && attribute) {
+    // Inside an <edit:with>, assume that <a>'name'</a> links refer to an
+    // attribute on the element given on the <edit:with>.  Outside an
+    // <edit:with>, the name must be unambiguous.
+    element = null;
+    property = null;
+  }
+
   if (!attribute && !property) {
     var attrs = findAttributesInCategories(this, name)
                   .concat(findCommonAttributesForElements(this, name));
     if (attrs.length > 1) {
       utils.warn('ambiguous name "' + name + '" matching multiple attributes', context);
       return utils.parse('<span class="xxx">@@ ambiguous name "{{name}}" (matches multiple attributes)</span>', { name: name });
     }
     attribute = attrs[0];

Received on Thursday, 10 April 2014 08:17:49 UTC