summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/snippets.editor.js
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2017-06-01 01:46:13 +0200
committerOlivier Dony <odo@openerp.com>2017-06-01 01:46:13 +0200
commit5d2869cbc812f716e3115b5efb9bd1c3082f47b7 (patch)
tree364844fc326f0d095997120d10d83e67fdf341e9 /addons/web_editor/static/src/js/snippets.editor.js
parent04111cae39e36015d3c8494f52b110ab5ab6ad80 (diff)
parentba15df47cb25625cb0921cba554aa0879048c90a (diff)
[MERGE] Forward-port saas-16 up to ba15df47cb25625cb0921cba554aa0879048c90a
Diffstat (limited to 'addons/web_editor/static/src/js/snippets.editor.js')
-rw-r--r--addons/web_editor/static/src/js/snippets.editor.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/addons/web_editor/static/src/js/snippets.editor.js b/addons/web_editor/static/src/js/snippets.editor.js
index 20a96a91e84..42f2103f95f 100644
--- a/addons/web_editor/static/src/js/snippets.editor.js
+++ b/addons/web_editor/static/src/js/snippets.editor.js
@@ -107,7 +107,7 @@ data.Class = Widget.extend({
return $from.closest(selector, parentNode);
},
all: function ($from) {
- return $from ? $from.find(selector) : $(selector);
+ return $from ? cssFind($from, selector) : $(selector);
},
is: function ($from) {
return $from.is(selector);
@@ -130,15 +130,31 @@ data.Class = Widget.extend({
});
},
all: is_children ? function ($from) {
- return ($from || self.$editable).find(selector);
+ return cssFind($from || self.$editable, selector);
} : function ($from) {
- return $from ? $from.find(selector) : self.$editable.filter(selector).add(self.$editable.find(selector));
+ $from = $from || self.$editable;
+ return $from.filter(selector).add(cssFind($from, selector));
},
is: function ($from) {
return $from.is(selector);
}
};
}
+
+ /**
+ * jQuery find function behavior is:
+ * $('A').find('A B') <=> $('A A B')
+ * The searches behavior to find options' DOM needs to be
+ * $('A').find('A B') <=> $('A B')
+ * This is what this function does.
+ *
+ * @param {jQuery} $from - the jQuery element(s) from which to search
+ * @param {string} selector - the CSS selector to match
+ * @returns {jQuery}
+ */
+ function cssFind($from, selector) {
+ return $from.find('*').filter(selector);
+ }
},
fetch_snippet_templates: function () {