Permalink
Browse files

Throw error when setting html id attribute that already exists

  • Loading branch information...
nvh committed Jan 26, 2018
1 parent 8bb17ec commit 5d18f8a927383463dfea958a8ae949eca63b9086
Showing with 8 additions and 0 deletions.
  1. +8 −0 framer/Layer.coffee
View
@@ -236,6 +236,8 @@ class exports.Layer extends BaseClass
@onChange("size", @updateForSizeChange)
@ExistingIdMessage: (type, id) -> "Can not set #{type}: There's already an element with id '#{id}' in this document'"
##############################################################
# Properties
@@ -924,6 +926,12 @@ class exports.Layer extends BaseClass
# a child node to insert it in, so it won't mess with Framers
# layer hierarchy.
@_createHTMLElementIfNeeded()
ids = Utils.getIdAttributesFromString(value)
for id in ids
existingElement = document.querySelector("[id='#{id}']")
if existingElement?
Utils.throwInStudioOrWarnInProduction(Layer.ExistingIdMessage("html", id))
return
@_elementHTML.innerHTML = value
@_updateHTMLScale()

0 comments on commit 5d18f8a

Please sign in to comment.