mirror of
https://github.com/discourse/discourse.git
synced 2025-06-20 14:41:43 +08:00
DEV: Make discourse-common
an Ember addon. (#9578)
This is to help with the migration to Ember CLI. In the current running version of Discourse everything should be the same as before, just with a few extra files that are not used. However, using Ember CLI this can be installed as an Ember addon. Co-Authored-By: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
@ -0,0 +1,42 @@
|
||||
// FROM: https://github.com/Matt-Esch/virtual-dom
|
||||
// License: MIT
|
||||
|
||||
function AttributeHook(namespace, value) {
|
||||
if (!(this instanceof AttributeHook)) {
|
||||
return new AttributeHook(namespace, value);
|
||||
}
|
||||
|
||||
this.namespace = namespace;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
AttributeHook.prototype.hook = function(node, prop, prev) {
|
||||
if (
|
||||
prev &&
|
||||
prev.type === "AttributeHook" &&
|
||||
prev.value === this.value &&
|
||||
prev.namespace === this.namespace
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
node.setAttributeNS(this.namespace, prop, this.value);
|
||||
};
|
||||
|
||||
AttributeHook.prototype.unhook = function(node, prop, next) {
|
||||
if (
|
||||
next &&
|
||||
next.type === "AttributeHook" &&
|
||||
next.namespace === this.namespace
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
var colonPosition = prop.indexOf(":");
|
||||
var localName = colonPosition > -1 ? prop.substr(colonPosition + 1) : prop;
|
||||
node.removeAttributeNS(this.namespace, localName);
|
||||
};
|
||||
|
||||
AttributeHook.prototype.type = "AttributeHook";
|
||||
|
||||
export default AttributeHook;
|
Reference in New Issue
Block a user