From cd09dd4cfc07abacdb33311e32e1f8c879163c40 Mon Sep 17 00:00:00 2001 From: Chao Liu Date: Wed, 29 Aug 2012 02:42:35 +0800 Subject: [PATCH] [Preperty View] Fix bug: using illegal values results in silent failure --- src/js/adm.js | 11 ++++++----- src/js/views/property.js | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/js/adm.js b/src/js/adm.js index 364f82fa..2b52fcef 100644 --- a/src/js/adm.js +++ b/src/js/adm.js @@ -2249,14 +2249,15 @@ ADMNode.prototype.setProperty = function (property, value, data, raw) { } } - // TODO: In HTML5 the rules for ids are not this strict, so this should be - // corrected with reference to the spec. - // HTML id naming rules: - // Must begin with a letter A-Z or a-z + // TODO: In HTML5 the rules for ids are not this strict, but JQM and jQuery don't work well + // with special chars, such as "$" "%" "/" accepted by HTML5. + // + // So we use the following id naming rules: + // Must begin with a letter A-Z or a-z or 0-9 // Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), and underscores ("_") // In HTML, all values are case-insensitive if (property == "id") { - var pattern = /^[a-zA-Z]([\w-]*)$/; + var pattern = /^[a-zA-Z0-9]([\w-]*)$/; if (value && !pattern.test(value)) { console.error("Error: attempted to set invalid id"); return rval; diff --git a/src/js/views/property.js b/src/js/views/property.js index d19ef861..33563fdf 100644 --- a/src/js/views/property.js +++ b/src/js/views/property.js @@ -471,7 +471,7 @@ ret = ADM.setProperty(node, updated, value); type = node.getType(); if (ret.result === false) { - $(this).val(node.getProperty(updated)); + $(this).effect("highlight", {color: "red"}, 1000).val(node.getProperty(updated)); } else if (type === "Button" && value === "previous page") { ADM.setProperty(node, "opentargetas", "default");